@gvnrdao/dh-sdk 0.0.219 → 0.0.220
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/browser/dist/index.js +5 -24
- package/dist/index.js +1128 -997
- package/dist/index.mjs +1128 -997
- package/dist/modules/bitcoin/bitcoin-operations.module.d.ts +2 -10
- package/dist/modules/cache/cache-manager.module.d.ts +200 -41
- package/dist/modules/diamond-hands-sdk.d.ts +1 -5
- package/dist/modules/loan/loan-query.module.d.ts +1 -5
- package/dist/modules/pkp/pkp-manager.module.d.ts +1 -5
- package/package.json +5 -5
- package/browser/dist/397.browser.js +0 -2
- package/browser/dist/397.browser.js.LICENSE.txt +0 -1
- package/browser/dist/833.browser.js +0 -2
- package/browser/dist/833.browser.js.LICENSE.txt +0 -1
- package/browser/dist/browser.js +0 -2
- package/browser/dist/browser.js.LICENSE.txt +0 -23
package/dist/index.mjs
CHANGED
|
@@ -12691,93 +12691,504 @@ var require_elliptic = __commonJS({
|
|
|
12691
12691
|
}
|
|
12692
12692
|
});
|
|
12693
12693
|
|
|
12694
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/
|
|
12695
|
-
var
|
|
12696
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/
|
|
12697
|
-
"use strict";
|
|
12698
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12699
|
-
}
|
|
12700
|
-
});
|
|
12701
|
-
|
|
12702
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/lit-action-config.i.js
|
|
12703
|
-
var require_lit_action_config_i = __commonJS({
|
|
12704
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/lit-action-config.i.js"(exports) {
|
|
12705
|
-
"use strict";
|
|
12706
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12707
|
-
}
|
|
12708
|
-
});
|
|
12709
|
-
|
|
12710
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.js
|
|
12711
|
-
var require_diamond_hands_lit_actions_i = __commonJS({
|
|
12712
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.js"(exports) {
|
|
12713
|
-
"use strict";
|
|
12714
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12715
|
-
}
|
|
12716
|
-
});
|
|
12717
|
-
|
|
12718
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/lit-action-registry.i.js
|
|
12719
|
-
var require_lit_action_registry_i = __commonJS({
|
|
12720
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/lit-action-registry.i.js"(exports) {
|
|
12721
|
-
"use strict";
|
|
12722
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12723
|
-
}
|
|
12724
|
-
});
|
|
12725
|
-
|
|
12726
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/index.js
|
|
12727
|
-
var require_interfaces = __commonJS({
|
|
12728
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/index.js"(exports) {
|
|
12694
|
+
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js
|
|
12695
|
+
var require_pkg_src = __commonJS({
|
|
12696
|
+
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js"(exports, module) {
|
|
12729
12697
|
"use strict";
|
|
12730
|
-
var
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
12738
|
-
|
|
12739
|
-
|
|
12740
|
-
}
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
|
|
12698
|
+
var __defProp2 = Object.defineProperty;
|
|
12699
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
12700
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
12701
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
12702
|
+
var __esm2 = (fn, res) => function __init() {
|
|
12703
|
+
return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
|
|
12704
|
+
};
|
|
12705
|
+
var __export2 = (target, all) => {
|
|
12706
|
+
for (var name in all)
|
|
12707
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
12708
|
+
};
|
|
12709
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
12710
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12711
|
+
for (let key2 of __getOwnPropNames2(from))
|
|
12712
|
+
if (!__hasOwnProp2.call(to, key2) && key2 !== except)
|
|
12713
|
+
__defProp2(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc2(from, key2)) || desc.enumerable });
|
|
12714
|
+
}
|
|
12715
|
+
return to;
|
|
12716
|
+
};
|
|
12717
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
12718
|
+
function configureDebugLogging(config) {
|
|
12719
|
+
debugConfig = { ...debugConfig, ...config };
|
|
12720
|
+
}
|
|
12721
|
+
function getTimestamp() {
|
|
12722
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
12723
|
+
}
|
|
12724
|
+
function formatMessage(level, component, message, metadata) {
|
|
12725
|
+
const timestamp = debugConfig.enableTimestamps ? `[${getTimestamp()}] ` : "";
|
|
12726
|
+
const metadataStr = metadata ? ` ${JSON.stringify(metadata)}` : "";
|
|
12727
|
+
return `${timestamp}[${level}] [${component}] ${message}${metadataStr}`;
|
|
12728
|
+
}
|
|
12729
|
+
function debugError(component, message, metadata) {
|
|
12730
|
+
if (debugConfig.level >= 0) {
|
|
12731
|
+
console.error(formatMessage("ERROR", component, message, metadata));
|
|
12732
|
+
}
|
|
12733
|
+
}
|
|
12734
|
+
function debugWarn(component, message, metadata) {
|
|
12735
|
+
if (debugConfig.level >= 1) {
|
|
12736
|
+
console.warn(formatMessage("WARN", component, message, metadata));
|
|
12737
|
+
}
|
|
12738
|
+
}
|
|
12739
|
+
function debugInfo(component, message, metadata) {
|
|
12740
|
+
if (debugConfig.level >= 2) {
|
|
12741
|
+
console.log(formatMessage("INFO", component, message, metadata));
|
|
12742
|
+
}
|
|
12743
|
+
}
|
|
12744
|
+
function debugLog(component, message, metadata) {
|
|
12745
|
+
if (debugConfig.level >= 3) {
|
|
12746
|
+
console.log(formatMessage("DEBUG", component, message, metadata));
|
|
12747
|
+
}
|
|
12748
|
+
}
|
|
12749
|
+
function debugTrace(component, message, metadata) {
|
|
12750
|
+
if (debugConfig.level >= 4) {
|
|
12751
|
+
console.log(formatMessage("TRACE", component, message, metadata));
|
|
12752
|
+
}
|
|
12753
|
+
}
|
|
12754
|
+
function logRequest(component, operation, params) {
|
|
12755
|
+
if (!debugConfig.enableRequestLogging)
|
|
12756
|
+
return;
|
|
12757
|
+
debugLog(component, `\u{1F504} Request: ${operation}`, {
|
|
12758
|
+
operation,
|
|
12759
|
+
params: JSON.stringify(params, null, 2)
|
|
12760
|
+
});
|
|
12761
|
+
}
|
|
12762
|
+
function logResponse(component, operation, response, duration) {
|
|
12763
|
+
if (!debugConfig.enableRequestLogging)
|
|
12764
|
+
return;
|
|
12765
|
+
debugLog(component, `\u2705 Response: ${operation} (${duration}ms)`, {
|
|
12766
|
+
operation,
|
|
12767
|
+
duration,
|
|
12768
|
+
response: typeof response === "object" ? JSON.stringify(response, null, 2) : response
|
|
12769
|
+
});
|
|
12770
|
+
}
|
|
12771
|
+
function logError(component, operation, error, duration) {
|
|
12772
|
+
const durationStr = duration ? ` (${duration}ms)` : "";
|
|
12773
|
+
debugError(component, `\u274C Error: ${operation}${durationStr}`, {
|
|
12774
|
+
operation,
|
|
12775
|
+
duration,
|
|
12776
|
+
error: error?.message || error?.toString() || "Unknown error",
|
|
12777
|
+
stack: error?.stack
|
|
12778
|
+
});
|
|
12779
|
+
}
|
|
12780
|
+
function logConnectionAttempt(network, attempt, maxAttempts) {
|
|
12781
|
+
debugInfo("CONNECTION", `\u{1F517} Connecting to ${network} (attempt ${attempt}/${maxAttempts})`);
|
|
12782
|
+
}
|
|
12783
|
+
function logConnectionSuccess(network, latency) {
|
|
12784
|
+
debugInfo("CONNECTION", `\u2705 Connected to ${network} (${latency}ms)`);
|
|
12785
|
+
networkMetrics.recordRequest(`connection-${network}`, true, latency);
|
|
12786
|
+
}
|
|
12787
|
+
function logConnectionFailure(network, error, attempt) {
|
|
12788
|
+
debugError("CONNECTION", `\u274C Connection failed to ${network} (attempt ${attempt})`, { error });
|
|
12789
|
+
networkMetrics.recordRequest(`connection-${network}`, false, 0, error);
|
|
12790
|
+
}
|
|
12791
|
+
function logPkpOperation(operation, pkpId, details) {
|
|
12792
|
+
const pkpStr = pkpId ? ` (PKP: ${pkpId.slice(0, 8)}...)` : "";
|
|
12793
|
+
debugInfo("PKP", `\u{1F511} ${operation}${pkpStr}`, details);
|
|
12794
|
+
}
|
|
12795
|
+
function logSessionSignatures(count, expiration) {
|
|
12796
|
+
debugInfo("SESSION", `\u{1F510} Generated ${count} session signatures (expires: ${expiration})`);
|
|
12797
|
+
}
|
|
12798
|
+
function logLitActionExecution(cid, params) {
|
|
12799
|
+
debugInfo("LIT_ACTION", `\u26A1 Executing LIT Action: ${cid}`, {
|
|
12800
|
+
cid,
|
|
12801
|
+
params
|
|
12802
|
+
});
|
|
12803
|
+
}
|
|
12804
|
+
function logLitActionResult(cid, success2, duration, result) {
|
|
12805
|
+
const status = success2 ? "\u2705" : "\u274C";
|
|
12806
|
+
debugInfo("LIT_ACTION", `${status} LIT Action completed: ${cid} (${duration}ms)`, {
|
|
12807
|
+
cid,
|
|
12808
|
+
success: success2,
|
|
12809
|
+
duration,
|
|
12810
|
+
result: success2 && result ? JSON.stringify(result, null, 2) : void 0
|
|
12811
|
+
});
|
|
12812
|
+
}
|
|
12813
|
+
function logTestStart(testName) {
|
|
12814
|
+
debugInfo("TEST", `\u{1F9EA} Starting test: ${testName}`);
|
|
12815
|
+
return new PerformanceTracker(testName);
|
|
12816
|
+
}
|
|
12817
|
+
function logTestEnd(testName, success2, duration) {
|
|
12818
|
+
const status = success2 ? "\u2705" : "\u274C";
|
|
12819
|
+
debugInfo("TEST", `${status} Test completed: ${testName} (${duration}ms)`);
|
|
12820
|
+
networkMetrics.printSummary();
|
|
12821
|
+
}
|
|
12822
|
+
var LogLevel2;
|
|
12823
|
+
var DEFAULT_DEBUG_CONFIG;
|
|
12824
|
+
var debugConfig;
|
|
12825
|
+
var PerformanceTracker;
|
|
12826
|
+
var NetworkMetricsCollector;
|
|
12827
|
+
var networkMetrics;
|
|
12828
|
+
var init_debug_logger = __esm2({
|
|
12829
|
+
"pkg-src/utils/chunks/debug-logger.ts"() {
|
|
12830
|
+
"use strict";
|
|
12831
|
+
LogLevel2 = /* @__PURE__ */ ((LogLevel22) => {
|
|
12832
|
+
LogLevel22[LogLevel22["ERROR"] = 0] = "ERROR";
|
|
12833
|
+
LogLevel22[LogLevel22["WARN"] = 1] = "WARN";
|
|
12834
|
+
LogLevel22[LogLevel22["INFO"] = 2] = "INFO";
|
|
12835
|
+
LogLevel22[LogLevel22["DEBUG"] = 3] = "DEBUG";
|
|
12836
|
+
LogLevel22[LogLevel22["TRACE"] = 4] = "TRACE";
|
|
12837
|
+
return LogLevel22;
|
|
12838
|
+
})(LogLevel2 || {});
|
|
12839
|
+
DEFAULT_DEBUG_CONFIG = {
|
|
12840
|
+
level: 2,
|
|
12841
|
+
enableTimestamps: true,
|
|
12842
|
+
enablePerformanceMetrics: true,
|
|
12843
|
+
enableRequestLogging: true,
|
|
12844
|
+
enableNetworkMetrics: true
|
|
12845
|
+
};
|
|
12846
|
+
debugConfig = { ...DEFAULT_DEBUG_CONFIG };
|
|
12847
|
+
PerformanceTracker = class {
|
|
12848
|
+
constructor(operationName) {
|
|
12849
|
+
this.operationName = operationName;
|
|
12850
|
+
this.markers = /* @__PURE__ */ new Map();
|
|
12851
|
+
this.startTime = Date.now();
|
|
12852
|
+
this.log("PERF", `Started: ${operationName}`);
|
|
12853
|
+
}
|
|
12854
|
+
mark(label) {
|
|
12855
|
+
const elapsed = Date.now() - this.startTime;
|
|
12856
|
+
this.markers.set(label, elapsed);
|
|
12857
|
+
this.log("PERF", `${this.operationName} - ${label}: ${elapsed}ms`);
|
|
12858
|
+
}
|
|
12859
|
+
end(success2 = true) {
|
|
12860
|
+
const totalTime = Date.now() - this.startTime;
|
|
12861
|
+
const status = success2 ? "SUCCESS" : "FAILED";
|
|
12862
|
+
this.log("PERF", `${this.operationName} - ${status}: ${totalTime}ms`);
|
|
12863
|
+
if (debugConfig.enablePerformanceMetrics && this.markers.size > 0) {
|
|
12864
|
+
console.log(`\u{1F4CA} Performance Breakdown for ${this.operationName}:`);
|
|
12865
|
+
for (const [label, time] of this.markers) {
|
|
12866
|
+
console.log(` ${label}: ${time}ms`);
|
|
12867
|
+
}
|
|
12868
|
+
console.log(` Total: ${totalTime}ms`);
|
|
12869
|
+
}
|
|
12870
|
+
return totalTime;
|
|
12871
|
+
}
|
|
12872
|
+
log(level, message) {
|
|
12873
|
+
if (debugConfig.enablePerformanceMetrics) {
|
|
12874
|
+
console.log(formatMessage(level, "PERFORMANCE", message));
|
|
12875
|
+
}
|
|
12876
|
+
}
|
|
12877
|
+
};
|
|
12878
|
+
NetworkMetricsCollector = class {
|
|
12879
|
+
constructor() {
|
|
12880
|
+
this.metrics = /* @__PURE__ */ new Map();
|
|
12881
|
+
}
|
|
12882
|
+
getMetrics(operation) {
|
|
12883
|
+
if (!this.metrics.has(operation)) {
|
|
12884
|
+
this.metrics.set(operation, {
|
|
12885
|
+
requestCount: 0,
|
|
12886
|
+
successCount: 0,
|
|
12887
|
+
failureCount: 0,
|
|
12888
|
+
averageLatency: 0,
|
|
12889
|
+
startTime: Date.now()
|
|
12890
|
+
});
|
|
12891
|
+
}
|
|
12892
|
+
return this.metrics.get(operation);
|
|
12893
|
+
}
|
|
12894
|
+
recordRequest(operation, success2, latency, error) {
|
|
12895
|
+
const metrics = this.getMetrics(operation);
|
|
12896
|
+
metrics.requestCount++;
|
|
12897
|
+
if (success2) {
|
|
12898
|
+
metrics.successCount++;
|
|
12899
|
+
metrics.averageLatency = (metrics.averageLatency * (metrics.successCount - 1) + latency) / metrics.successCount;
|
|
12900
|
+
} else {
|
|
12901
|
+
metrics.failureCount++;
|
|
12902
|
+
if (error)
|
|
12903
|
+
metrics.lastError = error;
|
|
12904
|
+
}
|
|
12905
|
+
if (debugConfig.enableNetworkMetrics) {
|
|
12906
|
+
const successRate = (metrics.successCount / metrics.requestCount * 100).toFixed(1);
|
|
12907
|
+
debugLog("NETWORK", `${operation} - Success: ${success2}, Latency: ${latency}ms, Success Rate: ${successRate}%`);
|
|
12908
|
+
}
|
|
12909
|
+
}
|
|
12910
|
+
printSummary() {
|
|
12911
|
+
if (!debugConfig.enableNetworkMetrics)
|
|
12912
|
+
return;
|
|
12913
|
+
console.log("\n\u{1F4C8} Network Metrics Summary:");
|
|
12914
|
+
for (const [operation, metrics] of this.metrics) {
|
|
12915
|
+
const successRate = (metrics.successCount / metrics.requestCount * 100).toFixed(1);
|
|
12916
|
+
const runtime = Date.now() - metrics.startTime;
|
|
12917
|
+
console.log(` ${operation}:`);
|
|
12918
|
+
console.log(` Requests: ${metrics.requestCount}`);
|
|
12919
|
+
console.log(` Success Rate: ${successRate}%`);
|
|
12920
|
+
console.log(` Avg Latency: ${metrics.averageLatency.toFixed(0)}ms`);
|
|
12921
|
+
console.log(` Runtime: ${runtime}ms`);
|
|
12922
|
+
if (metrics.lastError) {
|
|
12923
|
+
console.log(` Last Error: ${metrics.lastError}`);
|
|
12924
|
+
}
|
|
12925
|
+
}
|
|
12926
|
+
}
|
|
12927
|
+
};
|
|
12928
|
+
networkMetrics = new NetworkMetricsCollector();
|
|
12929
|
+
}
|
|
12744
12930
|
});
|
|
12745
|
-
var
|
|
12746
|
-
|
|
12747
|
-
|
|
12748
|
-
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12931
|
+
var session_signature_cache_exports = {};
|
|
12932
|
+
__export2(session_signature_cache_exports, {
|
|
12933
|
+
DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
|
|
12934
|
+
clearSessionSignatureCache: () => clearSessionSignatureCache,
|
|
12935
|
+
configureSessionSignatureCache: () => configureSessionSignatureCache,
|
|
12936
|
+
generateSessionSignaturesWithCache: () => generateSessionSignaturesWithCache,
|
|
12937
|
+
getSessionSignatureCacheStats: () => getSessionSignatureCacheStats,
|
|
12938
|
+
sessionSignatureCache: () => sessionSignatureCache
|
|
12939
|
+
});
|
|
12940
|
+
async function generateSessionSignaturesWithCache(litNodeClient, sessionConfig, pkpTokenId, litActionCid, signerAddress, network = "chipotle") {
|
|
12941
|
+
const cached = sessionSignatureCache.get(pkpTokenId, litActionCid, signerAddress, network);
|
|
12942
|
+
if (cached) {
|
|
12943
|
+
return cached;
|
|
12944
|
+
}
|
|
12945
|
+
debugInfo("CACHE", "\u{1F510} Generating new session signatures (cache miss)...");
|
|
12946
|
+
const sessionSigs = await litNodeClient.getSessionSigs(sessionConfig);
|
|
12947
|
+
const expiration = new Date(sessionConfig.expiration);
|
|
12948
|
+
sessionSignatureCache.set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration);
|
|
12949
|
+
const sigCount = Object.keys(sessionSigs).length;
|
|
12950
|
+
debugInfo("CACHE", `\u2705 Generated and cached ${sigCount} session signatures`);
|
|
12951
|
+
return sessionSigs;
|
|
12952
|
+
}
|
|
12953
|
+
function configureSessionSignatureCache(config) {
|
|
12954
|
+
Object.assign(sessionSignatureCache["config"], config);
|
|
12955
|
+
}
|
|
12956
|
+
function clearSessionSignatureCache() {
|
|
12957
|
+
sessionSignatureCache.clear();
|
|
12958
|
+
}
|
|
12959
|
+
function getSessionSignatureCacheStats() {
|
|
12960
|
+
return sessionSignatureCache.getStats();
|
|
12961
|
+
}
|
|
12962
|
+
var DEFAULT_CACHE_CONFIG;
|
|
12963
|
+
var SessionSignatureCache;
|
|
12964
|
+
var sessionSignatureCache;
|
|
12965
|
+
var init_session_signature_cache = __esm2({
|
|
12966
|
+
"pkg-src/utils/chunks/session-signature-cache.ts"() {
|
|
12967
|
+
"use strict";
|
|
12968
|
+
init_debug_logger();
|
|
12969
|
+
DEFAULT_CACHE_CONFIG = {
|
|
12970
|
+
maxEntries: 50,
|
|
12971
|
+
bufferTimeMs: 6e4,
|
|
12972
|
+
// 1 minute buffer before expiration
|
|
12973
|
+
enableLogging: true
|
|
12974
|
+
};
|
|
12975
|
+
SessionSignatureCache = class {
|
|
12976
|
+
constructor(config = {}) {
|
|
12977
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
12978
|
+
this.config = { ...DEFAULT_CACHE_CONFIG, ...config };
|
|
12979
|
+
}
|
|
12980
|
+
/**
|
|
12981
|
+
* Generate cache key from PKP and context
|
|
12982
|
+
*/
|
|
12983
|
+
generateCacheKey(pkpTokenId, litActionCid, signerAddress, network) {
|
|
12984
|
+
return `${signerAddress}-${network}-${pkpTokenId}-${litActionCid}`;
|
|
12985
|
+
}
|
|
12986
|
+
/**
|
|
12987
|
+
* Check if cache entry is still valid
|
|
12988
|
+
*/
|
|
12989
|
+
isEntryValid(entry) {
|
|
12990
|
+
const now2 = /* @__PURE__ */ new Date();
|
|
12991
|
+
const expirationWithBuffer = new Date(
|
|
12992
|
+
entry.expiration.getTime() - this.config.bufferTimeMs
|
|
12993
|
+
);
|
|
12994
|
+
return now2 < expirationWithBuffer;
|
|
12995
|
+
}
|
|
12996
|
+
/**
|
|
12997
|
+
* Clean expired entries from cache
|
|
12998
|
+
*/
|
|
12999
|
+
cleanExpiredEntries() {
|
|
13000
|
+
const now2 = /* @__PURE__ */ new Date();
|
|
13001
|
+
let cleanedCount = 0;
|
|
13002
|
+
for (const [key2, entry] of this.cache.entries()) {
|
|
13003
|
+
if (now2 >= entry.expiration) {
|
|
13004
|
+
this.cache.delete(key2);
|
|
13005
|
+
cleanedCount++;
|
|
13006
|
+
}
|
|
13007
|
+
}
|
|
13008
|
+
if (cleanedCount > 0 && this.config.enableLogging) {
|
|
13009
|
+
debugInfo("CACHE", `\u{1F9F9} Cleaned ${cleanedCount} expired session signature entries`);
|
|
13010
|
+
}
|
|
13011
|
+
}
|
|
13012
|
+
/**
|
|
13013
|
+
* Enforce cache size limits
|
|
13014
|
+
*/
|
|
13015
|
+
enforceCacheSize() {
|
|
13016
|
+
if (this.cache.size <= this.config.maxEntries) {
|
|
13017
|
+
return;
|
|
13018
|
+
}
|
|
13019
|
+
const entries = Array.from(this.cache.entries()).sort(([, a], [, b]) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
13020
|
+
const toRemove = entries.slice(0, this.cache.size - this.config.maxEntries);
|
|
13021
|
+
for (const [key2] of toRemove) {
|
|
13022
|
+
this.cache.delete(key2);
|
|
13023
|
+
}
|
|
13024
|
+
if (this.config.enableLogging) {
|
|
13025
|
+
debugInfo("CACHE", `\u{1F4E6} Removed ${toRemove.length} oldest cache entries to maintain size limit`);
|
|
13026
|
+
}
|
|
13027
|
+
}
|
|
13028
|
+
/**
|
|
13029
|
+
* Get cached session signatures if valid
|
|
13030
|
+
*/
|
|
13031
|
+
get(pkpTokenId, litActionCid, signerAddress, network) {
|
|
13032
|
+
this.cleanExpiredEntries();
|
|
13033
|
+
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13034
|
+
const entry = this.cache.get(cacheKey);
|
|
13035
|
+
if (!entry) {
|
|
13036
|
+
if (this.config.enableLogging) {
|
|
13037
|
+
debugLog("CACHE", `\u274C Session signatures cache miss: ${cacheKey}`);
|
|
13038
|
+
}
|
|
13039
|
+
return null;
|
|
13040
|
+
}
|
|
13041
|
+
if (!this.isEntryValid(entry)) {
|
|
13042
|
+
this.cache.delete(cacheKey);
|
|
13043
|
+
if (this.config.enableLogging) {
|
|
13044
|
+
debugWarn("CACHE", `\u23F0 Session signatures expired: ${cacheKey}`);
|
|
13045
|
+
}
|
|
13046
|
+
return null;
|
|
13047
|
+
}
|
|
13048
|
+
if (this.config.enableLogging) {
|
|
13049
|
+
const timeUntilExpiry = entry.expiration.getTime() - Date.now();
|
|
13050
|
+
debugInfo("CACHE", `\u2705 Session signatures cache hit: ${cacheKey} (expires in ${Math.round(timeUntilExpiry / 1e3)}s)`);
|
|
13051
|
+
}
|
|
13052
|
+
return entry.sessionSigs;
|
|
13053
|
+
}
|
|
13054
|
+
/**
|
|
13055
|
+
* Cache session signatures
|
|
13056
|
+
*/
|
|
13057
|
+
set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration) {
|
|
13058
|
+
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13059
|
+
const entry = {
|
|
13060
|
+
sessionSigs,
|
|
13061
|
+
expiration,
|
|
13062
|
+
pkpTokenId,
|
|
13063
|
+
litActionCid,
|
|
13064
|
+
signerAddress,
|
|
13065
|
+
network,
|
|
13066
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
13067
|
+
};
|
|
13068
|
+
this.cache.set(cacheKey, entry);
|
|
13069
|
+
if (this.config.enableLogging) {
|
|
13070
|
+
const timeUntilExpiry = expiration.getTime() - Date.now();
|
|
13071
|
+
debugInfo("CACHE", `\u{1F4BE} Cached session signatures: ${cacheKey} (expires in ${Math.round(timeUntilExpiry / 1e3)}s)`);
|
|
13072
|
+
}
|
|
13073
|
+
this.enforceCacheSize();
|
|
13074
|
+
}
|
|
13075
|
+
/**
|
|
13076
|
+
* Clear all cached session signatures
|
|
13077
|
+
*/
|
|
13078
|
+
clear() {
|
|
13079
|
+
const size = this.cache.size;
|
|
13080
|
+
this.cache.clear();
|
|
13081
|
+
if (this.config.enableLogging) {
|
|
13082
|
+
debugInfo("CACHE", `\u{1F5D1}\uFE0F Cleared ${size} cached session signature entries`);
|
|
13083
|
+
}
|
|
13084
|
+
}
|
|
13085
|
+
/**
|
|
13086
|
+
* Get cache statistics
|
|
13087
|
+
*/
|
|
13088
|
+
getStats() {
|
|
13089
|
+
this.cleanExpiredEntries();
|
|
13090
|
+
return {
|
|
13091
|
+
size: this.cache.size,
|
|
13092
|
+
maxEntries: this.config.maxEntries,
|
|
13093
|
+
utilizationPercent: Math.round(this.cache.size / this.config.maxEntries * 100)
|
|
13094
|
+
};
|
|
13095
|
+
}
|
|
13096
|
+
/**
|
|
13097
|
+
* Remove specific cache entry
|
|
13098
|
+
*/
|
|
13099
|
+
delete(pkpTokenId, litActionCid, signerAddress, network) {
|
|
13100
|
+
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13101
|
+
const deleted = this.cache.delete(cacheKey);
|
|
13102
|
+
if (deleted && this.config.enableLogging) {
|
|
13103
|
+
debugInfo("CACHE", `\u{1F5D1}\uFE0F Removed session signatures from cache: ${cacheKey}`);
|
|
13104
|
+
}
|
|
13105
|
+
return deleted;
|
|
13106
|
+
}
|
|
13107
|
+
};
|
|
13108
|
+
sessionSignatureCache = new SessionSignatureCache();
|
|
13109
|
+
}
|
|
13110
|
+
});
|
|
13111
|
+
var index_exports = {};
|
|
13112
|
+
__export2(index_exports, {
|
|
13113
|
+
CHIPOTLE_DEPLOYMENTS: () => CHIPOTLE_DEPLOYMENTS,
|
|
13114
|
+
DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
|
|
13115
|
+
DEFAULT_DEBUG_CONFIG: () => DEFAULT_DEBUG_CONFIG,
|
|
13116
|
+
DEFAULT_RETRY_CONFIG: () => DEFAULT_RETRY_CONFIG,
|
|
13117
|
+
DH_LIT_ACTIONS_CHIPOTLE: () => DH_LIT_ACTIONS_CHIPOTLE3,
|
|
13118
|
+
ErrorCategory: () => ErrorCategory2,
|
|
13119
|
+
LogLevel: () => LogLevel2,
|
|
13120
|
+
NETWORK_TIMEOUTS: () => NETWORK_TIMEOUTS,
|
|
13121
|
+
PerformanceTracker: () => PerformanceTracker,
|
|
13122
|
+
RetryStrategy: () => RetryStrategy,
|
|
13123
|
+
analyzeError: () => analyzeError,
|
|
13124
|
+
calculateDelay: () => calculateDelay,
|
|
13125
|
+
cidToHex: () => cidToHex,
|
|
13126
|
+
classifyError: () => classifyError,
|
|
13127
|
+
clearSessionSignatureCache: () => clearSessionSignatureCache,
|
|
13128
|
+
configureDebugLogging: () => configureDebugLogging,
|
|
13129
|
+
configureSessionSignatureCache: () => configureSessionSignatureCache,
|
|
13130
|
+
connectLitContracts: () => connectLitContracts,
|
|
13131
|
+
connectLitNodeClient: () => connectLitNodeClient,
|
|
13132
|
+
createErrorReport: () => createErrorReport,
|
|
13133
|
+
debugError: () => debugError,
|
|
13134
|
+
debugInfo: () => debugInfo,
|
|
13135
|
+
debugLog: () => debugLog,
|
|
13136
|
+
debugTrace: () => debugTrace,
|
|
13137
|
+
debugWarn: () => debugWarn,
|
|
13138
|
+
executeLitAction: () => executeLitAction,
|
|
13139
|
+
executePkpOperation: () => executePkpOperation,
|
|
13140
|
+
generateSessionSignatures: () => generateSessionSignatures,
|
|
13141
|
+
generateSessionSignaturesWithCache: () => generateSessionSignaturesWithCache,
|
|
13142
|
+
getDeployedActions: () => getDeployedActions,
|
|
13143
|
+
getDeploymentsForNetwork: () => getDeploymentsForNetwork,
|
|
13144
|
+
getLitActionCID: () => getLitActionCID,
|
|
13145
|
+
getLitActionConfig: () => getLitActionConfig,
|
|
13146
|
+
getNetworkTimeouts: () => getNetworkTimeouts,
|
|
13147
|
+
getPKPValidatorSetup: () => getPKPValidatorSetup,
|
|
13148
|
+
getRetryConfigFromClassification: () => getRetryConfigFromClassification,
|
|
13149
|
+
getSessionSignatureCacheStats: () => getSessionSignatureCacheStats,
|
|
13150
|
+
isLitActionDeployed: () => isLitActionDeployed,
|
|
13151
|
+
isRetryableError: () => isRetryableError,
|
|
13152
|
+
litProtocolErrors: () => litProtocolErrors,
|
|
13153
|
+
logConnectionAttempt: () => logConnectionAttempt,
|
|
13154
|
+
logConnectionFailure: () => logConnectionFailure,
|
|
13155
|
+
logConnectionSuccess: () => logConnectionSuccess,
|
|
13156
|
+
logError: () => logError,
|
|
13157
|
+
logLitActionExecution: () => logLitActionExecution,
|
|
13158
|
+
logLitActionResult: () => logLitActionResult,
|
|
13159
|
+
logPkpOperation: () => logPkpOperation,
|
|
13160
|
+
logRequest: () => logRequest,
|
|
13161
|
+
logResponse: () => logResponse,
|
|
13162
|
+
logSessionSignatures: () => logSessionSignatures,
|
|
13163
|
+
logTestEnd: () => logTestEnd,
|
|
13164
|
+
logTestStart: () => logTestStart,
|
|
13165
|
+
networkMetrics: () => networkMetrics,
|
|
13166
|
+
sessionSignatureCache: () => sessionSignatureCache,
|
|
13167
|
+
sleep: () => sleep,
|
|
13168
|
+
validateDeployedActions: () => validateDeployedActions,
|
|
13169
|
+
validateLitNodeConnection: () => validateLitNodeConnection,
|
|
13170
|
+
validateLitNodeReadiness: () => validateLitNodeReadiness,
|
|
13171
|
+
withRetry: () => withRetry
|
|
13172
|
+
});
|
|
13173
|
+
module.exports = __toCommonJS2(index_exports);
|
|
13174
|
+
function base2(ALPHABET2) {
|
|
13175
|
+
if (ALPHABET2.length >= 255) {
|
|
12765
13176
|
throw new TypeError("Alphabet too long");
|
|
12766
13177
|
}
|
|
12767
13178
|
const BASE_MAP = new Uint8Array(256);
|
|
12768
13179
|
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
12769
13180
|
BASE_MAP[j] = 255;
|
|
12770
13181
|
}
|
|
12771
|
-
for (let i = 0; i <
|
|
12772
|
-
const x =
|
|
13182
|
+
for (let i = 0; i < ALPHABET2.length; i++) {
|
|
13183
|
+
const x = ALPHABET2.charAt(i);
|
|
12773
13184
|
const xc = x.charCodeAt(0);
|
|
12774
13185
|
if (BASE_MAP[xc] !== 255) {
|
|
12775
13186
|
throw new TypeError(x + " is ambiguous");
|
|
12776
13187
|
}
|
|
12777
13188
|
BASE_MAP[xc] = i;
|
|
12778
13189
|
}
|
|
12779
|
-
const BASE =
|
|
12780
|
-
const LEADER =
|
|
13190
|
+
const BASE = ALPHABET2.length;
|
|
13191
|
+
const LEADER = ALPHABET2.charAt(0);
|
|
12781
13192
|
const FACTOR = Math.log(BASE) / Math.log(256);
|
|
12782
13193
|
const iFACTOR = Math.log(256) / Math.log(BASE);
|
|
12783
13194
|
function encode4(source) {
|
|
@@ -12823,7 +13234,7 @@ var require_cjs = __commonJS({
|
|
|
12823
13234
|
}
|
|
12824
13235
|
let str = LEADER.repeat(zeroes);
|
|
12825
13236
|
for (; it2 < size; ++it2) {
|
|
12826
|
-
str +=
|
|
13237
|
+
str += ALPHABET2.charAt(b58[it2]);
|
|
12827
13238
|
}
|
|
12828
13239
|
return str;
|
|
12829
13240
|
}
|
|
@@ -12888,38 +13299,13 @@ var require_cjs = __commonJS({
|
|
|
12888
13299
|
decode: decode3
|
|
12889
13300
|
};
|
|
12890
13301
|
}
|
|
12891
|
-
|
|
12892
|
-
}
|
|
12893
|
-
});
|
|
12894
|
-
|
|
12895
|
-
// node_modules/bs58/src/cjs/index.cjs
|
|
12896
|
-
var require_cjs2 = __commonJS({
|
|
12897
|
-
"node_modules/bs58/src/cjs/index.cjs"(exports) {
|
|
12898
|
-
"use strict";
|
|
12899
|
-
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
12900
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
12901
|
-
};
|
|
12902
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12903
|
-
var base_x_1 = __importDefault(require_cjs());
|
|
13302
|
+
var esm_default = base2;
|
|
12904
13303
|
var ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
12905
|
-
|
|
12906
|
-
}
|
|
12907
|
-
});
|
|
12908
|
-
|
|
12909
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/cid-utils.js
|
|
12910
|
-
var require_cid_utils = __commonJS({
|
|
12911
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/cid-utils.js"(exports) {
|
|
12912
|
-
"use strict";
|
|
12913
|
-
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
12914
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
12915
|
-
};
|
|
12916
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12917
|
-
exports.cidToHex = cidToHex;
|
|
12918
|
-
var bs58_1 = __importDefault(require_cjs2());
|
|
13304
|
+
var esm_default2 = esm_default(ALPHABET);
|
|
12919
13305
|
function cidToHex(cid) {
|
|
12920
13306
|
try {
|
|
12921
13307
|
if (cid.startsWith("Qm")) {
|
|
12922
|
-
const bytes =
|
|
13308
|
+
const bytes = esm_default2.decode(cid);
|
|
12923
13309
|
return "0x" + Buffer.from(bytes).toString("hex");
|
|
12924
13310
|
} else if (cid.startsWith("0x")) {
|
|
12925
13311
|
return cid;
|
|
@@ -12933,21 +13319,12 @@ var require_cid_utils = __commonJS({
|
|
|
12933
13319
|
throw new Error(`Failed to convert CID ${cid} to hex: ${error instanceof Error ? error.message : String(error)}`);
|
|
12934
13320
|
}
|
|
12935
13321
|
}
|
|
12936
|
-
|
|
12937
|
-
});
|
|
12938
|
-
|
|
12939
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.js
|
|
12940
|
-
var require_lit_actions_registry = __commonJS({
|
|
12941
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.js"(exports) {
|
|
12942
|
-
"use strict";
|
|
12943
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12944
|
-
exports.CHIPOTLE_DEPLOYMENTS = exports.DH_LIT_ACTIONS_CHIPOTLE = void 0;
|
|
12945
|
-
exports.getDeploymentsForNetwork = getDeploymentsForNetwork;
|
|
12946
|
-
var cid_utils_1 = require_cid_utils();
|
|
12947
|
-
exports.DH_LIT_ACTIONS_CHIPOTLE = {
|
|
13322
|
+
var DH_LIT_ACTIONS_CHIPOTLE3 = {
|
|
12948
13323
|
authorizationDummy: {
|
|
12949
13324
|
cid: "QmXPh5RTReLqjqZDRNhgVKi1TWMJK2vS9QSRPkWPhLBQJN",
|
|
12950
|
-
authorizedCidHex:
|
|
13325
|
+
authorizedCidHex: cidToHex(
|
|
13326
|
+
"QmXPh5RTReLqjqZDRNhgVKi1TWMJK2vS9QSRPkWPhLBQJN"
|
|
13327
|
+
),
|
|
12951
13328
|
name: "Authorization Dummy",
|
|
12952
13329
|
description: "Production Authorization Dummy",
|
|
12953
13330
|
version: "1.0.0",
|
|
@@ -12958,7 +13335,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
12958
13335
|
},
|
|
12959
13336
|
authorizationDummyB: {
|
|
12960
13337
|
cid: "QmQXTcAU9tr4YAVrzHujEJw9moJgM1o5gnJU2ojcvhigua",
|
|
12961
|
-
authorizedCidHex:
|
|
13338
|
+
authorizedCidHex: cidToHex(
|
|
13339
|
+
"QmQXTcAU9tr4YAVrzHujEJw9moJgM1o5gnJU2ojcvhigua"
|
|
13340
|
+
),
|
|
12962
13341
|
name: "Authorization Dummy B",
|
|
12963
13342
|
description: "Production Authorization Dummy B",
|
|
12964
13343
|
version: "1.0.0",
|
|
@@ -12969,7 +13348,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
12969
13348
|
},
|
|
12970
13349
|
pkpValidator: {
|
|
12971
13350
|
cid: "QmTqsmXkjib7CRGFcEhmCs61Z3EZTaRPznaZDDLk5Wq9NX",
|
|
12972
|
-
authorizedCidHex:
|
|
13351
|
+
authorizedCidHex: cidToHex(
|
|
13352
|
+
"QmTqsmXkjib7CRGFcEhmCs61Z3EZTaRPznaZDDLk5Wq9NX"
|
|
13353
|
+
),
|
|
12973
13354
|
name: "Pkp Validator",
|
|
12974
13355
|
description: "Production Pkp Validator",
|
|
12975
13356
|
version: "1.0.0",
|
|
@@ -12985,7 +13366,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
12985
13366
|
},
|
|
12986
13367
|
btcTransactionSigner: {
|
|
12987
13368
|
cid: "QmYSvuDcn2EPjRoDsPBLK2e3PGYEUHtWAPxwB51s4unkaG",
|
|
12988
|
-
authorizedCidHex:
|
|
13369
|
+
authorizedCidHex: cidToHex(
|
|
13370
|
+
"QmYSvuDcn2EPjRoDsPBLK2e3PGYEUHtWAPxwB51s4unkaG"
|
|
13371
|
+
),
|
|
12989
13372
|
name: "Btc Transaction Signer",
|
|
12990
13373
|
description: "Production Btc Transaction Signer",
|
|
12991
13374
|
version: "1.0.0",
|
|
@@ -12996,7 +13379,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
12996
13379
|
},
|
|
12997
13380
|
ucdMintValidator: {
|
|
12998
13381
|
cid: "QmbYWJkLBdxTCNUkYTVmBzcp4CFhAn7ZcCyMZjhhbjAUMB",
|
|
12999
|
-
authorizedCidHex:
|
|
13382
|
+
authorizedCidHex: cidToHex(
|
|
13383
|
+
"QmbYWJkLBdxTCNUkYTVmBzcp4CFhAn7ZcCyMZjhhbjAUMB"
|
|
13384
|
+
),
|
|
13000
13385
|
name: "Ucd Mint Validator",
|
|
13001
13386
|
description: "Production Ucd Mint Validator",
|
|
13002
13387
|
version: "1.0.0",
|
|
@@ -13012,7 +13397,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13012
13397
|
},
|
|
13013
13398
|
processPaymentValidator: {
|
|
13014
13399
|
cid: "Qmc9gkDVY1SK9vvyQ9cXa3PSSuv8q6Ki9o9rsG87qpXCYi",
|
|
13015
|
-
authorizedCidHex:
|
|
13400
|
+
authorizedCidHex: cidToHex(
|
|
13401
|
+
"Qmc9gkDVY1SK9vvyQ9cXa3PSSuv8q6Ki9o9rsG87qpXCYi"
|
|
13402
|
+
),
|
|
13016
13403
|
name: "Process Payment Validator",
|
|
13017
13404
|
description: "Production Process Payment Validator",
|
|
13018
13405
|
version: "1.0.0",
|
|
@@ -13028,7 +13415,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13028
13415
|
},
|
|
13029
13416
|
extendPositionValidator: {
|
|
13030
13417
|
cid: "Qmc5MDW6ZxTRe3nXJEKa5KKUCVXFznV9vDqFL4n7ayRZ4p",
|
|
13031
|
-
authorizedCidHex:
|
|
13418
|
+
authorizedCidHex: cidToHex(
|
|
13419
|
+
"Qmc5MDW6ZxTRe3nXJEKa5KKUCVXFznV9vDqFL4n7ayRZ4p"
|
|
13420
|
+
),
|
|
13032
13421
|
name: "Extend Position Validator",
|
|
13033
13422
|
description: "Production Extend Position Validator",
|
|
13034
13423
|
version: "1.0.0",
|
|
@@ -13044,7 +13433,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13044
13433
|
},
|
|
13045
13434
|
btcWithdrawal: {
|
|
13046
13435
|
cid: "QmQC7QKobtNJKArGK7rgGj8ZCcEWt1pBKXPyd5SZ2fi4tt",
|
|
13047
|
-
authorizedCidHex:
|
|
13436
|
+
authorizedCidHex: cidToHex(
|
|
13437
|
+
"QmQC7QKobtNJKArGK7rgGj8ZCcEWt1pBKXPyd5SZ2fi4tt"
|
|
13438
|
+
),
|
|
13048
13439
|
name: "Btc Withdrawal",
|
|
13049
13440
|
description: "Production Btc Withdrawal",
|
|
13050
13441
|
version: "1.0.1",
|
|
@@ -13060,7 +13451,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13060
13451
|
},
|
|
13061
13452
|
liquidationValidator: {
|
|
13062
13453
|
cid: "QmZscQTKzwqWDZwYfaE57vdG4vYoNeQMkC2DwgJsnRNgQf",
|
|
13063
|
-
authorizedCidHex:
|
|
13454
|
+
authorizedCidHex: cidToHex(
|
|
13455
|
+
"QmZscQTKzwqWDZwYfaE57vdG4vYoNeQMkC2DwgJsnRNgQf"
|
|
13456
|
+
),
|
|
13064
13457
|
name: "Liquidation Validator",
|
|
13065
13458
|
description: "Production Liquidation Validator",
|
|
13066
13459
|
version: "1.0.0",
|
|
@@ -13076,7 +13469,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13076
13469
|
},
|
|
13077
13470
|
priceOracle: {
|
|
13078
13471
|
cid: "Qma6vTTnn3AFy3A4u3A7T5tT6eEp26vXt7rPHSWpmBpdsp",
|
|
13079
|
-
authorizedCidHex:
|
|
13472
|
+
authorizedCidHex: cidToHex(
|
|
13473
|
+
"Qma6vTTnn3AFy3A4u3A7T5tT6eEp26vXt7rPHSWpmBpdsp"
|
|
13474
|
+
),
|
|
13080
13475
|
name: "Price Oracle",
|
|
13081
13476
|
description: "Production Price Oracle (Chipotle main+getPrivateKey)",
|
|
13082
13477
|
version: "1.1.0",
|
|
@@ -13092,7 +13487,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13092
13487
|
},
|
|
13093
13488
|
loanVaultBtcBalance: {
|
|
13094
13489
|
cid: "QmWGEg79snhDQ5Fkm9pLhNmLKUJY5uXfp3t3276Jybritq",
|
|
13095
|
-
authorizedCidHex:
|
|
13490
|
+
authorizedCidHex: cidToHex(
|
|
13491
|
+
"QmWGEg79snhDQ5Fkm9pLhNmLKUJY5uXfp3t3276Jybritq"
|
|
13492
|
+
),
|
|
13096
13493
|
name: "Loan Vault Btc Balance",
|
|
13097
13494
|
description: "Production Loan Vault Btc Balance",
|
|
13098
13495
|
version: "1.0.0",
|
|
@@ -13108,7 +13505,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13108
13505
|
},
|
|
13109
13506
|
adminLiquidationValidator: {
|
|
13110
13507
|
cid: "QmYJJFgFPF4BR4ts9GrAkwfEoQbVSXEwnrciZ5Jj9WTDgd",
|
|
13111
|
-
authorizedCidHex:
|
|
13508
|
+
authorizedCidHex: cidToHex(
|
|
13509
|
+
"QmYJJFgFPF4BR4ts9GrAkwfEoQbVSXEwnrciZ5Jj9WTDgd"
|
|
13510
|
+
),
|
|
13112
13511
|
name: "Admin Liquidation Validator",
|
|
13113
13512
|
description: "Production Admin Liquidation Validator",
|
|
13114
13513
|
version: "1.0.0",
|
|
@@ -13124,7 +13523,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13124
13523
|
},
|
|
13125
13524
|
alwaysSigner: {
|
|
13126
13525
|
cid: "QmXQjybSsdE19Da66to9Hh7X2dLFwpZPhjoqojxbpk7Nvs",
|
|
13127
|
-
authorizedCidHex:
|
|
13526
|
+
authorizedCidHex: cidToHex(
|
|
13527
|
+
"QmXQjybSsdE19Da66to9Hh7X2dLFwpZPhjoqojxbpk7Nvs"
|
|
13528
|
+
),
|
|
13128
13529
|
name: "Always Signer",
|
|
13129
13530
|
description: "Production Always Signer",
|
|
13130
13531
|
version: "1.0.0",
|
|
@@ -13136,336 +13537,80 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13136
13537
|
};
|
|
13137
13538
|
function getDeploymentsForNetwork(network) {
|
|
13138
13539
|
if (network === "chipotle")
|
|
13139
|
-
return
|
|
13540
|
+
return DH_LIT_ACTIONS_CHIPOTLE3;
|
|
13140
13541
|
throw new Error(`Unsupported LIT network: ${network}`);
|
|
13141
13542
|
}
|
|
13142
|
-
|
|
13143
|
-
}
|
|
13144
|
-
});
|
|
13145
|
-
|
|
13146
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/lit-action-helpers.js
|
|
13147
|
-
var require_lit_action_helpers = __commonJS({
|
|
13148
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/lit-action-helpers.js"(exports) {
|
|
13149
|
-
"use strict";
|
|
13150
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13151
|
-
exports.getLitActionCID = getLitActionCID;
|
|
13152
|
-
exports.getLitActionConfig = getLitActionConfig;
|
|
13153
|
-
exports.isLitActionDeployed = isLitActionDeployed;
|
|
13154
|
-
exports.validateDeployedActions = validateDeployedActions;
|
|
13155
|
-
exports.getDeployedActions = getDeployedActions;
|
|
13156
|
-
var lit_actions_registry_1 = require_lit_actions_registry();
|
|
13543
|
+
var CHIPOTLE_DEPLOYMENTS = DH_LIT_ACTIONS_CHIPOTLE3;
|
|
13157
13544
|
function getLitActionCID(litNetwork = "chipotle", actionName) {
|
|
13158
|
-
const deployments =
|
|
13545
|
+
const deployments = getDeploymentsForNetwork(litNetwork);
|
|
13159
13546
|
const action = deployments[actionName];
|
|
13160
13547
|
if (!action || !action.deployed || !action.cid) {
|
|
13161
|
-
throw new Error(
|
|
13548
|
+
throw new Error(
|
|
13549
|
+
`LIT Action '${actionName}' not deployed on network '${litNetwork}'. Check deployment status.`
|
|
13550
|
+
);
|
|
13162
13551
|
}
|
|
13163
13552
|
return action.cid;
|
|
13164
13553
|
}
|
|
13165
13554
|
function getLitActionConfig(actionName, litNetwork = "chipotle") {
|
|
13166
|
-
const deployments =
|
|
13555
|
+
const deployments = getDeploymentsForNetwork(litNetwork);
|
|
13167
13556
|
const action = deployments[actionName];
|
|
13168
13557
|
if (!action) {
|
|
13169
|
-
throw new Error(
|
|
13558
|
+
throw new Error(
|
|
13559
|
+
`LIT Action '${actionName}' not found in registry for network '${litNetwork}'.`
|
|
13560
|
+
);
|
|
13170
13561
|
}
|
|
13171
13562
|
return action;
|
|
13172
13563
|
}
|
|
13173
13564
|
function isLitActionDeployed(actionName, litNetwork = "chipotle") {
|
|
13174
|
-
const deployments =
|
|
13565
|
+
const deployments = getDeploymentsForNetwork(litNetwork);
|
|
13175
13566
|
const action = deployments[actionName];
|
|
13176
13567
|
return !!(action && action.deployed && action.cid);
|
|
13177
13568
|
}
|
|
13178
13569
|
function validateDeployedActions(requiredActions, litNetwork = "chipotle") {
|
|
13179
|
-
return requiredActions.every(
|
|
13570
|
+
return requiredActions.every(
|
|
13571
|
+
(actionName) => isLitActionDeployed(actionName, litNetwork)
|
|
13572
|
+
);
|
|
13180
13573
|
}
|
|
13181
13574
|
function getDeployedActions(litNetwork = "chipotle") {
|
|
13182
|
-
const deployments =
|
|
13183
|
-
return Object.values(deployments).filter(
|
|
13575
|
+
const deployments = getDeploymentsForNetwork(litNetwork);
|
|
13576
|
+
return Object.values(deployments).filter(
|
|
13577
|
+
(action) => action && action.deployed
|
|
13578
|
+
);
|
|
13184
13579
|
}
|
|
13185
|
-
}
|
|
13186
|
-
});
|
|
13187
|
-
|
|
13188
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/pkp-setup.js
|
|
13189
|
-
var require_pkp_setup = __commonJS({
|
|
13190
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/pkp-setup.js"(exports) {
|
|
13191
|
-
"use strict";
|
|
13192
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13193
|
-
exports.getPKPValidatorSetup = getPKPValidatorSetup;
|
|
13194
|
-
var lit_actions_registry_1 = require_lit_actions_registry();
|
|
13195
13580
|
function getPKPValidatorSetup(litNetwork = "chipotle") {
|
|
13196
|
-
const deployments =
|
|
13581
|
+
const deployments = getDeploymentsForNetwork(litNetwork);
|
|
13197
13582
|
const litAction = deployments.pkpValidator;
|
|
13198
13583
|
if (!litAction || !litAction.pkp) {
|
|
13199
|
-
throw new Error(
|
|
13584
|
+
throw new Error(
|
|
13585
|
+
`PKP validator setup is not available for litNetwork='${litNetwork}'. Ensure the pkpValidator action (with pkp attached) is defined in the registry.`
|
|
13586
|
+
);
|
|
13200
13587
|
}
|
|
13201
13588
|
return {
|
|
13202
13589
|
litAction,
|
|
13203
13590
|
pkp: litAction.pkp
|
|
13204
13591
|
};
|
|
13205
13592
|
}
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
|
|
13210
|
-
|
|
13211
|
-
|
|
13212
|
-
|
|
13213
|
-
|
|
13214
|
-
|
|
13215
|
-
|
|
13216
|
-
|
|
13217
|
-
|
|
13218
|
-
|
|
13219
|
-
|
|
13220
|
-
exports.debugTrace = debugTrace;
|
|
13221
|
-
exports.logRequest = logRequest;
|
|
13222
|
-
exports.logResponse = logResponse;
|
|
13223
|
-
exports.logError = logError;
|
|
13224
|
-
exports.logConnectionAttempt = logConnectionAttempt;
|
|
13225
|
-
exports.logConnectionSuccess = logConnectionSuccess;
|
|
13226
|
-
exports.logConnectionFailure = logConnectionFailure;
|
|
13227
|
-
exports.logPkpOperation = logPkpOperation;
|
|
13228
|
-
exports.logSessionSignatures = logSessionSignatures;
|
|
13229
|
-
exports.logLitActionExecution = logLitActionExecution;
|
|
13230
|
-
exports.logLitActionResult = logLitActionResult;
|
|
13231
|
-
exports.logTestStart = logTestStart;
|
|
13232
|
-
exports.logTestEnd = logTestEnd;
|
|
13233
|
-
var LogLevel2;
|
|
13234
|
-
(function(LogLevel3) {
|
|
13235
|
-
LogLevel3[LogLevel3["ERROR"] = 0] = "ERROR";
|
|
13236
|
-
LogLevel3[LogLevel3["WARN"] = 1] = "WARN";
|
|
13237
|
-
LogLevel3[LogLevel3["INFO"] = 2] = "INFO";
|
|
13238
|
-
LogLevel3[LogLevel3["DEBUG"] = 3] = "DEBUG";
|
|
13239
|
-
LogLevel3[LogLevel3["TRACE"] = 4] = "TRACE";
|
|
13240
|
-
})(LogLevel2 || (exports.LogLevel = LogLevel2 = {}));
|
|
13241
|
-
exports.DEFAULT_DEBUG_CONFIG = {
|
|
13242
|
-
level: LogLevel2.INFO,
|
|
13243
|
-
enableTimestamps: true,
|
|
13244
|
-
enablePerformanceMetrics: true,
|
|
13245
|
-
enableRequestLogging: true,
|
|
13246
|
-
enableNetworkMetrics: true
|
|
13247
|
-
};
|
|
13248
|
-
var debugConfig = { ...exports.DEFAULT_DEBUG_CONFIG };
|
|
13249
|
-
function configureDebugLogging(config) {
|
|
13250
|
-
debugConfig = { ...debugConfig, ...config };
|
|
13251
|
-
}
|
|
13252
|
-
function getTimestamp() {
|
|
13253
|
-
return (/* @__PURE__ */ new Date()).toISOString();
|
|
13254
|
-
}
|
|
13255
|
-
function formatMessage(level, component, message, metadata) {
|
|
13256
|
-
const timestamp = debugConfig.enableTimestamps ? `[${getTimestamp()}] ` : "";
|
|
13257
|
-
const metadataStr = metadata ? ` ${JSON.stringify(metadata)}` : "";
|
|
13258
|
-
return `${timestamp}[${level}] [${component}] ${message}${metadataStr}`;
|
|
13259
|
-
}
|
|
13260
|
-
var PerformanceTracker = class {
|
|
13261
|
-
constructor(operationName) {
|
|
13262
|
-
this.operationName = operationName;
|
|
13263
|
-
this.markers = /* @__PURE__ */ new Map();
|
|
13264
|
-
this.startTime = Date.now();
|
|
13265
|
-
this.log("PERF", `Started: ${operationName}`);
|
|
13266
|
-
}
|
|
13267
|
-
mark(label) {
|
|
13268
|
-
const elapsed = Date.now() - this.startTime;
|
|
13269
|
-
this.markers.set(label, elapsed);
|
|
13270
|
-
this.log("PERF", `${this.operationName} - ${label}: ${elapsed}ms`);
|
|
13271
|
-
}
|
|
13272
|
-
end(success2 = true) {
|
|
13273
|
-
const totalTime = Date.now() - this.startTime;
|
|
13274
|
-
const status = success2 ? "SUCCESS" : "FAILED";
|
|
13275
|
-
this.log("PERF", `${this.operationName} - ${status}: ${totalTime}ms`);
|
|
13276
|
-
if (debugConfig.enablePerformanceMetrics && this.markers.size > 0) {
|
|
13277
|
-
console.log(`\u{1F4CA} Performance Breakdown for ${this.operationName}:`);
|
|
13278
|
-
for (const [label, time] of this.markers) {
|
|
13279
|
-
console.log(` ${label}: ${time}ms`);
|
|
13280
|
-
}
|
|
13281
|
-
console.log(` Total: ${totalTime}ms`);
|
|
13282
|
-
}
|
|
13283
|
-
return totalTime;
|
|
13284
|
-
}
|
|
13285
|
-
log(level, message) {
|
|
13286
|
-
if (debugConfig.enablePerformanceMetrics) {
|
|
13287
|
-
console.log(formatMessage(level, "PERFORMANCE", message));
|
|
13288
|
-
}
|
|
13289
|
-
}
|
|
13290
|
-
};
|
|
13291
|
-
exports.PerformanceTracker = PerformanceTracker;
|
|
13292
|
-
var NetworkMetricsCollector = class {
|
|
13293
|
-
constructor() {
|
|
13294
|
-
this.metrics = /* @__PURE__ */ new Map();
|
|
13295
|
-
}
|
|
13296
|
-
getMetrics(operation) {
|
|
13297
|
-
if (!this.metrics.has(operation)) {
|
|
13298
|
-
this.metrics.set(operation, {
|
|
13299
|
-
requestCount: 0,
|
|
13300
|
-
successCount: 0,
|
|
13301
|
-
failureCount: 0,
|
|
13302
|
-
averageLatency: 0,
|
|
13303
|
-
startTime: Date.now()
|
|
13304
|
-
});
|
|
13305
|
-
}
|
|
13306
|
-
return this.metrics.get(operation);
|
|
13307
|
-
}
|
|
13308
|
-
recordRequest(operation, success2, latency, error) {
|
|
13309
|
-
const metrics = this.getMetrics(operation);
|
|
13310
|
-
metrics.requestCount++;
|
|
13311
|
-
if (success2) {
|
|
13312
|
-
metrics.successCount++;
|
|
13313
|
-
metrics.averageLatency = (metrics.averageLatency * (metrics.successCount - 1) + latency) / metrics.successCount;
|
|
13314
|
-
} else {
|
|
13315
|
-
metrics.failureCount++;
|
|
13316
|
-
if (error)
|
|
13317
|
-
metrics.lastError = error;
|
|
13318
|
-
}
|
|
13319
|
-
if (debugConfig.enableNetworkMetrics) {
|
|
13320
|
-
const successRate = (metrics.successCount / metrics.requestCount * 100).toFixed(1);
|
|
13321
|
-
debugLog("NETWORK", `${operation} - Success: ${success2}, Latency: ${latency}ms, Success Rate: ${successRate}%`);
|
|
13322
|
-
}
|
|
13323
|
-
}
|
|
13324
|
-
printSummary() {
|
|
13325
|
-
if (!debugConfig.enableNetworkMetrics)
|
|
13326
|
-
return;
|
|
13327
|
-
console.log("\n\u{1F4C8} Network Metrics Summary:");
|
|
13328
|
-
for (const [operation, metrics] of this.metrics) {
|
|
13329
|
-
const successRate = (metrics.successCount / metrics.requestCount * 100).toFixed(1);
|
|
13330
|
-
const runtime = Date.now() - metrics.startTime;
|
|
13331
|
-
console.log(` ${operation}:`);
|
|
13332
|
-
console.log(` Requests: ${metrics.requestCount}`);
|
|
13333
|
-
console.log(` Success Rate: ${successRate}%`);
|
|
13334
|
-
console.log(` Avg Latency: ${metrics.averageLatency.toFixed(0)}ms`);
|
|
13335
|
-
console.log(` Runtime: ${runtime}ms`);
|
|
13336
|
-
if (metrics.lastError) {
|
|
13337
|
-
console.log(` Last Error: ${metrics.lastError}`);
|
|
13338
|
-
}
|
|
13339
|
-
}
|
|
13340
|
-
}
|
|
13341
|
-
};
|
|
13342
|
-
exports.networkMetrics = new NetworkMetricsCollector();
|
|
13343
|
-
function debugError(component, message, metadata) {
|
|
13344
|
-
if (debugConfig.level >= LogLevel2.ERROR) {
|
|
13345
|
-
console.error(formatMessage("ERROR", component, message, metadata));
|
|
13346
|
-
}
|
|
13347
|
-
}
|
|
13348
|
-
function debugWarn(component, message, metadata) {
|
|
13349
|
-
if (debugConfig.level >= LogLevel2.WARN) {
|
|
13350
|
-
console.warn(formatMessage("WARN", component, message, metadata));
|
|
13351
|
-
}
|
|
13352
|
-
}
|
|
13353
|
-
function debugInfo(component, message, metadata) {
|
|
13354
|
-
if (debugConfig.level >= LogLevel2.INFO) {
|
|
13355
|
-
console.log(formatMessage("INFO", component, message, metadata));
|
|
13356
|
-
}
|
|
13357
|
-
}
|
|
13358
|
-
function debugLog(component, message, metadata) {
|
|
13359
|
-
if (debugConfig.level >= LogLevel2.DEBUG) {
|
|
13360
|
-
console.log(formatMessage("DEBUG", component, message, metadata));
|
|
13361
|
-
}
|
|
13362
|
-
}
|
|
13363
|
-
function debugTrace(component, message, metadata) {
|
|
13364
|
-
if (debugConfig.level >= LogLevel2.TRACE) {
|
|
13365
|
-
console.log(formatMessage("TRACE", component, message, metadata));
|
|
13366
|
-
}
|
|
13367
|
-
}
|
|
13368
|
-
function logRequest(component, operation, params) {
|
|
13369
|
-
if (!debugConfig.enableRequestLogging)
|
|
13370
|
-
return;
|
|
13371
|
-
debugLog(component, `\u{1F504} Request: ${operation}`, {
|
|
13372
|
-
operation,
|
|
13373
|
-
params: JSON.stringify(params, null, 2)
|
|
13374
|
-
});
|
|
13375
|
-
}
|
|
13376
|
-
function logResponse(component, operation, response, duration) {
|
|
13377
|
-
if (!debugConfig.enableRequestLogging)
|
|
13378
|
-
return;
|
|
13379
|
-
debugLog(component, `\u2705 Response: ${operation} (${duration}ms)`, {
|
|
13380
|
-
operation,
|
|
13381
|
-
duration,
|
|
13382
|
-
response: typeof response === "object" ? JSON.stringify(response, null, 2) : response
|
|
13383
|
-
});
|
|
13384
|
-
}
|
|
13385
|
-
function logError(component, operation, error, duration) {
|
|
13386
|
-
const durationStr = duration ? ` (${duration}ms)` : "";
|
|
13387
|
-
debugError(component, `\u274C Error: ${operation}${durationStr}`, {
|
|
13388
|
-
operation,
|
|
13389
|
-
duration,
|
|
13390
|
-
error: error?.message || error?.toString() || "Unknown error",
|
|
13391
|
-
stack: error?.stack
|
|
13392
|
-
});
|
|
13393
|
-
}
|
|
13394
|
-
function logConnectionAttempt(network, attempt, maxAttempts) {
|
|
13395
|
-
debugInfo("CONNECTION", `\u{1F517} Connecting to ${network} (attempt ${attempt}/${maxAttempts})`);
|
|
13396
|
-
}
|
|
13397
|
-
function logConnectionSuccess(network, latency) {
|
|
13398
|
-
debugInfo("CONNECTION", `\u2705 Connected to ${network} (${latency}ms)`);
|
|
13399
|
-
exports.networkMetrics.recordRequest(`connection-${network}`, true, latency);
|
|
13400
|
-
}
|
|
13401
|
-
function logConnectionFailure(network, error, attempt) {
|
|
13402
|
-
debugError("CONNECTION", `\u274C Connection failed to ${network} (attempt ${attempt})`, { error });
|
|
13403
|
-
exports.networkMetrics.recordRequest(`connection-${network}`, false, 0, error);
|
|
13404
|
-
}
|
|
13405
|
-
function logPkpOperation(operation, pkpId, details) {
|
|
13406
|
-
const pkpStr = pkpId ? ` (PKP: ${pkpId.slice(0, 8)}...)` : "";
|
|
13407
|
-
debugInfo("PKP", `\u{1F511} ${operation}${pkpStr}`, details);
|
|
13408
|
-
}
|
|
13409
|
-
function logSessionSignatures(count, expiration) {
|
|
13410
|
-
debugInfo("SESSION", `\u{1F510} Generated ${count} session signatures (expires: ${expiration})`);
|
|
13411
|
-
}
|
|
13412
|
-
function logLitActionExecution(cid, params) {
|
|
13413
|
-
debugInfo("LIT_ACTION", `\u26A1 Executing LIT Action: ${cid}`, {
|
|
13414
|
-
cid,
|
|
13415
|
-
params
|
|
13416
|
-
});
|
|
13417
|
-
}
|
|
13418
|
-
function logLitActionResult(cid, success2, duration, result) {
|
|
13419
|
-
const status = success2 ? "\u2705" : "\u274C";
|
|
13420
|
-
debugInfo("LIT_ACTION", `${status} LIT Action completed: ${cid} (${duration}ms)`, {
|
|
13421
|
-
cid,
|
|
13422
|
-
success: success2,
|
|
13423
|
-
duration,
|
|
13424
|
-
result: success2 && result ? JSON.stringify(result, null, 2) : void 0
|
|
13425
|
-
});
|
|
13426
|
-
}
|
|
13427
|
-
function logTestStart(testName) {
|
|
13428
|
-
debugInfo("TEST", `\u{1F9EA} Starting test: ${testName}`);
|
|
13429
|
-
return new PerformanceTracker(testName);
|
|
13430
|
-
}
|
|
13431
|
-
function logTestEnd(testName, success2, duration) {
|
|
13432
|
-
const status = success2 ? "\u2705" : "\u274C";
|
|
13433
|
-
debugInfo("TEST", `${status} Test completed: ${testName} (${duration}ms)`);
|
|
13434
|
-
exports.networkMetrics.printSummary();
|
|
13435
|
-
}
|
|
13436
|
-
}
|
|
13437
|
-
});
|
|
13438
|
-
|
|
13439
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/error-classification.js
|
|
13440
|
-
var require_error_classification = __commonJS({
|
|
13441
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/error-classification.js"(exports) {
|
|
13442
|
-
"use strict";
|
|
13443
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13444
|
-
exports.litProtocolErrors = exports.RetryStrategy = exports.ErrorCategory = void 0;
|
|
13445
|
-
exports.classifyError = classifyError;
|
|
13446
|
-
exports.getRetryConfigFromClassification = getRetryConfigFromClassification;
|
|
13447
|
-
exports.analyzeError = analyzeError;
|
|
13448
|
-
exports.createErrorReport = createErrorReport;
|
|
13449
|
-
var ErrorCategory2;
|
|
13450
|
-
(function(ErrorCategory3) {
|
|
13451
|
-
ErrorCategory3["NETWORK"] = "network";
|
|
13452
|
-
ErrorCategory3["PROTOCOL"] = "protocol";
|
|
13453
|
-
ErrorCategory3["AUTHENTICATION"] = "authentication";
|
|
13454
|
-
ErrorCategory3["RESOURCE"] = "resource";
|
|
13455
|
-
ErrorCategory3["VALIDATION"] = "validation";
|
|
13456
|
-
ErrorCategory3["TIMEOUT"] = "timeout";
|
|
13457
|
-
ErrorCategory3["RATE_LIMIT"] = "rate_limit";
|
|
13458
|
-
ErrorCategory3["CONFIGURATION"] = "configuration";
|
|
13459
|
-
ErrorCategory3["UNKNOWN"] = "unknown";
|
|
13460
|
-
})(ErrorCategory2 || (exports.ErrorCategory = ErrorCategory2 = {}));
|
|
13461
|
-
var RetryStrategy;
|
|
13462
|
-
(function(RetryStrategy2) {
|
|
13593
|
+
init_debug_logger();
|
|
13594
|
+
var ErrorCategory2 = /* @__PURE__ */ ((ErrorCategory22) => {
|
|
13595
|
+
ErrorCategory22["NETWORK"] = "network";
|
|
13596
|
+
ErrorCategory22["PROTOCOL"] = "protocol";
|
|
13597
|
+
ErrorCategory22["AUTHENTICATION"] = "authentication";
|
|
13598
|
+
ErrorCategory22["RESOURCE"] = "resource";
|
|
13599
|
+
ErrorCategory22["VALIDATION"] = "validation";
|
|
13600
|
+
ErrorCategory22["TIMEOUT"] = "timeout";
|
|
13601
|
+
ErrorCategory22["RATE_LIMIT"] = "rate_limit";
|
|
13602
|
+
ErrorCategory22["CONFIGURATION"] = "configuration";
|
|
13603
|
+
ErrorCategory22["UNKNOWN"] = "unknown";
|
|
13604
|
+
return ErrorCategory22;
|
|
13605
|
+
})(ErrorCategory2 || {});
|
|
13606
|
+
var RetryStrategy = /* @__PURE__ */ ((RetryStrategy2) => {
|
|
13463
13607
|
RetryStrategy2["AGGRESSIVE"] = "aggressive";
|
|
13464
13608
|
RetryStrategy2["CONSERVATIVE"] = "conservative";
|
|
13465
13609
|
RetryStrategy2["EXPONENTIAL"] = "exponential";
|
|
13466
13610
|
RetryStrategy2["LINEAR"] = "linear";
|
|
13467
13611
|
RetryStrategy2["NONE"] = "none";
|
|
13468
|
-
|
|
13612
|
+
return RetryStrategy2;
|
|
13613
|
+
})(RetryStrategy || {});
|
|
13469
13614
|
var LIT_ERROR_PATTERNS = {
|
|
13470
13615
|
// Network and connection errors
|
|
13471
13616
|
network: [
|
|
@@ -13558,31 +13703,46 @@ var require_error_classification = __commonJS({
|
|
|
13558
13703
|
]
|
|
13559
13704
|
};
|
|
13560
13705
|
var RETRY_STRATEGIES = {
|
|
13561
|
-
[
|
|
13706
|
+
[
|
|
13707
|
+
"aggressive"
|
|
13708
|
+
/* AGGRESSIVE */
|
|
13709
|
+
]: {
|
|
13562
13710
|
maxAttempts: 5,
|
|
13563
13711
|
baseDelayMs: 500,
|
|
13564
13712
|
maxDelayMs: 5e3,
|
|
13565
13713
|
multiplier: 1.5
|
|
13566
13714
|
},
|
|
13567
|
-
[
|
|
13715
|
+
[
|
|
13716
|
+
"conservative"
|
|
13717
|
+
/* CONSERVATIVE */
|
|
13718
|
+
]: {
|
|
13568
13719
|
maxAttempts: 3,
|
|
13569
13720
|
baseDelayMs: 3e3,
|
|
13570
13721
|
maxDelayMs: 3e4,
|
|
13571
13722
|
multiplier: 2.5
|
|
13572
13723
|
},
|
|
13573
|
-
[
|
|
13724
|
+
[
|
|
13725
|
+
"exponential"
|
|
13726
|
+
/* EXPONENTIAL */
|
|
13727
|
+
]: {
|
|
13574
13728
|
maxAttempts: 4,
|
|
13575
13729
|
baseDelayMs: 1e3,
|
|
13576
13730
|
maxDelayMs: 15e3,
|
|
13577
13731
|
multiplier: 2
|
|
13578
13732
|
},
|
|
13579
|
-
[
|
|
13733
|
+
[
|
|
13734
|
+
"linear"
|
|
13735
|
+
/* LINEAR */
|
|
13736
|
+
]: {
|
|
13580
13737
|
maxAttempts: 3,
|
|
13581
13738
|
baseDelayMs: 2e3,
|
|
13582
13739
|
maxDelayMs: 1e4,
|
|
13583
13740
|
multiplier: 1
|
|
13584
13741
|
},
|
|
13585
|
-
[
|
|
13742
|
+
[
|
|
13743
|
+
"none"
|
|
13744
|
+
/* NONE */
|
|
13745
|
+
]: {
|
|
13586
13746
|
maxAttempts: 1,
|
|
13587
13747
|
baseDelayMs: 0,
|
|
13588
13748
|
maxDelayMs: 0,
|
|
@@ -13590,11 +13750,17 @@ var require_error_classification = __commonJS({
|
|
|
13590
13750
|
}
|
|
13591
13751
|
};
|
|
13592
13752
|
var CLASSIFICATION_RULES = {
|
|
13593
|
-
[
|
|
13594
|
-
|
|
13595
|
-
|
|
13753
|
+
[
|
|
13754
|
+
"network"
|
|
13755
|
+
/* NETWORK */
|
|
13756
|
+
]: {
|
|
13757
|
+
category: "network",
|
|
13758
|
+
retryStrategy: "aggressive",
|
|
13596
13759
|
isRetryable: true,
|
|
13597
|
-
...RETRY_STRATEGIES[
|
|
13760
|
+
...RETRY_STRATEGIES[
|
|
13761
|
+
"aggressive"
|
|
13762
|
+
/* AGGRESSIVE */
|
|
13763
|
+
],
|
|
13598
13764
|
description: "Network connectivity or communication error",
|
|
13599
13765
|
troubleshooting: [
|
|
13600
13766
|
"Check internet connection",
|
|
@@ -13603,11 +13769,17 @@ var require_error_classification = __commonJS({
|
|
|
13603
13769
|
"Try connecting to different node endpoints"
|
|
13604
13770
|
]
|
|
13605
13771
|
},
|
|
13606
|
-
[
|
|
13607
|
-
|
|
13608
|
-
|
|
13772
|
+
[
|
|
13773
|
+
"protocol"
|
|
13774
|
+
/* PROTOCOL */
|
|
13775
|
+
]: {
|
|
13776
|
+
category: "protocol",
|
|
13777
|
+
retryStrategy: "conservative",
|
|
13609
13778
|
isRetryable: true,
|
|
13610
|
-
...RETRY_STRATEGIES[
|
|
13779
|
+
...RETRY_STRATEGIES[
|
|
13780
|
+
"conservative"
|
|
13781
|
+
/* CONSERVATIVE */
|
|
13782
|
+
],
|
|
13611
13783
|
description: "LIT Protocol specific operational error",
|
|
13612
13784
|
troubleshooting: [
|
|
13613
13785
|
"Check LIT Protocol network status",
|
|
@@ -13616,11 +13788,17 @@ var require_error_classification = __commonJS({
|
|
|
13616
13788
|
"Wait for network consensus"
|
|
13617
13789
|
]
|
|
13618
13790
|
},
|
|
13619
|
-
[
|
|
13620
|
-
|
|
13621
|
-
|
|
13791
|
+
[
|
|
13792
|
+
"authentication"
|
|
13793
|
+
/* AUTHENTICATION */
|
|
13794
|
+
]: {
|
|
13795
|
+
category: "authentication",
|
|
13796
|
+
retryStrategy: "exponential",
|
|
13622
13797
|
isRetryable: true,
|
|
13623
|
-
...RETRY_STRATEGIES[
|
|
13798
|
+
...RETRY_STRATEGIES[
|
|
13799
|
+
"exponential"
|
|
13800
|
+
/* EXPONENTIAL */
|
|
13801
|
+
],
|
|
13624
13802
|
maxAttempts: 2,
|
|
13625
13803
|
// Override: limited retries for auth issues
|
|
13626
13804
|
description: "Authentication or authorization error",
|
|
@@ -13631,11 +13809,17 @@ var require_error_classification = __commonJS({
|
|
|
13631
13809
|
"Check PKP authorization status"
|
|
13632
13810
|
]
|
|
13633
13811
|
},
|
|
13634
|
-
[
|
|
13635
|
-
|
|
13636
|
-
|
|
13812
|
+
[
|
|
13813
|
+
"resource"
|
|
13814
|
+
/* RESOURCE */
|
|
13815
|
+
]: {
|
|
13816
|
+
category: "resource",
|
|
13817
|
+
retryStrategy: "linear",
|
|
13637
13818
|
isRetryable: true,
|
|
13638
|
-
...RETRY_STRATEGIES[
|
|
13819
|
+
...RETRY_STRATEGIES[
|
|
13820
|
+
"linear"
|
|
13821
|
+
/* LINEAR */
|
|
13822
|
+
],
|
|
13639
13823
|
maxAttempts: 2,
|
|
13640
13824
|
// Override: limited retries for resource issues
|
|
13641
13825
|
description: "Resource not found or validation error",
|
|
@@ -13646,11 +13830,17 @@ var require_error_classification = __commonJS({
|
|
|
13646
13830
|
"Wait for resource propagation"
|
|
13647
13831
|
]
|
|
13648
13832
|
},
|
|
13649
|
-
[
|
|
13650
|
-
|
|
13651
|
-
|
|
13833
|
+
[
|
|
13834
|
+
"validation"
|
|
13835
|
+
/* VALIDATION */
|
|
13836
|
+
]: {
|
|
13837
|
+
category: "validation",
|
|
13838
|
+
retryStrategy: "none",
|
|
13652
13839
|
isRetryable: false,
|
|
13653
|
-
...RETRY_STRATEGIES[
|
|
13840
|
+
...RETRY_STRATEGIES[
|
|
13841
|
+
"none"
|
|
13842
|
+
/* NONE */
|
|
13843
|
+
],
|
|
13654
13844
|
description: "Input validation or schema error",
|
|
13655
13845
|
troubleshooting: [
|
|
13656
13846
|
"Check input parameters format",
|
|
@@ -13659,11 +13849,17 @@ var require_error_classification = __commonJS({
|
|
|
13659
13849
|
"Review API documentation"
|
|
13660
13850
|
]
|
|
13661
13851
|
},
|
|
13662
|
-
[
|
|
13663
|
-
|
|
13664
|
-
|
|
13852
|
+
[
|
|
13853
|
+
"timeout"
|
|
13854
|
+
/* TIMEOUT */
|
|
13855
|
+
]: {
|
|
13856
|
+
category: "timeout",
|
|
13857
|
+
retryStrategy: "conservative",
|
|
13665
13858
|
isRetryable: true,
|
|
13666
|
-
...RETRY_STRATEGIES[
|
|
13859
|
+
...RETRY_STRATEGIES[
|
|
13860
|
+
"conservative"
|
|
13861
|
+
/* CONSERVATIVE */
|
|
13862
|
+
],
|
|
13667
13863
|
description: "Operation timeout error",
|
|
13668
13864
|
troubleshooting: [
|
|
13669
13865
|
"Increase timeout values",
|
|
@@ -13672,11 +13868,17 @@ var require_error_classification = __commonJS({
|
|
|
13672
13868
|
"Split operations into smaller chunks"
|
|
13673
13869
|
]
|
|
13674
13870
|
},
|
|
13675
|
-
[
|
|
13676
|
-
|
|
13677
|
-
|
|
13871
|
+
[
|
|
13872
|
+
"rate_limit"
|
|
13873
|
+
/* RATE_LIMIT */
|
|
13874
|
+
]: {
|
|
13875
|
+
category: "rate_limit",
|
|
13876
|
+
retryStrategy: "conservative",
|
|
13678
13877
|
isRetryable: true,
|
|
13679
|
-
...RETRY_STRATEGIES[
|
|
13878
|
+
...RETRY_STRATEGIES[
|
|
13879
|
+
"conservative"
|
|
13880
|
+
/* CONSERVATIVE */
|
|
13881
|
+
],
|
|
13680
13882
|
maxAttempts: 2,
|
|
13681
13883
|
// Override: limited retries to avoid further rate limiting
|
|
13682
13884
|
baseDelayMs: 5e3,
|
|
@@ -13689,11 +13891,17 @@ var require_error_classification = __commonJS({
|
|
|
13689
13891
|
"Wait for quota reset"
|
|
13690
13892
|
]
|
|
13691
13893
|
},
|
|
13692
|
-
[
|
|
13693
|
-
|
|
13694
|
-
|
|
13894
|
+
[
|
|
13895
|
+
"configuration"
|
|
13896
|
+
/* CONFIGURATION */
|
|
13897
|
+
]: {
|
|
13898
|
+
category: "configuration",
|
|
13899
|
+
retryStrategy: "none",
|
|
13695
13900
|
isRetryable: false,
|
|
13696
|
-
...RETRY_STRATEGIES[
|
|
13901
|
+
...RETRY_STRATEGIES[
|
|
13902
|
+
"none"
|
|
13903
|
+
/* NONE */
|
|
13904
|
+
],
|
|
13697
13905
|
description: "Configuration or setup error",
|
|
13698
13906
|
troubleshooting: [
|
|
13699
13907
|
"Check environment variables",
|
|
@@ -13702,11 +13910,17 @@ var require_error_classification = __commonJS({
|
|
|
13702
13910
|
"Check required dependencies"
|
|
13703
13911
|
]
|
|
13704
13912
|
},
|
|
13705
|
-
[
|
|
13706
|
-
|
|
13707
|
-
|
|
13913
|
+
[
|
|
13914
|
+
"unknown"
|
|
13915
|
+
/* UNKNOWN */
|
|
13916
|
+
]: {
|
|
13917
|
+
category: "unknown",
|
|
13918
|
+
retryStrategy: "exponential",
|
|
13708
13919
|
isRetryable: true,
|
|
13709
|
-
...RETRY_STRATEGIES[
|
|
13920
|
+
...RETRY_STRATEGIES[
|
|
13921
|
+
"exponential"
|
|
13922
|
+
/* EXPONENTIAL */
|
|
13923
|
+
],
|
|
13710
13924
|
maxAttempts: 2,
|
|
13711
13925
|
// Override: conservative retries for unknown errors
|
|
13712
13926
|
description: "Unknown or unclassified error",
|
|
@@ -13732,7 +13946,10 @@ var require_error_classification = __commonJS({
|
|
|
13732
13946
|
}
|
|
13733
13947
|
}
|
|
13734
13948
|
}
|
|
13735
|
-
const unknownClassification = CLASSIFICATION_RULES[
|
|
13949
|
+
const unknownClassification = CLASSIFICATION_RULES[
|
|
13950
|
+
"unknown"
|
|
13951
|
+
/* UNKNOWN */
|
|
13952
|
+
];
|
|
13736
13953
|
return {
|
|
13737
13954
|
...unknownClassification,
|
|
13738
13955
|
description: `${unknownClassification.description}: ${errorMessage.slice(0, 100)}`
|
|
@@ -13783,258 +14000,17 @@ var require_error_classification = __commonJS({
|
|
|
13783
14000
|
}
|
|
13784
14001
|
return report.join("\n");
|
|
13785
14002
|
}
|
|
13786
|
-
|
|
13787
|
-
isNetworkError: (error) => classifyError(error).category ===
|
|
13788
|
-
isProtocolError: (error) => classifyError(error).category ===
|
|
13789
|
-
isAuthenticationError: (error) => classifyError(error).category ===
|
|
13790
|
-
isResourceError: (error) => classifyError(error).category ===
|
|
13791
|
-
isTimeoutError: (error) => classifyError(error).category ===
|
|
13792
|
-
isRateLimitError: (error) => classifyError(error).category ===
|
|
13793
|
-
isConfigurationError: (error) => classifyError(error).category ===
|
|
14003
|
+
var litProtocolErrors = {
|
|
14004
|
+
isNetworkError: (error) => classifyError(error).category === "network",
|
|
14005
|
+
isProtocolError: (error) => classifyError(error).category === "protocol",
|
|
14006
|
+
isAuthenticationError: (error) => classifyError(error).category === "authentication",
|
|
14007
|
+
isResourceError: (error) => classifyError(error).category === "resource",
|
|
14008
|
+
isTimeoutError: (error) => classifyError(error).category === "timeout",
|
|
14009
|
+
isRateLimitError: (error) => classifyError(error).category === "rate_limit",
|
|
14010
|
+
isConfigurationError: (error) => classifyError(error).category === "configuration",
|
|
13794
14011
|
isRetryable: (error) => classifyError(error).isRetryable
|
|
13795
14012
|
};
|
|
13796
|
-
|
|
13797
|
-
});
|
|
13798
|
-
|
|
13799
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/session-signature-cache.js
|
|
13800
|
-
var require_session_signature_cache = __commonJS({
|
|
13801
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/session-signature-cache.js"(exports) {
|
|
13802
|
-
"use strict";
|
|
13803
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13804
|
-
exports.sessionSignatureCache = exports.DEFAULT_CACHE_CONFIG = void 0;
|
|
13805
|
-
exports.generateSessionSignaturesWithCache = generateSessionSignaturesWithCache;
|
|
13806
|
-
exports.configureSessionSignatureCache = configureSessionSignatureCache;
|
|
13807
|
-
exports.clearSessionSignatureCache = clearSessionSignatureCache;
|
|
13808
|
-
exports.getSessionSignatureCacheStats = getSessionSignatureCacheStats;
|
|
13809
|
-
var debug_logger_1 = require_debug_logger();
|
|
13810
|
-
exports.DEFAULT_CACHE_CONFIG = {
|
|
13811
|
-
maxEntries: 50,
|
|
13812
|
-
bufferTimeMs: 6e4,
|
|
13813
|
-
// 1 minute buffer before expiration
|
|
13814
|
-
enableLogging: true
|
|
13815
|
-
};
|
|
13816
|
-
var SessionSignatureCache = class {
|
|
13817
|
-
constructor(config = {}) {
|
|
13818
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
13819
|
-
this.config = { ...exports.DEFAULT_CACHE_CONFIG, ...config };
|
|
13820
|
-
}
|
|
13821
|
-
/**
|
|
13822
|
-
* Generate cache key from PKP and context
|
|
13823
|
-
*/
|
|
13824
|
-
generateCacheKey(pkpTokenId, litActionCid, signerAddress, network) {
|
|
13825
|
-
return `${signerAddress}-${network}-${pkpTokenId}-${litActionCid}`;
|
|
13826
|
-
}
|
|
13827
|
-
/**
|
|
13828
|
-
* Check if cache entry is still valid
|
|
13829
|
-
*/
|
|
13830
|
-
isEntryValid(entry) {
|
|
13831
|
-
const now2 = /* @__PURE__ */ new Date();
|
|
13832
|
-
const expirationWithBuffer = new Date(entry.expiration.getTime() - this.config.bufferTimeMs);
|
|
13833
|
-
return now2 < expirationWithBuffer;
|
|
13834
|
-
}
|
|
13835
|
-
/**
|
|
13836
|
-
* Clean expired entries from cache
|
|
13837
|
-
*/
|
|
13838
|
-
cleanExpiredEntries() {
|
|
13839
|
-
const now2 = /* @__PURE__ */ new Date();
|
|
13840
|
-
let cleanedCount = 0;
|
|
13841
|
-
for (const [key2, entry] of this.cache.entries()) {
|
|
13842
|
-
if (now2 >= entry.expiration) {
|
|
13843
|
-
this.cache.delete(key2);
|
|
13844
|
-
cleanedCount++;
|
|
13845
|
-
}
|
|
13846
|
-
}
|
|
13847
|
-
if (cleanedCount > 0 && this.config.enableLogging) {
|
|
13848
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u{1F9F9} Cleaned ${cleanedCount} expired session signature entries`);
|
|
13849
|
-
}
|
|
13850
|
-
}
|
|
13851
|
-
/**
|
|
13852
|
-
* Enforce cache size limits
|
|
13853
|
-
*/
|
|
13854
|
-
enforceCacheSize() {
|
|
13855
|
-
if (this.cache.size <= this.config.maxEntries) {
|
|
13856
|
-
return;
|
|
13857
|
-
}
|
|
13858
|
-
const entries = Array.from(this.cache.entries()).sort(([, a], [, b]) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
13859
|
-
const toRemove = entries.slice(0, this.cache.size - this.config.maxEntries);
|
|
13860
|
-
for (const [key2] of toRemove) {
|
|
13861
|
-
this.cache.delete(key2);
|
|
13862
|
-
}
|
|
13863
|
-
if (this.config.enableLogging) {
|
|
13864
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u{1F4E6} Removed ${toRemove.length} oldest cache entries to maintain size limit`);
|
|
13865
|
-
}
|
|
13866
|
-
}
|
|
13867
|
-
/**
|
|
13868
|
-
* Get cached session signatures if valid
|
|
13869
|
-
*/
|
|
13870
|
-
get(pkpTokenId, litActionCid, signerAddress, network) {
|
|
13871
|
-
this.cleanExpiredEntries();
|
|
13872
|
-
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13873
|
-
const entry = this.cache.get(cacheKey);
|
|
13874
|
-
if (!entry) {
|
|
13875
|
-
if (this.config.enableLogging) {
|
|
13876
|
-
(0, debug_logger_1.debugLog)("CACHE", `\u274C Session signatures cache miss: ${cacheKey}`);
|
|
13877
|
-
}
|
|
13878
|
-
return null;
|
|
13879
|
-
}
|
|
13880
|
-
if (!this.isEntryValid(entry)) {
|
|
13881
|
-
this.cache.delete(cacheKey);
|
|
13882
|
-
if (this.config.enableLogging) {
|
|
13883
|
-
(0, debug_logger_1.debugWarn)("CACHE", `\u23F0 Session signatures expired: ${cacheKey}`);
|
|
13884
|
-
}
|
|
13885
|
-
return null;
|
|
13886
|
-
}
|
|
13887
|
-
if (this.config.enableLogging) {
|
|
13888
|
-
const timeUntilExpiry = entry.expiration.getTime() - Date.now();
|
|
13889
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u2705 Session signatures cache hit: ${cacheKey} (expires in ${Math.round(timeUntilExpiry / 1e3)}s)`);
|
|
13890
|
-
}
|
|
13891
|
-
return entry.sessionSigs;
|
|
13892
|
-
}
|
|
13893
|
-
/**
|
|
13894
|
-
* Cache session signatures
|
|
13895
|
-
*/
|
|
13896
|
-
set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration) {
|
|
13897
|
-
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13898
|
-
const entry = {
|
|
13899
|
-
sessionSigs,
|
|
13900
|
-
expiration,
|
|
13901
|
-
pkpTokenId,
|
|
13902
|
-
litActionCid,
|
|
13903
|
-
signerAddress,
|
|
13904
|
-
network,
|
|
13905
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
13906
|
-
};
|
|
13907
|
-
this.cache.set(cacheKey, entry);
|
|
13908
|
-
if (this.config.enableLogging) {
|
|
13909
|
-
const timeUntilExpiry = expiration.getTime() - Date.now();
|
|
13910
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u{1F4BE} Cached session signatures: ${cacheKey} (expires in ${Math.round(timeUntilExpiry / 1e3)}s)`);
|
|
13911
|
-
}
|
|
13912
|
-
this.enforceCacheSize();
|
|
13913
|
-
}
|
|
13914
|
-
/**
|
|
13915
|
-
* Clear all cached session signatures
|
|
13916
|
-
*/
|
|
13917
|
-
clear() {
|
|
13918
|
-
const size = this.cache.size;
|
|
13919
|
-
this.cache.clear();
|
|
13920
|
-
if (this.config.enableLogging) {
|
|
13921
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u{1F5D1}\uFE0F Cleared ${size} cached session signature entries`);
|
|
13922
|
-
}
|
|
13923
|
-
}
|
|
13924
|
-
/**
|
|
13925
|
-
* Get cache statistics
|
|
13926
|
-
*/
|
|
13927
|
-
getStats() {
|
|
13928
|
-
this.cleanExpiredEntries();
|
|
13929
|
-
return {
|
|
13930
|
-
size: this.cache.size,
|
|
13931
|
-
maxEntries: this.config.maxEntries,
|
|
13932
|
-
utilizationPercent: Math.round(this.cache.size / this.config.maxEntries * 100)
|
|
13933
|
-
};
|
|
13934
|
-
}
|
|
13935
|
-
/**
|
|
13936
|
-
* Remove specific cache entry
|
|
13937
|
-
*/
|
|
13938
|
-
delete(pkpTokenId, litActionCid, signerAddress, network) {
|
|
13939
|
-
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13940
|
-
const deleted = this.cache.delete(cacheKey);
|
|
13941
|
-
if (deleted && this.config.enableLogging) {
|
|
13942
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u{1F5D1}\uFE0F Removed session signatures from cache: ${cacheKey}`);
|
|
13943
|
-
}
|
|
13944
|
-
return deleted;
|
|
13945
|
-
}
|
|
13946
|
-
};
|
|
13947
|
-
exports.sessionSignatureCache = new SessionSignatureCache();
|
|
13948
|
-
async function generateSessionSignaturesWithCache(litNodeClient, sessionConfig, pkpTokenId, litActionCid, signerAddress, network = "chipotle") {
|
|
13949
|
-
const cached = exports.sessionSignatureCache.get(pkpTokenId, litActionCid, signerAddress, network);
|
|
13950
|
-
if (cached) {
|
|
13951
|
-
return cached;
|
|
13952
|
-
}
|
|
13953
|
-
(0, debug_logger_1.debugInfo)("CACHE", "\u{1F510} Generating new session signatures (cache miss)...");
|
|
13954
|
-
const sessionSigs = await litNodeClient.getSessionSigs(sessionConfig);
|
|
13955
|
-
const expiration = new Date(sessionConfig.expiration);
|
|
13956
|
-
exports.sessionSignatureCache.set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration);
|
|
13957
|
-
const sigCount = Object.keys(sessionSigs).length;
|
|
13958
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u2705 Generated and cached ${sigCount} session signatures`);
|
|
13959
|
-
return sessionSigs;
|
|
13960
|
-
}
|
|
13961
|
-
function configureSessionSignatureCache(config) {
|
|
13962
|
-
Object.assign(exports.sessionSignatureCache["config"], config);
|
|
13963
|
-
}
|
|
13964
|
-
function clearSessionSignatureCache() {
|
|
13965
|
-
exports.sessionSignatureCache.clear();
|
|
13966
|
-
}
|
|
13967
|
-
function getSessionSignatureCacheStats() {
|
|
13968
|
-
return exports.sessionSignatureCache.getStats();
|
|
13969
|
-
}
|
|
13970
|
-
}
|
|
13971
|
-
});
|
|
13972
|
-
|
|
13973
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/connection-helpers.js
|
|
13974
|
-
var require_connection_helpers = __commonJS({
|
|
13975
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/connection-helpers.js"(exports) {
|
|
13976
|
-
"use strict";
|
|
13977
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
13978
|
-
if (k2 === void 0)
|
|
13979
|
-
k2 = k;
|
|
13980
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13981
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13982
|
-
desc = { enumerable: true, get: function() {
|
|
13983
|
-
return m[k];
|
|
13984
|
-
} };
|
|
13985
|
-
}
|
|
13986
|
-
Object.defineProperty(o, k2, desc);
|
|
13987
|
-
} : function(o, m, k, k2) {
|
|
13988
|
-
if (k2 === void 0)
|
|
13989
|
-
k2 = k;
|
|
13990
|
-
o[k2] = m[k];
|
|
13991
|
-
});
|
|
13992
|
-
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
13993
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
13994
|
-
} : function(o, v) {
|
|
13995
|
-
o["default"] = v;
|
|
13996
|
-
});
|
|
13997
|
-
var __importStar = exports && exports.__importStar || function() {
|
|
13998
|
-
var ownKeys = function(o) {
|
|
13999
|
-
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
14000
|
-
var ar = [];
|
|
14001
|
-
for (var k in o2)
|
|
14002
|
-
if (Object.prototype.hasOwnProperty.call(o2, k))
|
|
14003
|
-
ar[ar.length] = k;
|
|
14004
|
-
return ar;
|
|
14005
|
-
};
|
|
14006
|
-
return ownKeys(o);
|
|
14007
|
-
};
|
|
14008
|
-
return function(mod) {
|
|
14009
|
-
if (mod && mod.__esModule)
|
|
14010
|
-
return mod;
|
|
14011
|
-
var result = {};
|
|
14012
|
-
if (mod != null) {
|
|
14013
|
-
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
14014
|
-
if (k[i] !== "default")
|
|
14015
|
-
__createBinding(result, mod, k[i]);
|
|
14016
|
-
}
|
|
14017
|
-
__setModuleDefault(result, mod);
|
|
14018
|
-
return result;
|
|
14019
|
-
};
|
|
14020
|
-
}();
|
|
14021
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14022
|
-
exports.NETWORK_TIMEOUTS = exports.DEFAULT_RETRY_CONFIG = void 0;
|
|
14023
|
-
exports.sleep = sleep;
|
|
14024
|
-
exports.isRetryableError = isRetryableError;
|
|
14025
|
-
exports.calculateDelay = calculateDelay;
|
|
14026
|
-
exports.withRetry = withRetry;
|
|
14027
|
-
exports.connectLitNodeClient = connectLitNodeClient;
|
|
14028
|
-
exports.connectLitContracts = connectLitContracts;
|
|
14029
|
-
exports.validateLitNodeConnection = validateLitNodeConnection;
|
|
14030
|
-
exports.generateSessionSignatures = generateSessionSignatures;
|
|
14031
|
-
exports.validateLitNodeReadiness = validateLitNodeReadiness;
|
|
14032
|
-
exports.executeLitAction = executeLitAction;
|
|
14033
|
-
exports.executePkpOperation = executePkpOperation;
|
|
14034
|
-
exports.getNetworkTimeouts = getNetworkTimeouts;
|
|
14035
|
-
var debug_logger_1 = require_debug_logger();
|
|
14036
|
-
var error_classification_1 = require_error_classification();
|
|
14037
|
-
exports.DEFAULT_RETRY_CONFIG = {
|
|
14013
|
+
var DEFAULT_RETRY_CONFIG = {
|
|
14038
14014
|
maxAttempts: 5,
|
|
14039
14015
|
// Increased from 3 for PKP operations
|
|
14040
14016
|
initialDelayMs: 2e3,
|
|
@@ -14068,80 +14044,85 @@ var require_connection_helpers = __commonJS({
|
|
|
14068
14044
|
function sleep(ms) {
|
|
14069
14045
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
14070
14046
|
}
|
|
14071
|
-
function isRetryableError(error, retryableErrors =
|
|
14047
|
+
function isRetryableError(error, retryableErrors = DEFAULT_RETRY_CONFIG.retryableErrors) {
|
|
14072
14048
|
if (!error)
|
|
14073
14049
|
return false;
|
|
14074
|
-
const classification =
|
|
14050
|
+
const classification = classifyError(error);
|
|
14075
14051
|
if (classification.isRetryable !== void 0) {
|
|
14076
|
-
|
|
14052
|
+
debugInfo("ERROR_CLASSIFICATION", `Error classified as: ${classification.category} (retryable: ${classification.isRetryable})`);
|
|
14077
14053
|
return classification.isRetryable;
|
|
14078
14054
|
}
|
|
14079
14055
|
const errorMessage = error.message || error.toString() || "";
|
|
14080
14056
|
const errorLower = errorMessage.toLowerCase();
|
|
14081
|
-
return retryableErrors.some(
|
|
14057
|
+
return retryableErrors.some(
|
|
14058
|
+
(pattern) => errorLower.includes(pattern.toLowerCase())
|
|
14059
|
+
);
|
|
14082
14060
|
}
|
|
14083
14061
|
function calculateDelay(attempt, config) {
|
|
14084
|
-
const exponentialDelay = Math.min(
|
|
14062
|
+
const exponentialDelay = Math.min(
|
|
14063
|
+
config.initialDelayMs * Math.pow(config.backoffMultiplier, attempt - 1),
|
|
14064
|
+
config.maxDelayMs
|
|
14065
|
+
);
|
|
14085
14066
|
const jitter = exponentialDelay * 0.25 * (Math.random() - 0.5);
|
|
14086
14067
|
return Math.max(100, exponentialDelay + jitter);
|
|
14087
14068
|
}
|
|
14088
14069
|
async function withRetry(operation, config = {}, operationName = "operation") {
|
|
14089
|
-
let finalConfig = { ...
|
|
14090
|
-
const tracker = new
|
|
14070
|
+
let finalConfig = { ...DEFAULT_RETRY_CONFIG, ...config };
|
|
14071
|
+
const tracker = new PerformanceTracker(`Retry ${operationName}`);
|
|
14091
14072
|
let lastError;
|
|
14092
14073
|
let errorClassification = null;
|
|
14093
14074
|
for (let attempt = 1; attempt <= finalConfig.maxAttempts; attempt++) {
|
|
14094
14075
|
try {
|
|
14095
|
-
|
|
14076
|
+
debugInfo("RETRY", `\u{1F504} [${operationName}] Attempt ${attempt}/${finalConfig.maxAttempts}`);
|
|
14096
14077
|
const startTime = Date.now();
|
|
14097
14078
|
const result = await operation();
|
|
14098
14079
|
const duration = Date.now() - startTime;
|
|
14099
|
-
|
|
14100
|
-
|
|
14080
|
+
debugInfo("RETRY", `\u2705 [${operationName}] Success after ${duration}ms (attempt ${attempt})`);
|
|
14081
|
+
networkMetrics.recordRequest(operationName, true, duration);
|
|
14101
14082
|
tracker.end(true);
|
|
14102
14083
|
return result;
|
|
14103
14084
|
} catch (error) {
|
|
14104
14085
|
lastError = error;
|
|
14105
14086
|
const errorMessage = error?.message || error?.toString() || "Unknown error";
|
|
14106
|
-
errorClassification =
|
|
14087
|
+
errorClassification = classifyError(error);
|
|
14107
14088
|
if (attempt === 1 && errorClassification) {
|
|
14108
|
-
const intelligentConfig =
|
|
14089
|
+
const intelligentConfig = getRetryConfigFromClassification(errorClassification);
|
|
14109
14090
|
finalConfig = {
|
|
14110
14091
|
...finalConfig,
|
|
14111
14092
|
...intelligentConfig,
|
|
14112
14093
|
maxAttempts: Math.min(finalConfig.maxAttempts, intelligentConfig.maxAttempts)
|
|
14113
14094
|
};
|
|
14114
|
-
|
|
14115
|
-
|
|
14095
|
+
debugInfo("RETRY", `\u{1F9E0} Intelligent retry strategy applied: ${errorClassification.category} (${errorClassification.retryStrategy})`);
|
|
14096
|
+
debugInfo("RETRY", `\u{1F4CA} Adjusted config: max=${finalConfig.maxAttempts}, delay=${finalConfig.initialDelayMs}ms`);
|
|
14116
14097
|
}
|
|
14117
|
-
|
|
14098
|
+
debugWarn("RETRY", `\u26A0\uFE0F [${operationName}] Attempt ${attempt} failed:`, {
|
|
14118
14099
|
error: errorMessage,
|
|
14119
14100
|
attempt,
|
|
14120
14101
|
category: errorClassification.category,
|
|
14121
14102
|
retryable: errorClassification.isRetryable
|
|
14122
14103
|
});
|
|
14123
|
-
|
|
14104
|
+
networkMetrics.recordRequest(operationName, false, 0, errorMessage);
|
|
14124
14105
|
if (attempt >= finalConfig.maxAttempts) {
|
|
14125
|
-
|
|
14106
|
+
debugError("RETRY", `\u274C [${operationName}] All attempts failed. Last error:`, { error: errorMessage });
|
|
14126
14107
|
if (errorClassification) {
|
|
14127
|
-
const errorReport =
|
|
14128
|
-
|
|
14108
|
+
const errorReport = createErrorReport(error);
|
|
14109
|
+
debugError("RETRY", `\u{1F4CB} Error Analysis Report:
|
|
14129
14110
|
${errorReport}`);
|
|
14130
14111
|
}
|
|
14131
14112
|
tracker.end(false);
|
|
14132
14113
|
break;
|
|
14133
14114
|
}
|
|
14134
14115
|
if (!errorClassification.isRetryable) {
|
|
14135
|
-
|
|
14116
|
+
debugError("RETRY", `\u{1F6AB} [${operationName}] Non-retryable error (${errorClassification.category}):`, { error: errorMessage });
|
|
14136
14117
|
if (errorClassification.troubleshooting) {
|
|
14137
|
-
|
|
14118
|
+
debugInfo("RETRY", `\u{1F4A1} Troubleshooting suggestions:
|
|
14138
14119
|
${errorClassification.troubleshooting.join("\n ")}`);
|
|
14139
14120
|
}
|
|
14140
14121
|
tracker.end(false);
|
|
14141
14122
|
break;
|
|
14142
14123
|
}
|
|
14143
14124
|
const delayMs = calculateDelay(attempt, finalConfig);
|
|
14144
|
-
|
|
14125
|
+
debugInfo("RETRY", `\u23F3 [${operationName}] Waiting ${delayMs}ms before retry... (${errorClassification.retryStrategy} strategy)`);
|
|
14145
14126
|
await sleep(delayMs);
|
|
14146
14127
|
}
|
|
14147
14128
|
}
|
|
@@ -14149,36 +14130,44 @@ ${errorReport}`);
|
|
|
14149
14130
|
}
|
|
14150
14131
|
async function connectLitNodeClient(litNodeClient, config = {}) {
|
|
14151
14132
|
const network = litNodeClient?.config?.litNetwork || "unknown";
|
|
14152
|
-
return withRetry(
|
|
14153
|
-
|
|
14154
|
-
|
|
14155
|
-
|
|
14156
|
-
|
|
14157
|
-
|
|
14158
|
-
|
|
14159
|
-
|
|
14160
|
-
|
|
14161
|
-
|
|
14162
|
-
|
|
14163
|
-
|
|
14164
|
-
|
|
14165
|
-
|
|
14166
|
-
|
|
14167
|
-
|
|
14168
|
-
|
|
14169
|
-
|
|
14170
|
-
|
|
14171
|
-
|
|
14133
|
+
return withRetry(
|
|
14134
|
+
async () => {
|
|
14135
|
+
if (!litNodeClient) {
|
|
14136
|
+
throw new Error("LIT Node Client is null or undefined");
|
|
14137
|
+
}
|
|
14138
|
+
const startTime = Date.now();
|
|
14139
|
+
logConnectionAttempt(network, 1, config.maxAttempts || DEFAULT_RETRY_CONFIG.maxAttempts);
|
|
14140
|
+
await litNodeClient.connect();
|
|
14141
|
+
debugInfo("CONNECTION", `\u23F3 Waiting for LIT Node Client to be ready...`);
|
|
14142
|
+
const readyTimeout = 3e4;
|
|
14143
|
+
const readyStartTime = Date.now();
|
|
14144
|
+
while (!litNodeClient.ready && Date.now() - readyStartTime < readyTimeout) {
|
|
14145
|
+
await sleep(500);
|
|
14146
|
+
}
|
|
14147
|
+
if (!litNodeClient.ready) {
|
|
14148
|
+
throw new Error(`LIT Node Client failed to become ready within ${readyTimeout}ms`);
|
|
14149
|
+
}
|
|
14150
|
+
const latency = Date.now() - startTime;
|
|
14151
|
+
debugInfo("CONNECTION", `\u2705 LIT Node Client is ready (${litNodeClient.ready})`);
|
|
14152
|
+
logConnectionSuccess(network, latency);
|
|
14153
|
+
},
|
|
14154
|
+
config,
|
|
14155
|
+
"LIT Node Client Connection"
|
|
14156
|
+
);
|
|
14172
14157
|
}
|
|
14173
14158
|
async function connectLitContracts(litContracts, config = {}) {
|
|
14174
|
-
return withRetry(
|
|
14175
|
-
|
|
14176
|
-
|
|
14177
|
-
|
|
14178
|
-
|
|
14179
|
-
|
|
14180
|
-
|
|
14181
|
-
|
|
14159
|
+
return withRetry(
|
|
14160
|
+
async () => {
|
|
14161
|
+
if (!litContracts) {
|
|
14162
|
+
throw new Error("LIT Contracts is null or undefined");
|
|
14163
|
+
}
|
|
14164
|
+
console.log(`\u{1F517} Connecting to LIT Contracts: ${litContracts.network || "unknown"}`);
|
|
14165
|
+
await litContracts.connect();
|
|
14166
|
+
console.log("\u2705 LIT Contracts connected successfully");
|
|
14167
|
+
},
|
|
14168
|
+
config,
|
|
14169
|
+
"LIT Contracts Connection"
|
|
14170
|
+
);
|
|
14182
14171
|
}
|
|
14183
14172
|
async function validateLitNodeConnection(litNodeClient) {
|
|
14184
14173
|
try {
|
|
@@ -14198,33 +14187,37 @@ ${errorReport}`);
|
|
|
14198
14187
|
}
|
|
14199
14188
|
async function generateSessionSignatures(litNodeClient, sessionConfig, config = {}, pkpTokenId, litActionCid, signerAddress, network = "chipotle") {
|
|
14200
14189
|
if (pkpTokenId && litActionCid && signerAddress) {
|
|
14201
|
-
const { sessionSignatureCache } = await Promise.resolve().then(() =>
|
|
14202
|
-
const cached =
|
|
14190
|
+
const { sessionSignatureCache: sessionSignatureCache2 } = await Promise.resolve().then(() => (init_session_signature_cache(), session_signature_cache_exports));
|
|
14191
|
+
const cached = sessionSignatureCache2.get(pkpTokenId, litActionCid, signerAddress, network);
|
|
14203
14192
|
if (cached) {
|
|
14204
14193
|
const sigCount = Object.keys(cached).length;
|
|
14205
|
-
|
|
14194
|
+
debugInfo("SESSION", `\u{1F504} Using cached session signatures (${sigCount} sigs)`);
|
|
14206
14195
|
return cached;
|
|
14207
14196
|
}
|
|
14208
14197
|
}
|
|
14209
|
-
return withRetry(
|
|
14210
|
-
(
|
|
14211
|
-
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
|
|
14215
|
-
|
|
14216
|
-
|
|
14217
|
-
|
|
14218
|
-
|
|
14219
|
-
|
|
14220
|
-
|
|
14198
|
+
return withRetry(
|
|
14199
|
+
async () => {
|
|
14200
|
+
debugInfo("SESSION", "\u{1F510} Generating new session signatures...");
|
|
14201
|
+
const sessionSigs = await litNodeClient.getSessionSigs(sessionConfig);
|
|
14202
|
+
const sigCount = Object.keys(sessionSigs).length;
|
|
14203
|
+
if (pkpTokenId && litActionCid && signerAddress) {
|
|
14204
|
+
const { sessionSignatureCache: sessionSignatureCache2 } = await Promise.resolve().then(() => (init_session_signature_cache(), session_signature_cache_exports));
|
|
14205
|
+
const expiration = new Date(sessionConfig.expiration);
|
|
14206
|
+
sessionSignatureCache2.set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration);
|
|
14207
|
+
}
|
|
14208
|
+
debugInfo("SESSION", `\u2705 Generated ${sigCount} session signatures`);
|
|
14209
|
+
return sessionSigs;
|
|
14210
|
+
},
|
|
14211
|
+
config,
|
|
14212
|
+
"Session Signature Generation"
|
|
14213
|
+
);
|
|
14221
14214
|
}
|
|
14222
14215
|
async function validateLitNodeReadiness(litNodeClient) {
|
|
14223
14216
|
if (!litNodeClient) {
|
|
14224
14217
|
throw new Error("LIT Node Client is null or undefined");
|
|
14225
14218
|
}
|
|
14226
14219
|
if (!litNodeClient.ready) {
|
|
14227
|
-
|
|
14220
|
+
debugWarn("CONNECTION", "\u26A0\uFE0F LIT Node Client not ready, attempting to reconnect...");
|
|
14228
14221
|
await litNodeClient.connect();
|
|
14229
14222
|
const readyTimeout = 15e3;
|
|
14230
14223
|
const startTime = Date.now();
|
|
@@ -14235,32 +14228,36 @@ ${errorReport}`);
|
|
|
14235
14228
|
throw new Error("LIT Node Client is not ready for operations");
|
|
14236
14229
|
}
|
|
14237
14230
|
}
|
|
14238
|
-
|
|
14231
|
+
debugInfo("CONNECTION", "\u2705 LIT Node Client readiness validated");
|
|
14239
14232
|
}
|
|
14240
14233
|
async function executeLitAction(litNodeClient, executionConfig, config = {}) {
|
|
14241
14234
|
const cid = executionConfig.ipfsId;
|
|
14242
|
-
return withRetry(
|
|
14243
|
-
|
|
14244
|
-
|
|
14245
|
-
|
|
14246
|
-
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
(
|
|
14251
|
-
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
|
|
14255
|
-
|
|
14256
|
-
|
|
14235
|
+
return withRetry(
|
|
14236
|
+
async () => {
|
|
14237
|
+
const startTime = Date.now();
|
|
14238
|
+
await validateLitNodeReadiness(litNodeClient);
|
|
14239
|
+
logLitActionExecution(cid, executionConfig.jsParams);
|
|
14240
|
+
logRequest("LIT_ACTION", "executeJs", executionConfig);
|
|
14241
|
+
const result = await litNodeClient.executeJs(executionConfig);
|
|
14242
|
+
const duration = Date.now() - startTime;
|
|
14243
|
+
if (!result.response) {
|
|
14244
|
+
logError("LIT_ACTION", "executeJs", new Error("No response from LIT Action"), duration);
|
|
14245
|
+
throw new Error("No response from LIT Action");
|
|
14246
|
+
}
|
|
14247
|
+
logResponse("LIT_ACTION", "executeJs", result, duration);
|
|
14248
|
+
logLitActionResult(cid, true, duration, result);
|
|
14249
|
+
return result;
|
|
14250
|
+
},
|
|
14251
|
+
config,
|
|
14252
|
+
"LIT Action Execution"
|
|
14253
|
+
);
|
|
14257
14254
|
}
|
|
14258
14255
|
async function executePkpOperation(operation, operationName, config = {}) {
|
|
14259
14256
|
const pkpConfig = {
|
|
14260
|
-
...
|
|
14257
|
+
...DEFAULT_RETRY_CONFIG,
|
|
14261
14258
|
...config,
|
|
14262
14259
|
retryableErrors: [
|
|
14263
|
-
...
|
|
14260
|
+
...DEFAULT_RETRY_CONFIG.retryableErrors,
|
|
14264
14261
|
"pkp validation",
|
|
14265
14262
|
"signing shares",
|
|
14266
14263
|
"resource validation",
|
|
@@ -14269,7 +14266,7 @@ ${errorReport}`);
|
|
|
14269
14266
|
};
|
|
14270
14267
|
return withRetry(operation, pkpConfig, `PKP ${operationName}`);
|
|
14271
14268
|
}
|
|
14272
|
-
|
|
14269
|
+
var NETWORK_TIMEOUTS = {
|
|
14273
14270
|
chipotle: {
|
|
14274
14271
|
connection: 6e4,
|
|
14275
14272
|
operation: 12e4,
|
|
@@ -14277,82 +14274,10 @@ ${errorReport}`);
|
|
|
14277
14274
|
}
|
|
14278
14275
|
};
|
|
14279
14276
|
function getNetworkTimeouts(network) {
|
|
14280
|
-
return
|
|
14277
|
+
return NETWORK_TIMEOUTS[network] || NETWORK_TIMEOUTS["chipotle"];
|
|
14281
14278
|
}
|
|
14282
|
-
|
|
14283
|
-
|
|
14284
|
-
|
|
14285
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/index.js
|
|
14286
|
-
var require_utils4 = __commonJS({
|
|
14287
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/index.js"(exports) {
|
|
14288
|
-
"use strict";
|
|
14289
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
14290
|
-
if (k2 === void 0)
|
|
14291
|
-
k2 = k;
|
|
14292
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14293
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14294
|
-
desc = { enumerable: true, get: function() {
|
|
14295
|
-
return m[k];
|
|
14296
|
-
} };
|
|
14297
|
-
}
|
|
14298
|
-
Object.defineProperty(o, k2, desc);
|
|
14299
|
-
} : function(o, m, k, k2) {
|
|
14300
|
-
if (k2 === void 0)
|
|
14301
|
-
k2 = k;
|
|
14302
|
-
o[k2] = m[k];
|
|
14303
|
-
});
|
|
14304
|
-
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
14305
|
-
for (var p in m)
|
|
14306
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
14307
|
-
__createBinding(exports2, m, p);
|
|
14308
|
-
};
|
|
14309
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14310
|
-
__exportStar(require_lit_action_helpers(), exports);
|
|
14311
|
-
__exportStar(require_pkp_setup(), exports);
|
|
14312
|
-
__exportStar(require_cid_utils(), exports);
|
|
14313
|
-
__exportStar(require_connection_helpers(), exports);
|
|
14314
|
-
__exportStar(require_debug_logger(), exports);
|
|
14315
|
-
__exportStar(require_error_classification(), exports);
|
|
14316
|
-
__exportStar(require_session_signature_cache(), exports);
|
|
14317
|
-
}
|
|
14318
|
-
});
|
|
14319
|
-
|
|
14320
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js
|
|
14321
|
-
var require_pkg_src = __commonJS({
|
|
14322
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js"(exports) {
|
|
14323
|
-
"use strict";
|
|
14324
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
14325
|
-
if (k2 === void 0)
|
|
14326
|
-
k2 = k;
|
|
14327
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14328
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14329
|
-
desc = { enumerable: true, get: function() {
|
|
14330
|
-
return m[k];
|
|
14331
|
-
} };
|
|
14332
|
-
}
|
|
14333
|
-
Object.defineProperty(o, k2, desc);
|
|
14334
|
-
} : function(o, m, k, k2) {
|
|
14335
|
-
if (k2 === void 0)
|
|
14336
|
-
k2 = k;
|
|
14337
|
-
o[k2] = m[k];
|
|
14338
|
-
});
|
|
14339
|
-
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
14340
|
-
for (var p in m)
|
|
14341
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
14342
|
-
__createBinding(exports2, m, p);
|
|
14343
|
-
};
|
|
14344
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14345
|
-
exports.CHIPOTLE_DEPLOYMENTS = exports.DH_LIT_ACTIONS_CHIPOTLE = void 0;
|
|
14346
|
-
__exportStar(require_interfaces(), exports);
|
|
14347
|
-
__exportStar(require_lit_actions_registry(), exports);
|
|
14348
|
-
__exportStar(require_utils4(), exports);
|
|
14349
|
-
var lit_actions_registry_1 = require_lit_actions_registry();
|
|
14350
|
-
Object.defineProperty(exports, "DH_LIT_ACTIONS_CHIPOTLE", { enumerable: true, get: function() {
|
|
14351
|
-
return lit_actions_registry_1.DH_LIT_ACTIONS_CHIPOTLE;
|
|
14352
|
-
} });
|
|
14353
|
-
Object.defineProperty(exports, "CHIPOTLE_DEPLOYMENTS", { enumerable: true, get: function() {
|
|
14354
|
-
return lit_actions_registry_1.CHIPOTLE_DEPLOYMENTS;
|
|
14355
|
-
} });
|
|
14279
|
+
init_debug_logger();
|
|
14280
|
+
init_session_signature_cache();
|
|
14356
14281
|
}
|
|
14357
14282
|
});
|
|
14358
14283
|
|
|
@@ -14633,68 +14558,66 @@ var init_deployment_addresses = __esm({
|
|
|
14633
14558
|
LOCALHOST_DEPLOYMENT = {
|
|
14634
14559
|
network: "localhost",
|
|
14635
14560
|
chainId: 31337,
|
|
14636
|
-
timestamp: "2026-
|
|
14561
|
+
timestamp: "2026-03-23T15:33:34.068Z",
|
|
14637
14562
|
deployer: "",
|
|
14638
14563
|
contracts: {
|
|
14639
|
-
MessageHashBuilder: "
|
|
14640
|
-
UpgradeValidator: "
|
|
14564
|
+
MessageHashBuilder: "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
|
|
14565
|
+
UpgradeValidator: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
|
|
14641
14566
|
UCDToken: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
14642
14567
|
UCDController: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
14643
|
-
PositionManagerCoreModule: "
|
|
14644
|
-
TermManagerModule: "
|
|
14645
|
-
LoanOperationsManagerModule: "
|
|
14568
|
+
PositionManagerCoreModule: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
14569
|
+
TermManagerModule: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
|
|
14570
|
+
LoanOperationsManagerModule: "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
|
|
14646
14571
|
BTCSpendAuthorizer: "0x59b670e9fA9D0A427751Af201D676719a970857b",
|
|
14647
14572
|
CollateralManagerModule: "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
|
|
14648
14573
|
LiquidationManagerModule: "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
|
|
14649
|
-
CircuitBreakerModule: "
|
|
14574
|
+
CircuitBreakerModule: "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
|
|
14650
14575
|
AdminModule: "0xc5a5C42992dECbae36851359345FE25997F5C42d",
|
|
14651
|
-
PositionManagerViews: "
|
|
14652
|
-
PositionManager: "
|
|
14653
|
-
OperationAuthorizationRegistry: "
|
|
14654
|
-
PKPValidation: "
|
|
14576
|
+
PositionManagerViews: "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
|
|
14577
|
+
PositionManager: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
|
|
14578
|
+
OperationAuthorizationRegistry: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
|
|
14579
|
+
PKPValidation: "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc"
|
|
14655
14580
|
},
|
|
14656
14581
|
latestEnv: {
|
|
14657
14582
|
UCD_TOKEN: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
14658
14583
|
UCD_CONTROLLER: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
14659
|
-
POSITION_MANAGER: "
|
|
14660
|
-
PKP_VALIDATION_REGISTRY: "
|
|
14661
|
-
PKP_VALIDATION_CID_V1: "
|
|
14662
|
-
|
|
14663
|
-
|
|
14664
|
-
|
|
14665
|
-
UCD_MINT_VALIDATOR_ADDRESS: "0x4D9299055093938d0CD2F26C42A87260CB50adD8",
|
|
14584
|
+
POSITION_MANAGER: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
|
|
14585
|
+
PKP_VALIDATION_REGISTRY: "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc",
|
|
14586
|
+
PKP_VALIDATION_CID_V1: "QmfHJKA4RnW7RepsdLmrDwKjVTzPXB2K3qMTco3JNPDexm",
|
|
14587
|
+
PKP_ETH_ADDRESS: "0x9624C46073E1d1F5AB975c67Fc899536d599bb57",
|
|
14588
|
+
OPERATION_AUTHORIZATION_REGISTRY: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
|
|
14589
|
+
UCD_MINT_VALIDATOR_ADDRESS: "0x80f81afb9e6dF27afCD752ad46cD286e705e42be",
|
|
14666
14590
|
UCD_MINT_VALIDATOR_VERSION: 1,
|
|
14667
|
-
BTC_WITHDRAWAL_VALIDATOR_ADDRESS: "
|
|
14591
|
+
BTC_WITHDRAWAL_VALIDATOR_ADDRESS: "0xa751ad81E1CAe61d6cF5Cf64839Fe8D28A1372Df",
|
|
14668
14592
|
BTC_WITHDRAWAL_VALIDATOR_VERSION: 1,
|
|
14669
|
-
UPDATE_BALANCE_VALIDATOR_ADDRESS: "
|
|
14593
|
+
UPDATE_BALANCE_VALIDATOR_ADDRESS: "0x8A40C22B03348bc10df9ae0dc54346b4AE8e909c",
|
|
14670
14594
|
UPDATE_BALANCE_VALIDATOR_VERSION: 1,
|
|
14671
|
-
PROCESS_PAYMENT_VALIDATOR_ADDRESS: "
|
|
14595
|
+
PROCESS_PAYMENT_VALIDATOR_ADDRESS: "0x28f50E07532d3aF677b8E0bcF220422d159b0dd6",
|
|
14672
14596
|
PROCESS_PAYMENT_VALIDATOR_VERSION: 1,
|
|
14673
|
-
EXTEND_POSITION_VALIDATOR_ADDRESS: "
|
|
14597
|
+
EXTEND_POSITION_VALIDATOR_ADDRESS: "0xc7aC43F2F907123465449575e853f5D0229898e1",
|
|
14674
14598
|
EXTEND_POSITION_VALIDATOR_VERSION: 1,
|
|
14675
|
-
POSITION_MANAGER_CORE_MODULE: "
|
|
14676
|
-
LOAN_OPERATIONS_MANAGER_MODULE: "
|
|
14677
|
-
TERM_MANAGER_MODULE: "
|
|
14678
|
-
COMMUNITY_MANAGER_MODULE: ""
|
|
14599
|
+
POSITION_MANAGER_CORE_MODULE: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
14600
|
+
LOAN_OPERATIONS_MANAGER_MODULE: "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
|
|
14601
|
+
TERM_MANAGER_MODULE: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82"
|
|
14679
14602
|
}
|
|
14680
14603
|
};
|
|
14681
14604
|
LOCALHOST_CONTRACTS = {
|
|
14682
|
-
MessageHashBuilder: "
|
|
14683
|
-
UpgradeValidator: "
|
|
14605
|
+
MessageHashBuilder: "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
|
|
14606
|
+
UpgradeValidator: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
|
|
14684
14607
|
UCDToken: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
14685
14608
|
UCDController: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
14686
|
-
PositionManagerCoreModule: "
|
|
14687
|
-
TermManagerModule: "
|
|
14688
|
-
LoanOperationsManagerModule: "
|
|
14609
|
+
PositionManagerCoreModule: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
14610
|
+
TermManagerModule: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
|
|
14611
|
+
LoanOperationsManagerModule: "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
|
|
14689
14612
|
BTCSpendAuthorizer: "0x59b670e9fA9D0A427751Af201D676719a970857b",
|
|
14690
14613
|
CollateralManagerModule: "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
|
|
14691
14614
|
LiquidationManagerModule: "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
|
|
14692
|
-
CircuitBreakerModule: "
|
|
14615
|
+
CircuitBreakerModule: "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
|
|
14693
14616
|
AdminModule: "0xc5a5C42992dECbae36851359345FE25997F5C42d",
|
|
14694
|
-
PositionManagerViews: "
|
|
14695
|
-
PositionManager: "
|
|
14696
|
-
OperationAuthorizationRegistry: "
|
|
14697
|
-
PKPValidation: "
|
|
14617
|
+
PositionManagerViews: "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
|
|
14618
|
+
PositionManager: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
|
|
14619
|
+
OperationAuthorizationRegistry: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
|
|
14620
|
+
PKPValidation: "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc"
|
|
14698
14621
|
};
|
|
14699
14622
|
ALL_DEPLOYMENTS = {
|
|
14700
14623
|
sepolia: SEPOLIA_DEPLOYMENT,
|
|
@@ -31812,106 +31735,333 @@ function createContractManager(config) {
|
|
|
31812
31735
|
}
|
|
31813
31736
|
|
|
31814
31737
|
// src/modules/cache/cache-manager.module.ts
|
|
31815
|
-
var
|
|
31816
|
-
cache
|
|
31738
|
+
var LRUCache = class {
|
|
31739
|
+
cache;
|
|
31817
31740
|
maxSize;
|
|
31818
31741
|
ttlMs;
|
|
31819
|
-
|
|
31820
|
-
|
|
31821
|
-
|
|
31742
|
+
debug;
|
|
31743
|
+
name;
|
|
31744
|
+
// Statistics
|
|
31745
|
+
stats = {
|
|
31746
|
+
hits: 0,
|
|
31747
|
+
misses: 0,
|
|
31748
|
+
evictions: 0
|
|
31749
|
+
};
|
|
31750
|
+
constructor(config = {}) {
|
|
31751
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
31752
|
+
this.maxSize = config.maxSize || 1e3;
|
|
31753
|
+
this.ttlMs = config.ttlMs || 6e4;
|
|
31754
|
+
this.debug = config.debug || false;
|
|
31755
|
+
this.name = config.name || "Cache";
|
|
31756
|
+
if (this.debug) {
|
|
31757
|
+
console.log(
|
|
31758
|
+
`\u{1F4BE} [${this.name}] Initialized: maxSize=${this.maxSize}, ttl=${this.ttlMs}ms`
|
|
31759
|
+
);
|
|
31760
|
+
}
|
|
31822
31761
|
}
|
|
31823
31762
|
/**
|
|
31824
31763
|
* Get value from cache
|
|
31764
|
+
*
|
|
31765
|
+
* Returns null if:
|
|
31766
|
+
* - Key not found
|
|
31767
|
+
* - Entry has expired
|
|
31768
|
+
*
|
|
31769
|
+
* @param key - Cache key
|
|
31770
|
+
* @returns Cached value or null
|
|
31825
31771
|
*/
|
|
31826
31772
|
get(key2) {
|
|
31827
31773
|
const entry = this.cache.get(key2);
|
|
31828
31774
|
if (!entry) {
|
|
31829
|
-
|
|
31775
|
+
this.stats.misses++;
|
|
31776
|
+
if (this.debug) {
|
|
31777
|
+
console.log(`\u274C [${this.name}] Cache MISS: ${String(key2)}`);
|
|
31778
|
+
}
|
|
31779
|
+
return null;
|
|
31830
31780
|
}
|
|
31831
|
-
|
|
31832
|
-
if (now2 - entry.timestamp > entry.ttl) {
|
|
31781
|
+
if (this.isExpired(entry)) {
|
|
31833
31782
|
this.cache.delete(key2);
|
|
31834
|
-
|
|
31783
|
+
this.stats.misses++;
|
|
31784
|
+
if (this.debug) {
|
|
31785
|
+
const age = Date.now() - entry.timestamp;
|
|
31786
|
+
console.log(`\u23F0 [${this.name}] Cache EXPIRED: ${String(key2)} (age: ${age}ms)`);
|
|
31787
|
+
}
|
|
31788
|
+
return null;
|
|
31789
|
+
}
|
|
31790
|
+
entry.hits++;
|
|
31791
|
+
entry.lastAccessed = Date.now();
|
|
31792
|
+
this.cache.set(key2, entry);
|
|
31793
|
+
this.stats.hits++;
|
|
31794
|
+
if (this.debug) {
|
|
31795
|
+
const age = Date.now() - entry.timestamp;
|
|
31796
|
+
console.log(
|
|
31797
|
+
`\u2705 [${this.name}] Cache HIT: ${String(key2)} (age: ${age}ms, hits: ${entry.hits})`
|
|
31798
|
+
);
|
|
31835
31799
|
}
|
|
31836
31800
|
return entry.value;
|
|
31837
31801
|
}
|
|
31802
|
+
/**
|
|
31803
|
+
* Get value from cache with Result wrapper
|
|
31804
|
+
*
|
|
31805
|
+
* Useful when you want to distinguish between "not found" and "expired"
|
|
31806
|
+
*/
|
|
31807
|
+
getResult(key2) {
|
|
31808
|
+
const value = this.get(key2);
|
|
31809
|
+
if (value === null) {
|
|
31810
|
+
return failure(
|
|
31811
|
+
new SDKError({
|
|
31812
|
+
message: `Cache miss for key: ${String(key2)}`,
|
|
31813
|
+
category: "CACHE" /* CACHE */,
|
|
31814
|
+
severity: "LOW" /* LOW */,
|
|
31815
|
+
originalError: new Error("Cache miss")
|
|
31816
|
+
})
|
|
31817
|
+
);
|
|
31818
|
+
}
|
|
31819
|
+
return success(value);
|
|
31820
|
+
}
|
|
31838
31821
|
/**
|
|
31839
31822
|
* Set value in cache
|
|
31823
|
+
*
|
|
31824
|
+
* If cache is full, evicts the least recently used entry
|
|
31825
|
+
*
|
|
31826
|
+
* @param key - Cache key
|
|
31827
|
+
* @param value - Value to cache
|
|
31828
|
+
* @param ttl - Optional custom TTL for this entry (ms)
|
|
31840
31829
|
*/
|
|
31841
31830
|
set(key2, value, ttl) {
|
|
31842
31831
|
if (this.cache.size >= this.maxSize && !this.cache.has(key2)) {
|
|
31843
|
-
|
|
31844
|
-
if (firstKey) {
|
|
31845
|
-
this.cache.delete(firstKey);
|
|
31846
|
-
}
|
|
31832
|
+
this.evictLRU();
|
|
31847
31833
|
}
|
|
31848
|
-
|
|
31834
|
+
const entry = {
|
|
31849
31835
|
value,
|
|
31850
31836
|
timestamp: Date.now(),
|
|
31851
|
-
|
|
31852
|
-
|
|
31837
|
+
hits: 0,
|
|
31838
|
+
lastAccessed: Date.now()
|
|
31839
|
+
};
|
|
31840
|
+
this.cache.set(key2, entry);
|
|
31841
|
+
if (this.debug) {
|
|
31842
|
+
const effectiveTtl = ttl || this.ttlMs;
|
|
31843
|
+
console.log(
|
|
31844
|
+
`\u{1F4BE} [${this.name}] Cache SET: ${String(key2)} (ttl: ${effectiveTtl}ms, size: ${this.cache.size}/${this.maxSize})`
|
|
31845
|
+
);
|
|
31846
|
+
}
|
|
31847
|
+
}
|
|
31848
|
+
/**
|
|
31849
|
+
* Set value in cache with Result wrapper
|
|
31850
|
+
*/
|
|
31851
|
+
setResult(key2, value, ttl) {
|
|
31852
|
+
try {
|
|
31853
|
+
this.set(key2, value, ttl);
|
|
31854
|
+
return success(void 0);
|
|
31855
|
+
} catch (error) {
|
|
31856
|
+
return failure(
|
|
31857
|
+
new SDKError({
|
|
31858
|
+
message: `Failed to set cache value for key: ${String(key2)}`,
|
|
31859
|
+
category: "CACHE" /* CACHE */,
|
|
31860
|
+
severity: "MEDIUM" /* MEDIUM */,
|
|
31861
|
+
originalError: error instanceof Error ? error : new Error(String(error))
|
|
31862
|
+
})
|
|
31863
|
+
);
|
|
31864
|
+
}
|
|
31853
31865
|
}
|
|
31854
31866
|
/**
|
|
31855
|
-
* Check if key exists in cache
|
|
31867
|
+
* Check if key exists in cache (without affecting stats)
|
|
31856
31868
|
*/
|
|
31857
31869
|
has(key2) {
|
|
31858
|
-
|
|
31870
|
+
const entry = this.cache.get(key2);
|
|
31871
|
+
return entry !== void 0 && !this.isExpired(entry);
|
|
31859
31872
|
}
|
|
31860
31873
|
/**
|
|
31861
|
-
* Delete key from cache
|
|
31874
|
+
* Delete specific key from cache
|
|
31862
31875
|
*/
|
|
31863
31876
|
delete(key2) {
|
|
31864
|
-
|
|
31877
|
+
const deleted = this.cache.delete(key2);
|
|
31878
|
+
if (deleted && this.debug) {
|
|
31879
|
+
console.log(`\u{1F5D1}\uFE0F [${this.name}] Cache DELETE: ${String(key2)}`);
|
|
31880
|
+
}
|
|
31881
|
+
return deleted;
|
|
31865
31882
|
}
|
|
31866
31883
|
/**
|
|
31867
|
-
* Clear
|
|
31884
|
+
* Clear entire cache
|
|
31868
31885
|
*/
|
|
31869
31886
|
clear() {
|
|
31887
|
+
const previousSize = this.cache.size;
|
|
31870
31888
|
this.cache.clear();
|
|
31889
|
+
this.stats = {
|
|
31890
|
+
hits: 0,
|
|
31891
|
+
misses: 0,
|
|
31892
|
+
evictions: 0
|
|
31893
|
+
};
|
|
31894
|
+
if (this.debug) {
|
|
31895
|
+
console.log(`\u{1F9F9} [${this.name}] Cache CLEARED: removed ${previousSize} entries`);
|
|
31896
|
+
}
|
|
31897
|
+
}
|
|
31898
|
+
/**
|
|
31899
|
+
* Get current cache size
|
|
31900
|
+
*/
|
|
31901
|
+
size() {
|
|
31902
|
+
return this.cache.size;
|
|
31903
|
+
}
|
|
31904
|
+
/**
|
|
31905
|
+
* Get cache statistics
|
|
31906
|
+
*/
|
|
31907
|
+
getStats() {
|
|
31908
|
+
const entries = Array.from(this.cache.values());
|
|
31909
|
+
const timestamps = entries.map((e) => e.timestamp);
|
|
31910
|
+
const total = this.stats.hits + this.stats.misses;
|
|
31911
|
+
const hitRate = total === 0 ? 0 : this.stats.hits / total * 100;
|
|
31912
|
+
return {
|
|
31913
|
+
size: this.cache.size,
|
|
31914
|
+
hits: this.stats.hits,
|
|
31915
|
+
misses: this.stats.misses,
|
|
31916
|
+
evictions: this.stats.evictions,
|
|
31917
|
+
oldestEntry: timestamps.length > 0 ? Math.min(...timestamps) : 0,
|
|
31918
|
+
newestEntry: timestamps.length > 0 ? Math.max(...timestamps) : 0,
|
|
31919
|
+
hitRate
|
|
31920
|
+
};
|
|
31921
|
+
}
|
|
31922
|
+
/**
|
|
31923
|
+
* Get hit rate percentage
|
|
31924
|
+
*/
|
|
31925
|
+
getHitRate() {
|
|
31926
|
+
const total = this.stats.hits + this.stats.misses;
|
|
31927
|
+
return total === 0 ? 0 : this.stats.hits / total * 100;
|
|
31928
|
+
}
|
|
31929
|
+
/**
|
|
31930
|
+
* Get all cached keys (for debugging)
|
|
31931
|
+
*/
|
|
31932
|
+
getKeys() {
|
|
31933
|
+
return Array.from(this.cache.keys());
|
|
31934
|
+
}
|
|
31935
|
+
/**
|
|
31936
|
+
* Get all cached values (for debugging)
|
|
31937
|
+
*/
|
|
31938
|
+
getValues() {
|
|
31939
|
+
return Array.from(this.cache.values()).map((entry) => entry.value);
|
|
31940
|
+
}
|
|
31941
|
+
/**
|
|
31942
|
+
* Get all cache entries with metadata (for debugging)
|
|
31943
|
+
*/
|
|
31944
|
+
getEntries() {
|
|
31945
|
+
return Array.from(this.cache.entries()).map(([key2, entry]) => ({
|
|
31946
|
+
key: key2,
|
|
31947
|
+
value: entry.value,
|
|
31948
|
+
metadata: {
|
|
31949
|
+
timestamp: entry.timestamp,
|
|
31950
|
+
hits: entry.hits,
|
|
31951
|
+
lastAccessed: entry.lastAccessed
|
|
31952
|
+
}
|
|
31953
|
+
}));
|
|
31871
31954
|
}
|
|
31872
31955
|
/**
|
|
31873
|
-
* Clean expired entries
|
|
31956
|
+
* Clean up expired entries
|
|
31957
|
+
*
|
|
31958
|
+
* Useful for periodic maintenance
|
|
31959
|
+
*
|
|
31960
|
+
* @returns Number of entries cleaned
|
|
31874
31961
|
*/
|
|
31875
31962
|
cleanExpired() {
|
|
31876
31963
|
const now2 = Date.now();
|
|
31877
|
-
let
|
|
31964
|
+
let cleanedCount = 0;
|
|
31878
31965
|
for (const [key2, entry] of this.cache.entries()) {
|
|
31879
|
-
if (now2 - entry.timestamp >
|
|
31966
|
+
if (now2 - entry.timestamp > this.ttlMs) {
|
|
31880
31967
|
this.cache.delete(key2);
|
|
31881
|
-
|
|
31968
|
+
cleanedCount++;
|
|
31882
31969
|
}
|
|
31883
31970
|
}
|
|
31884
|
-
|
|
31971
|
+
if (cleanedCount > 0 && this.debug) {
|
|
31972
|
+
console.log(`\u{1F9F9} [${this.name}] Cleaned ${cleanedCount} expired entries`);
|
|
31973
|
+
}
|
|
31974
|
+
return cleanedCount;
|
|
31885
31975
|
}
|
|
31886
31976
|
/**
|
|
31887
|
-
*
|
|
31977
|
+
* Check if cache entry is expired
|
|
31888
31978
|
*/
|
|
31889
|
-
|
|
31890
|
-
return
|
|
31891
|
-
|
|
31892
|
-
|
|
31893
|
-
|
|
31894
|
-
|
|
31979
|
+
isExpired(entry) {
|
|
31980
|
+
return Date.now() - entry.timestamp > this.ttlMs;
|
|
31981
|
+
}
|
|
31982
|
+
/**
|
|
31983
|
+
* Evict least recently used entry
|
|
31984
|
+
*/
|
|
31985
|
+
evictLRU() {
|
|
31986
|
+
let oldestKey = null;
|
|
31987
|
+
let oldestAccess = Infinity;
|
|
31988
|
+
for (const [key2, entry] of this.cache.entries()) {
|
|
31989
|
+
if (entry.lastAccessed < oldestAccess) {
|
|
31990
|
+
oldestAccess = entry.lastAccessed;
|
|
31991
|
+
oldestKey = key2;
|
|
31992
|
+
}
|
|
31993
|
+
}
|
|
31994
|
+
if (oldestKey !== null) {
|
|
31995
|
+
this.cache.delete(oldestKey);
|
|
31996
|
+
this.stats.evictions++;
|
|
31997
|
+
if (this.debug) {
|
|
31998
|
+
const timeSinceAccess = Date.now() - oldestAccess;
|
|
31999
|
+
console.log(
|
|
32000
|
+
`\u267B\uFE0F [${this.name}] Cache EVICT (LRU): ${String(oldestKey)} (last accessed: ${timeSinceAccess}ms ago)`
|
|
32001
|
+
);
|
|
32002
|
+
}
|
|
32003
|
+
}
|
|
32004
|
+
}
|
|
32005
|
+
/**
|
|
32006
|
+
* Get or compute value
|
|
32007
|
+
*
|
|
32008
|
+
* If key exists in cache, returns cached value.
|
|
32009
|
+
* Otherwise, computes value using provided function and caches it.
|
|
32010
|
+
*
|
|
32011
|
+
* @param key - Cache key
|
|
32012
|
+
* @param compute - Function to compute value if not in cache
|
|
32013
|
+
* @param ttl - Optional custom TTL for this entry
|
|
32014
|
+
* @returns Cached or computed value
|
|
32015
|
+
*/
|
|
32016
|
+
async getOrCompute(key2, compute, ttl) {
|
|
32017
|
+
const cached = this.get(key2);
|
|
32018
|
+
if (cached !== null) {
|
|
32019
|
+
return cached;
|
|
32020
|
+
}
|
|
32021
|
+
const value = await compute();
|
|
32022
|
+
this.set(key2, value, ttl);
|
|
32023
|
+
return value;
|
|
32024
|
+
}
|
|
32025
|
+
/**
|
|
32026
|
+
* Get or compute value with Result wrapper
|
|
32027
|
+
*/
|
|
32028
|
+
async getOrComputeResult(key2, compute, ttl) {
|
|
32029
|
+
const cached = this.get(key2);
|
|
32030
|
+
if (cached !== null) {
|
|
32031
|
+
return success(cached);
|
|
32032
|
+
}
|
|
32033
|
+
const result = await compute();
|
|
32034
|
+
if (result.success) {
|
|
32035
|
+
this.set(key2, result.value, ttl);
|
|
32036
|
+
}
|
|
32037
|
+
return result;
|
|
31895
32038
|
}
|
|
31896
32039
|
};
|
|
31897
32040
|
var CacheManager = class {
|
|
31898
32041
|
caches = /* @__PURE__ */ new Map();
|
|
31899
|
-
|
|
31900
|
-
constructor(
|
|
31901
|
-
this.
|
|
32042
|
+
globalConfig;
|
|
32043
|
+
constructor(globalConfig = {}) {
|
|
32044
|
+
this.globalConfig = globalConfig;
|
|
31902
32045
|
}
|
|
31903
32046
|
/**
|
|
31904
|
-
*
|
|
32047
|
+
* Create or get a named cache
|
|
32048
|
+
*
|
|
32049
|
+
* @param name - Unique cache name
|
|
32050
|
+
* @param config - Optional cache-specific configuration
|
|
32051
|
+
* @returns LRU cache instance
|
|
31905
32052
|
*/
|
|
31906
32053
|
getCache(name, config) {
|
|
31907
|
-
|
|
31908
|
-
|
|
32054
|
+
const existingCache = this.caches.get(name);
|
|
32055
|
+
if (existingCache) {
|
|
32056
|
+
return existingCache;
|
|
31909
32057
|
}
|
|
31910
|
-
const
|
|
32058
|
+
const mergedConfig = {
|
|
32059
|
+
...this.globalConfig,
|
|
32060
|
+
...config,
|
|
32061
|
+
name
|
|
32062
|
+
};
|
|
32063
|
+
const cache = new LRUCache(mergedConfig);
|
|
31911
32064
|
this.caches.set(name, cache);
|
|
31912
|
-
if (this.debug) {
|
|
31913
|
-
console.log(`[CacheManager] Created cache: ${name}`, config);
|
|
31914
|
-
}
|
|
31915
32065
|
return cache;
|
|
31916
32066
|
}
|
|
31917
32067
|
/**
|
|
@@ -31926,11 +32076,11 @@ var CacheManager = class {
|
|
|
31926
32076
|
* Clean expired entries from all caches
|
|
31927
32077
|
*/
|
|
31928
32078
|
cleanAllExpired() {
|
|
31929
|
-
let
|
|
32079
|
+
let totalCleaned = 0;
|
|
31930
32080
|
for (const cache of this.caches.values()) {
|
|
31931
|
-
|
|
32081
|
+
totalCleaned += cache.cleanExpired();
|
|
31932
32082
|
}
|
|
31933
|
-
return
|
|
32083
|
+
return totalCleaned;
|
|
31934
32084
|
}
|
|
31935
32085
|
/**
|
|
31936
32086
|
* Get statistics for all caches
|
|
@@ -31943,11 +32093,16 @@ var CacheManager = class {
|
|
|
31943
32093
|
return stats;
|
|
31944
32094
|
}
|
|
31945
32095
|
/**
|
|
31946
|
-
*
|
|
32096
|
+
* Get list of all cache names
|
|
31947
32097
|
*/
|
|
31948
|
-
|
|
31949
|
-
this.
|
|
31950
|
-
|
|
32098
|
+
getCacheNames() {
|
|
32099
|
+
return Array.from(this.caches.keys());
|
|
32100
|
+
}
|
|
32101
|
+
/**
|
|
32102
|
+
* Delete a named cache
|
|
32103
|
+
*/
|
|
32104
|
+
deleteCache(name) {
|
|
32105
|
+
return this.caches.delete(name);
|
|
31951
32106
|
}
|
|
31952
32107
|
};
|
|
31953
32108
|
function createCacheManager(config) {
|
|
@@ -36138,7 +36293,7 @@ var DiamondHandsGraph = class {
|
|
|
36138
36293
|
}
|
|
36139
36294
|
|
|
36140
36295
|
${shouldQuery.mint ? `
|
|
36141
|
-
|
|
36296
|
+
ucdmintEvents(
|
|
36142
36297
|
${buildPositionWhereClause()}
|
|
36143
36298
|
first: $limit,
|
|
36144
36299
|
orderBy: timestamp,
|
|
@@ -36327,7 +36482,7 @@ var DiamondHandsGraph = class {
|
|
|
36327
36482
|
commitTimestamp: result.position.liquidation.commitTimestamp,
|
|
36328
36483
|
revealDelay: result.position.liquidation.revealDelay
|
|
36329
36484
|
} : void 0;
|
|
36330
|
-
const mints = (result.
|
|
36485
|
+
const mints = (result.ucdmintEvents || []).map((m) => ({
|
|
36331
36486
|
id: m.id,
|
|
36332
36487
|
positionId,
|
|
36333
36488
|
amount: m.amount,
|
|
@@ -36931,12 +37086,6 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
36931
37086
|
* @param config - SDK configuration
|
|
36932
37087
|
*/
|
|
36933
37088
|
constructor(config) {
|
|
36934
|
-
console.log(
|
|
36935
|
-
"[DEBUG] Constructor START - config keys:",
|
|
36936
|
-
Object.keys(config),
|
|
36937
|
-
"serviceEndpoint:",
|
|
36938
|
-
config["serviceEndpoint"]
|
|
36939
|
-
);
|
|
36940
37089
|
if (!config.provider && config.ethRpcUrl) {
|
|
36941
37090
|
config.provider = new ethers_exports.providers.JsonRpcProvider(config.ethRpcUrl);
|
|
36942
37091
|
}
|
|
@@ -36947,12 +37096,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
36947
37096
|
network: config.litNetwork
|
|
36948
37097
|
});
|
|
36949
37098
|
}
|
|
36950
|
-
console.log("[DEBUG] Before CacheManager init");
|
|
36951
37099
|
this.cacheManager = new CacheManager({
|
|
36952
37100
|
debug: config.debug
|
|
36953
37101
|
});
|
|
36954
|
-
console.log("[DEBUG] After CacheManager init");
|
|
36955
|
-
console.log("[DEBUG] Before ContractManager init");
|
|
36956
37102
|
const contractManagerResult = createContractManager({
|
|
36957
37103
|
provider: config.provider,
|
|
36958
37104
|
signer: config.contractSigner,
|
|
@@ -37132,17 +37278,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37132
37278
|
*/
|
|
37133
37279
|
static async create(config) {
|
|
37134
37280
|
const userProvidedServiceEndpoint = config.serviceEndpoint;
|
|
37135
|
-
console.log(
|
|
37136
|
-
"[DEBUG] DiamondHandsSDK.create - userProvidedServiceEndpoint:",
|
|
37137
|
-
userProvidedServiceEndpoint
|
|
37138
|
-
);
|
|
37139
37281
|
const enrichedConfig = await _DiamondHandsSDK.enrichConfigWithNetworkDefaults(config);
|
|
37140
37282
|
if (userProvidedServiceEndpoint) {
|
|
37141
37283
|
enrichedConfig.serviceEndpoint = userProvidedServiceEndpoint;
|
|
37142
|
-
console.log(
|
|
37143
|
-
"[DEBUG] DiamondHandsSDK.create - restored userProvidedServiceEndpoint:",
|
|
37144
|
-
userProvidedServiceEndpoint
|
|
37145
|
-
);
|
|
37146
37284
|
}
|
|
37147
37285
|
const configError = validateSDKConfig(enrichedConfig);
|
|
37148
37286
|
if (configError) {
|
|
@@ -37182,10 +37320,6 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37182
37320
|
*/
|
|
37183
37321
|
static async enrichConfigWithNetworkDefaults(config) {
|
|
37184
37322
|
const { getNetworkConfig: getNetworkConfig2, getNetworkConfigByName: getNetworkConfigByName2 } = await Promise.resolve().then(() => (init_network_configs(), network_configs_exports));
|
|
37185
|
-
console.log(
|
|
37186
|
-
"[DEBUG] enrichConfigWithNetworkDefaults - input config.serviceEndpoint:",
|
|
37187
|
-
config.serviceEndpoint
|
|
37188
|
-
);
|
|
37189
37323
|
let chainId = config.chainId;
|
|
37190
37324
|
if (!chainId) {
|
|
37191
37325
|
try {
|
|
@@ -37270,9 +37404,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37270
37404
|
...config.contractAddresses || {}
|
|
37271
37405
|
// User-provided individual overrides (only specified fields)
|
|
37272
37406
|
};
|
|
37273
|
-
|
|
37274
|
-
"[SDK] enrichConfigWithNetworkDefaults - contractAddresses after merge",
|
|
37275
|
-
{
|
|
37407
|
+
if (config.debug) {
|
|
37408
|
+
log.info("[SDK] enrichConfigWithNetworkDefaults - contractAddresses after merge", {
|
|
37276
37409
|
keys: Object.keys(enrichedConfig.contractAddresses || {}),
|
|
37277
37410
|
hasPositionManager: !!enrichedConfig.contractAddresses?.positionManager,
|
|
37278
37411
|
hasLoanOperationsManager: !!enrichedConfig.contractAddresses?.loanOperationsManager,
|
|
@@ -37282,8 +37415,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37282
37415
|
loanOperationsManager: enrichedConfig.contractAddresses?.loanOperationsManager || "MISSING",
|
|
37283
37416
|
termManager: enrichedConfig.contractAddresses?.termManager || "MISSING",
|
|
37284
37417
|
ucdController: enrichedConfig.contractAddresses?.ucdController || "MISSING"
|
|
37285
|
-
}
|
|
37286
|
-
|
|
37418
|
+
});
|
|
37419
|
+
}
|
|
37287
37420
|
if (config.debug) {
|
|
37288
37421
|
log.info("\u2705 Contract addresses loaded from network config", {
|
|
37289
37422
|
overridden: Object.keys(config.contractAddresses || {}).length,
|
|
@@ -37302,10 +37435,6 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37302
37435
|
});
|
|
37303
37436
|
}
|
|
37304
37437
|
}
|
|
37305
|
-
console.log(
|
|
37306
|
-
"[DEBUG] enrichConfigWithNetworkDefaults - output config.serviceEndpoint:",
|
|
37307
|
-
enrichedConfig.serviceEndpoint
|
|
37308
|
-
);
|
|
37309
37438
|
if (!enrichedConfig.validators) {
|
|
37310
37439
|
enrichedConfig.validators = {
|
|
37311
37440
|
loanCreation: 1,
|
|
@@ -40797,11 +40926,13 @@ Error data: ${errorData || "none"}`
|
|
|
40797
40926
|
transactionHash: transactionHash || "none"
|
|
40798
40927
|
});
|
|
40799
40928
|
}
|
|
40800
|
-
|
|
40801
|
-
error:
|
|
40802
|
-
|
|
40803
|
-
|
|
40804
|
-
|
|
40929
|
+
if (this.config.debug) {
|
|
40930
|
+
log.error("\u274C PAYMENT ERROR:", {
|
|
40931
|
+
error: errorMsg,
|
|
40932
|
+
errorType: typeof error,
|
|
40933
|
+
transactionHash: transactionHash || "none"
|
|
40934
|
+
});
|
|
40935
|
+
}
|
|
40805
40936
|
if (this.config.debug) {
|
|
40806
40937
|
log.error("\u274C Payment failed", {
|
|
40807
40938
|
transactionHash: transactionHash || "not available",
|
|
@@ -43369,7 +43500,7 @@ export {
|
|
|
43369
43500
|
ErrorSeverity,
|
|
43370
43501
|
EventHelpers,
|
|
43371
43502
|
LOCALHOST_CONTRACTS,
|
|
43372
|
-
|
|
43503
|
+
LRUCache,
|
|
43373
43504
|
LoanCreator,
|
|
43374
43505
|
LoanQuery,
|
|
43375
43506
|
LoanStatus,
|