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