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