@gvnrdao/dh-sdk 0.0.219 → 0.0.221
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/dist/index.js +5 -24
- package/dist/index.js +1297 -1086
- package/dist/index.mjs +1297 -1086
- package/dist/interfaces/chunks/contract-types.i.d.ts +1 -1
- package/dist/modules/bitcoin/bitcoin-operations.module.d.ts +2 -10
- package/dist/modules/cache/cache-manager.module.d.ts +200 -41
- package/dist/modules/diamond-hands-sdk.d.ts +6 -5
- package/dist/modules/loan/loan-query.module.d.ts +1 -5
- package/dist/modules/pkp/pkp-manager.module.d.ts +1 -5
- package/dist/utils/mint-authorization.utils.d.ts +26 -10
- package/dist/utils/telegram-messaging.utils.d.ts +1 -1
- package/package.json +6 -6
- package/browser/dist/397.browser.js +0 -2
- package/browser/dist/397.browser.js.LICENSE.txt +0 -1
- package/browser/dist/833.browser.js +0 -2
- package/browser/dist/833.browser.js.LICENSE.txt +0 -1
- package/browser/dist/browser.js +0 -2
- package/browser/dist/browser.js.LICENSE.txt +0 -23
package/dist/index.mjs
CHANGED
|
@@ -12691,93 +12691,504 @@ var require_elliptic = __commonJS({
|
|
|
12691
12691
|
}
|
|
12692
12692
|
});
|
|
12693
12693
|
|
|
12694
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/
|
|
12695
|
-
var
|
|
12696
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/
|
|
12697
|
-
"use strict";
|
|
12698
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12699
|
-
}
|
|
12700
|
-
});
|
|
12701
|
-
|
|
12702
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/lit-action-config.i.js
|
|
12703
|
-
var require_lit_action_config_i = __commonJS({
|
|
12704
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/lit-action-config.i.js"(exports) {
|
|
12705
|
-
"use strict";
|
|
12706
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12707
|
-
}
|
|
12708
|
-
});
|
|
12709
|
-
|
|
12710
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.js
|
|
12711
|
-
var require_diamond_hands_lit_actions_i = __commonJS({
|
|
12712
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.js"(exports) {
|
|
12713
|
-
"use strict";
|
|
12714
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12715
|
-
}
|
|
12716
|
-
});
|
|
12717
|
-
|
|
12718
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/lit-action-registry.i.js
|
|
12719
|
-
var require_lit_action_registry_i = __commonJS({
|
|
12720
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/lit-action-registry.i.js"(exports) {
|
|
12721
|
-
"use strict";
|
|
12722
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12723
|
-
}
|
|
12724
|
-
});
|
|
12725
|
-
|
|
12726
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/index.js
|
|
12727
|
-
var require_interfaces = __commonJS({
|
|
12728
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/index.js"(exports) {
|
|
12694
|
+
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js
|
|
12695
|
+
var require_pkg_src = __commonJS({
|
|
12696
|
+
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js"(exports, module) {
|
|
12729
12697
|
"use strict";
|
|
12730
|
-
var
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
12738
|
-
|
|
12739
|
-
|
|
12740
|
-
}
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
|
|
12698
|
+
var __defProp2 = Object.defineProperty;
|
|
12699
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
12700
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
12701
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
12702
|
+
var __esm2 = (fn, res) => function __init() {
|
|
12703
|
+
return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
|
|
12704
|
+
};
|
|
12705
|
+
var __export2 = (target, all) => {
|
|
12706
|
+
for (var name in all)
|
|
12707
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
12708
|
+
};
|
|
12709
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
12710
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12711
|
+
for (let key2 of __getOwnPropNames2(from))
|
|
12712
|
+
if (!__hasOwnProp2.call(to, key2) && key2 !== except)
|
|
12713
|
+
__defProp2(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc2(from, key2)) || desc.enumerable });
|
|
12714
|
+
}
|
|
12715
|
+
return to;
|
|
12716
|
+
};
|
|
12717
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
12718
|
+
function configureDebugLogging(config) {
|
|
12719
|
+
debugConfig = { ...debugConfig, ...config };
|
|
12720
|
+
}
|
|
12721
|
+
function getTimestamp() {
|
|
12722
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
12723
|
+
}
|
|
12724
|
+
function formatMessage(level, component, message, metadata) {
|
|
12725
|
+
const timestamp = debugConfig.enableTimestamps ? `[${getTimestamp()}] ` : "";
|
|
12726
|
+
const metadataStr = metadata ? ` ${JSON.stringify(metadata)}` : "";
|
|
12727
|
+
return `${timestamp}[${level}] [${component}] ${message}${metadataStr}`;
|
|
12728
|
+
}
|
|
12729
|
+
function debugError(component, message, metadata) {
|
|
12730
|
+
if (debugConfig.level >= 0) {
|
|
12731
|
+
console.error(formatMessage("ERROR", component, message, metadata));
|
|
12732
|
+
}
|
|
12733
|
+
}
|
|
12734
|
+
function debugWarn(component, message, metadata) {
|
|
12735
|
+
if (debugConfig.level >= 1) {
|
|
12736
|
+
console.warn(formatMessage("WARN", component, message, metadata));
|
|
12737
|
+
}
|
|
12738
|
+
}
|
|
12739
|
+
function debugInfo(component, message, metadata) {
|
|
12740
|
+
if (debugConfig.level >= 2) {
|
|
12741
|
+
console.log(formatMessage("INFO", component, message, metadata));
|
|
12742
|
+
}
|
|
12743
|
+
}
|
|
12744
|
+
function debugLog(component, message, metadata) {
|
|
12745
|
+
if (debugConfig.level >= 3) {
|
|
12746
|
+
console.log(formatMessage("DEBUG", component, message, metadata));
|
|
12747
|
+
}
|
|
12748
|
+
}
|
|
12749
|
+
function debugTrace(component, message, metadata) {
|
|
12750
|
+
if (debugConfig.level >= 4) {
|
|
12751
|
+
console.log(formatMessage("TRACE", component, message, metadata));
|
|
12752
|
+
}
|
|
12753
|
+
}
|
|
12754
|
+
function logRequest(component, operation, params) {
|
|
12755
|
+
if (!debugConfig.enableRequestLogging)
|
|
12756
|
+
return;
|
|
12757
|
+
debugLog(component, `\u{1F504} Request: ${operation}`, {
|
|
12758
|
+
operation,
|
|
12759
|
+
params: JSON.stringify(params, null, 2)
|
|
12760
|
+
});
|
|
12761
|
+
}
|
|
12762
|
+
function logResponse(component, operation, response, duration) {
|
|
12763
|
+
if (!debugConfig.enableRequestLogging)
|
|
12764
|
+
return;
|
|
12765
|
+
debugLog(component, `\u2705 Response: ${operation} (${duration}ms)`, {
|
|
12766
|
+
operation,
|
|
12767
|
+
duration,
|
|
12768
|
+
response: typeof response === "object" ? JSON.stringify(response, null, 2) : response
|
|
12769
|
+
});
|
|
12770
|
+
}
|
|
12771
|
+
function logError(component, operation, error, duration) {
|
|
12772
|
+
const durationStr = duration ? ` (${duration}ms)` : "";
|
|
12773
|
+
debugError(component, `\u274C Error: ${operation}${durationStr}`, {
|
|
12774
|
+
operation,
|
|
12775
|
+
duration,
|
|
12776
|
+
error: error?.message || error?.toString() || "Unknown error",
|
|
12777
|
+
stack: error?.stack
|
|
12778
|
+
});
|
|
12779
|
+
}
|
|
12780
|
+
function logConnectionAttempt(network, attempt, maxAttempts) {
|
|
12781
|
+
debugInfo("CONNECTION", `\u{1F517} Connecting to ${network} (attempt ${attempt}/${maxAttempts})`);
|
|
12782
|
+
}
|
|
12783
|
+
function logConnectionSuccess(network, latency) {
|
|
12784
|
+
debugInfo("CONNECTION", `\u2705 Connected to ${network} (${latency}ms)`);
|
|
12785
|
+
networkMetrics.recordRequest(`connection-${network}`, true, latency);
|
|
12786
|
+
}
|
|
12787
|
+
function logConnectionFailure(network, error, attempt) {
|
|
12788
|
+
debugError("CONNECTION", `\u274C Connection failed to ${network} (attempt ${attempt})`, { error });
|
|
12789
|
+
networkMetrics.recordRequest(`connection-${network}`, false, 0, error);
|
|
12790
|
+
}
|
|
12791
|
+
function logPkpOperation(operation, pkpId, details) {
|
|
12792
|
+
const pkpStr = pkpId ? ` (PKP: ${pkpId.slice(0, 8)}...)` : "";
|
|
12793
|
+
debugInfo("PKP", `\u{1F511} ${operation}${pkpStr}`, details);
|
|
12794
|
+
}
|
|
12795
|
+
function logSessionSignatures(count, expiration) {
|
|
12796
|
+
debugInfo("SESSION", `\u{1F510} Generated ${count} session signatures (expires: ${expiration})`);
|
|
12797
|
+
}
|
|
12798
|
+
function logLitActionExecution(cid, params) {
|
|
12799
|
+
debugInfo("LIT_ACTION", `\u26A1 Executing LIT Action: ${cid}`, {
|
|
12800
|
+
cid,
|
|
12801
|
+
params
|
|
12802
|
+
});
|
|
12803
|
+
}
|
|
12804
|
+
function logLitActionResult(cid, success2, duration, result) {
|
|
12805
|
+
const status = success2 ? "\u2705" : "\u274C";
|
|
12806
|
+
debugInfo("LIT_ACTION", `${status} LIT Action completed: ${cid} (${duration}ms)`, {
|
|
12807
|
+
cid,
|
|
12808
|
+
success: success2,
|
|
12809
|
+
duration,
|
|
12810
|
+
result: success2 && result ? JSON.stringify(result, null, 2) : void 0
|
|
12811
|
+
});
|
|
12812
|
+
}
|
|
12813
|
+
function logTestStart(testName) {
|
|
12814
|
+
debugInfo("TEST", `\u{1F9EA} Starting test: ${testName}`);
|
|
12815
|
+
return new PerformanceTracker(testName);
|
|
12816
|
+
}
|
|
12817
|
+
function logTestEnd(testName, success2, duration) {
|
|
12818
|
+
const status = success2 ? "\u2705" : "\u274C";
|
|
12819
|
+
debugInfo("TEST", `${status} Test completed: ${testName} (${duration}ms)`);
|
|
12820
|
+
networkMetrics.printSummary();
|
|
12821
|
+
}
|
|
12822
|
+
var LogLevel2;
|
|
12823
|
+
var DEFAULT_DEBUG_CONFIG;
|
|
12824
|
+
var debugConfig;
|
|
12825
|
+
var PerformanceTracker;
|
|
12826
|
+
var NetworkMetricsCollector;
|
|
12827
|
+
var networkMetrics;
|
|
12828
|
+
var init_debug_logger = __esm2({
|
|
12829
|
+
"pkg-src/utils/chunks/debug-logger.ts"() {
|
|
12830
|
+
"use strict";
|
|
12831
|
+
LogLevel2 = /* @__PURE__ */ ((LogLevel22) => {
|
|
12832
|
+
LogLevel22[LogLevel22["ERROR"] = 0] = "ERROR";
|
|
12833
|
+
LogLevel22[LogLevel22["WARN"] = 1] = "WARN";
|
|
12834
|
+
LogLevel22[LogLevel22["INFO"] = 2] = "INFO";
|
|
12835
|
+
LogLevel22[LogLevel22["DEBUG"] = 3] = "DEBUG";
|
|
12836
|
+
LogLevel22[LogLevel22["TRACE"] = 4] = "TRACE";
|
|
12837
|
+
return LogLevel22;
|
|
12838
|
+
})(LogLevel2 || {});
|
|
12839
|
+
DEFAULT_DEBUG_CONFIG = {
|
|
12840
|
+
level: 2,
|
|
12841
|
+
enableTimestamps: true,
|
|
12842
|
+
enablePerformanceMetrics: true,
|
|
12843
|
+
enableRequestLogging: true,
|
|
12844
|
+
enableNetworkMetrics: true
|
|
12845
|
+
};
|
|
12846
|
+
debugConfig = { ...DEFAULT_DEBUG_CONFIG };
|
|
12847
|
+
PerformanceTracker = class {
|
|
12848
|
+
constructor(operationName) {
|
|
12849
|
+
this.operationName = operationName;
|
|
12850
|
+
this.markers = /* @__PURE__ */ new Map();
|
|
12851
|
+
this.startTime = Date.now();
|
|
12852
|
+
this.log("PERF", `Started: ${operationName}`);
|
|
12853
|
+
}
|
|
12854
|
+
mark(label) {
|
|
12855
|
+
const elapsed = Date.now() - this.startTime;
|
|
12856
|
+
this.markers.set(label, elapsed);
|
|
12857
|
+
this.log("PERF", `${this.operationName} - ${label}: ${elapsed}ms`);
|
|
12858
|
+
}
|
|
12859
|
+
end(success2 = true) {
|
|
12860
|
+
const totalTime = Date.now() - this.startTime;
|
|
12861
|
+
const status = success2 ? "SUCCESS" : "FAILED";
|
|
12862
|
+
this.log("PERF", `${this.operationName} - ${status}: ${totalTime}ms`);
|
|
12863
|
+
if (debugConfig.enablePerformanceMetrics && this.markers.size > 0) {
|
|
12864
|
+
console.log(`\u{1F4CA} Performance Breakdown for ${this.operationName}:`);
|
|
12865
|
+
for (const [label, time] of this.markers) {
|
|
12866
|
+
console.log(` ${label}: ${time}ms`);
|
|
12867
|
+
}
|
|
12868
|
+
console.log(` Total: ${totalTime}ms`);
|
|
12869
|
+
}
|
|
12870
|
+
return totalTime;
|
|
12871
|
+
}
|
|
12872
|
+
log(level, message) {
|
|
12873
|
+
if (debugConfig.enablePerformanceMetrics) {
|
|
12874
|
+
console.log(formatMessage(level, "PERFORMANCE", message));
|
|
12875
|
+
}
|
|
12876
|
+
}
|
|
12877
|
+
};
|
|
12878
|
+
NetworkMetricsCollector = class {
|
|
12879
|
+
constructor() {
|
|
12880
|
+
this.metrics = /* @__PURE__ */ new Map();
|
|
12881
|
+
}
|
|
12882
|
+
getMetrics(operation) {
|
|
12883
|
+
if (!this.metrics.has(operation)) {
|
|
12884
|
+
this.metrics.set(operation, {
|
|
12885
|
+
requestCount: 0,
|
|
12886
|
+
successCount: 0,
|
|
12887
|
+
failureCount: 0,
|
|
12888
|
+
averageLatency: 0,
|
|
12889
|
+
startTime: Date.now()
|
|
12890
|
+
});
|
|
12891
|
+
}
|
|
12892
|
+
return this.metrics.get(operation);
|
|
12893
|
+
}
|
|
12894
|
+
recordRequest(operation, success2, latency, error) {
|
|
12895
|
+
const metrics = this.getMetrics(operation);
|
|
12896
|
+
metrics.requestCount++;
|
|
12897
|
+
if (success2) {
|
|
12898
|
+
metrics.successCount++;
|
|
12899
|
+
metrics.averageLatency = (metrics.averageLatency * (metrics.successCount - 1) + latency) / metrics.successCount;
|
|
12900
|
+
} else {
|
|
12901
|
+
metrics.failureCount++;
|
|
12902
|
+
if (error)
|
|
12903
|
+
metrics.lastError = error;
|
|
12904
|
+
}
|
|
12905
|
+
if (debugConfig.enableNetworkMetrics) {
|
|
12906
|
+
const successRate = (metrics.successCount / metrics.requestCount * 100).toFixed(1);
|
|
12907
|
+
debugLog("NETWORK", `${operation} - Success: ${success2}, Latency: ${latency}ms, Success Rate: ${successRate}%`);
|
|
12908
|
+
}
|
|
12909
|
+
}
|
|
12910
|
+
printSummary() {
|
|
12911
|
+
if (!debugConfig.enableNetworkMetrics)
|
|
12912
|
+
return;
|
|
12913
|
+
console.log("\n\u{1F4C8} Network Metrics Summary:");
|
|
12914
|
+
for (const [operation, metrics] of this.metrics) {
|
|
12915
|
+
const successRate = (metrics.successCount / metrics.requestCount * 100).toFixed(1);
|
|
12916
|
+
const runtime = Date.now() - metrics.startTime;
|
|
12917
|
+
console.log(` ${operation}:`);
|
|
12918
|
+
console.log(` Requests: ${metrics.requestCount}`);
|
|
12919
|
+
console.log(` Success Rate: ${successRate}%`);
|
|
12920
|
+
console.log(` Avg Latency: ${metrics.averageLatency.toFixed(0)}ms`);
|
|
12921
|
+
console.log(` Runtime: ${runtime}ms`);
|
|
12922
|
+
if (metrics.lastError) {
|
|
12923
|
+
console.log(` Last Error: ${metrics.lastError}`);
|
|
12924
|
+
}
|
|
12925
|
+
}
|
|
12926
|
+
}
|
|
12927
|
+
};
|
|
12928
|
+
networkMetrics = new NetworkMetricsCollector();
|
|
12929
|
+
}
|
|
12744
12930
|
});
|
|
12745
|
-
var
|
|
12746
|
-
|
|
12747
|
-
|
|
12748
|
-
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12931
|
+
var session_signature_cache_exports = {};
|
|
12932
|
+
__export2(session_signature_cache_exports, {
|
|
12933
|
+
DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
|
|
12934
|
+
clearSessionSignatureCache: () => clearSessionSignatureCache,
|
|
12935
|
+
configureSessionSignatureCache: () => configureSessionSignatureCache,
|
|
12936
|
+
generateSessionSignaturesWithCache: () => generateSessionSignaturesWithCache,
|
|
12937
|
+
getSessionSignatureCacheStats: () => getSessionSignatureCacheStats,
|
|
12938
|
+
sessionSignatureCache: () => sessionSignatureCache
|
|
12939
|
+
});
|
|
12940
|
+
async function generateSessionSignaturesWithCache(litNodeClient, sessionConfig, pkpTokenId, litActionCid, signerAddress, network = "chipotle") {
|
|
12941
|
+
const cached = sessionSignatureCache.get(pkpTokenId, litActionCid, signerAddress, network);
|
|
12942
|
+
if (cached) {
|
|
12943
|
+
return cached;
|
|
12944
|
+
}
|
|
12945
|
+
debugInfo("CACHE", "\u{1F510} Generating new session signatures (cache miss)...");
|
|
12946
|
+
const sessionSigs = await litNodeClient.getSessionSigs(sessionConfig);
|
|
12947
|
+
const expiration = new Date(sessionConfig.expiration);
|
|
12948
|
+
sessionSignatureCache.set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration);
|
|
12949
|
+
const sigCount = Object.keys(sessionSigs).length;
|
|
12950
|
+
debugInfo("CACHE", `\u2705 Generated and cached ${sigCount} session signatures`);
|
|
12951
|
+
return sessionSigs;
|
|
12952
|
+
}
|
|
12953
|
+
function configureSessionSignatureCache(config) {
|
|
12954
|
+
Object.assign(sessionSignatureCache["config"], config);
|
|
12955
|
+
}
|
|
12956
|
+
function clearSessionSignatureCache() {
|
|
12957
|
+
sessionSignatureCache.clear();
|
|
12958
|
+
}
|
|
12959
|
+
function getSessionSignatureCacheStats() {
|
|
12960
|
+
return sessionSignatureCache.getStats();
|
|
12961
|
+
}
|
|
12962
|
+
var DEFAULT_CACHE_CONFIG;
|
|
12963
|
+
var SessionSignatureCache;
|
|
12964
|
+
var sessionSignatureCache;
|
|
12965
|
+
var init_session_signature_cache = __esm2({
|
|
12966
|
+
"pkg-src/utils/chunks/session-signature-cache.ts"() {
|
|
12967
|
+
"use strict";
|
|
12968
|
+
init_debug_logger();
|
|
12969
|
+
DEFAULT_CACHE_CONFIG = {
|
|
12970
|
+
maxEntries: 50,
|
|
12971
|
+
bufferTimeMs: 6e4,
|
|
12972
|
+
// 1 minute buffer before expiration
|
|
12973
|
+
enableLogging: true
|
|
12974
|
+
};
|
|
12975
|
+
SessionSignatureCache = class {
|
|
12976
|
+
constructor(config = {}) {
|
|
12977
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
12978
|
+
this.config = { ...DEFAULT_CACHE_CONFIG, ...config };
|
|
12979
|
+
}
|
|
12980
|
+
/**
|
|
12981
|
+
* Generate cache key from PKP and context
|
|
12982
|
+
*/
|
|
12983
|
+
generateCacheKey(pkpTokenId, litActionCid, signerAddress, network) {
|
|
12984
|
+
return `${signerAddress}-${network}-${pkpTokenId}-${litActionCid}`;
|
|
12985
|
+
}
|
|
12986
|
+
/**
|
|
12987
|
+
* Check if cache entry is still valid
|
|
12988
|
+
*/
|
|
12989
|
+
isEntryValid(entry) {
|
|
12990
|
+
const now2 = /* @__PURE__ */ new Date();
|
|
12991
|
+
const expirationWithBuffer = new Date(
|
|
12992
|
+
entry.expiration.getTime() - this.config.bufferTimeMs
|
|
12993
|
+
);
|
|
12994
|
+
return now2 < expirationWithBuffer;
|
|
12995
|
+
}
|
|
12996
|
+
/**
|
|
12997
|
+
* Clean expired entries from cache
|
|
12998
|
+
*/
|
|
12999
|
+
cleanExpiredEntries() {
|
|
13000
|
+
const now2 = /* @__PURE__ */ new Date();
|
|
13001
|
+
let cleanedCount = 0;
|
|
13002
|
+
for (const [key2, entry] of this.cache.entries()) {
|
|
13003
|
+
if (now2 >= entry.expiration) {
|
|
13004
|
+
this.cache.delete(key2);
|
|
13005
|
+
cleanedCount++;
|
|
13006
|
+
}
|
|
13007
|
+
}
|
|
13008
|
+
if (cleanedCount > 0 && this.config.enableLogging) {
|
|
13009
|
+
debugInfo("CACHE", `\u{1F9F9} Cleaned ${cleanedCount} expired session signature entries`);
|
|
13010
|
+
}
|
|
13011
|
+
}
|
|
13012
|
+
/**
|
|
13013
|
+
* Enforce cache size limits
|
|
13014
|
+
*/
|
|
13015
|
+
enforceCacheSize() {
|
|
13016
|
+
if (this.cache.size <= this.config.maxEntries) {
|
|
13017
|
+
return;
|
|
13018
|
+
}
|
|
13019
|
+
const entries = Array.from(this.cache.entries()).sort(([, a], [, b]) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
13020
|
+
const toRemove = entries.slice(0, this.cache.size - this.config.maxEntries);
|
|
13021
|
+
for (const [key2] of toRemove) {
|
|
13022
|
+
this.cache.delete(key2);
|
|
13023
|
+
}
|
|
13024
|
+
if (this.config.enableLogging) {
|
|
13025
|
+
debugInfo("CACHE", `\u{1F4E6} Removed ${toRemove.length} oldest cache entries to maintain size limit`);
|
|
13026
|
+
}
|
|
13027
|
+
}
|
|
13028
|
+
/**
|
|
13029
|
+
* Get cached session signatures if valid
|
|
13030
|
+
*/
|
|
13031
|
+
get(pkpTokenId, litActionCid, signerAddress, network) {
|
|
13032
|
+
this.cleanExpiredEntries();
|
|
13033
|
+
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13034
|
+
const entry = this.cache.get(cacheKey);
|
|
13035
|
+
if (!entry) {
|
|
13036
|
+
if (this.config.enableLogging) {
|
|
13037
|
+
debugLog("CACHE", `\u274C Session signatures cache miss: ${cacheKey}`);
|
|
13038
|
+
}
|
|
13039
|
+
return null;
|
|
13040
|
+
}
|
|
13041
|
+
if (!this.isEntryValid(entry)) {
|
|
13042
|
+
this.cache.delete(cacheKey);
|
|
13043
|
+
if (this.config.enableLogging) {
|
|
13044
|
+
debugWarn("CACHE", `\u23F0 Session signatures expired: ${cacheKey}`);
|
|
13045
|
+
}
|
|
13046
|
+
return null;
|
|
13047
|
+
}
|
|
13048
|
+
if (this.config.enableLogging) {
|
|
13049
|
+
const timeUntilExpiry = entry.expiration.getTime() - Date.now();
|
|
13050
|
+
debugInfo("CACHE", `\u2705 Session signatures cache hit: ${cacheKey} (expires in ${Math.round(timeUntilExpiry / 1e3)}s)`);
|
|
13051
|
+
}
|
|
13052
|
+
return entry.sessionSigs;
|
|
13053
|
+
}
|
|
13054
|
+
/**
|
|
13055
|
+
* Cache session signatures
|
|
13056
|
+
*/
|
|
13057
|
+
set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration) {
|
|
13058
|
+
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13059
|
+
const entry = {
|
|
13060
|
+
sessionSigs,
|
|
13061
|
+
expiration,
|
|
13062
|
+
pkpTokenId,
|
|
13063
|
+
litActionCid,
|
|
13064
|
+
signerAddress,
|
|
13065
|
+
network,
|
|
13066
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
13067
|
+
};
|
|
13068
|
+
this.cache.set(cacheKey, entry);
|
|
13069
|
+
if (this.config.enableLogging) {
|
|
13070
|
+
const timeUntilExpiry = expiration.getTime() - Date.now();
|
|
13071
|
+
debugInfo("CACHE", `\u{1F4BE} Cached session signatures: ${cacheKey} (expires in ${Math.round(timeUntilExpiry / 1e3)}s)`);
|
|
13072
|
+
}
|
|
13073
|
+
this.enforceCacheSize();
|
|
13074
|
+
}
|
|
13075
|
+
/**
|
|
13076
|
+
* Clear all cached session signatures
|
|
13077
|
+
*/
|
|
13078
|
+
clear() {
|
|
13079
|
+
const size = this.cache.size;
|
|
13080
|
+
this.cache.clear();
|
|
13081
|
+
if (this.config.enableLogging) {
|
|
13082
|
+
debugInfo("CACHE", `\u{1F5D1}\uFE0F Cleared ${size} cached session signature entries`);
|
|
13083
|
+
}
|
|
13084
|
+
}
|
|
13085
|
+
/**
|
|
13086
|
+
* Get cache statistics
|
|
13087
|
+
*/
|
|
13088
|
+
getStats() {
|
|
13089
|
+
this.cleanExpiredEntries();
|
|
13090
|
+
return {
|
|
13091
|
+
size: this.cache.size,
|
|
13092
|
+
maxEntries: this.config.maxEntries,
|
|
13093
|
+
utilizationPercent: Math.round(this.cache.size / this.config.maxEntries * 100)
|
|
13094
|
+
};
|
|
13095
|
+
}
|
|
13096
|
+
/**
|
|
13097
|
+
* Remove specific cache entry
|
|
13098
|
+
*/
|
|
13099
|
+
delete(pkpTokenId, litActionCid, signerAddress, network) {
|
|
13100
|
+
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13101
|
+
const deleted = this.cache.delete(cacheKey);
|
|
13102
|
+
if (deleted && this.config.enableLogging) {
|
|
13103
|
+
debugInfo("CACHE", `\u{1F5D1}\uFE0F Removed session signatures from cache: ${cacheKey}`);
|
|
13104
|
+
}
|
|
13105
|
+
return deleted;
|
|
13106
|
+
}
|
|
13107
|
+
};
|
|
13108
|
+
sessionSignatureCache = new SessionSignatureCache();
|
|
13109
|
+
}
|
|
13110
|
+
});
|
|
13111
|
+
var index_exports = {};
|
|
13112
|
+
__export2(index_exports, {
|
|
13113
|
+
CHIPOTLE_DEPLOYMENTS: () => CHIPOTLE_DEPLOYMENTS,
|
|
13114
|
+
DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
|
|
13115
|
+
DEFAULT_DEBUG_CONFIG: () => DEFAULT_DEBUG_CONFIG,
|
|
13116
|
+
DEFAULT_RETRY_CONFIG: () => DEFAULT_RETRY_CONFIG,
|
|
13117
|
+
DH_LIT_ACTIONS_CHIPOTLE: () => DH_LIT_ACTIONS_CHIPOTLE3,
|
|
13118
|
+
ErrorCategory: () => ErrorCategory2,
|
|
13119
|
+
LogLevel: () => LogLevel2,
|
|
13120
|
+
NETWORK_TIMEOUTS: () => NETWORK_TIMEOUTS,
|
|
13121
|
+
PerformanceTracker: () => PerformanceTracker,
|
|
13122
|
+
RetryStrategy: () => RetryStrategy,
|
|
13123
|
+
analyzeError: () => analyzeError,
|
|
13124
|
+
calculateDelay: () => calculateDelay,
|
|
13125
|
+
cidToHex: () => cidToHex,
|
|
13126
|
+
classifyError: () => classifyError,
|
|
13127
|
+
clearSessionSignatureCache: () => clearSessionSignatureCache,
|
|
13128
|
+
configureDebugLogging: () => configureDebugLogging,
|
|
13129
|
+
configureSessionSignatureCache: () => configureSessionSignatureCache,
|
|
13130
|
+
connectLitContracts: () => connectLitContracts,
|
|
13131
|
+
connectLitNodeClient: () => connectLitNodeClient,
|
|
13132
|
+
createErrorReport: () => createErrorReport,
|
|
13133
|
+
debugError: () => debugError,
|
|
13134
|
+
debugInfo: () => debugInfo,
|
|
13135
|
+
debugLog: () => debugLog,
|
|
13136
|
+
debugTrace: () => debugTrace,
|
|
13137
|
+
debugWarn: () => debugWarn,
|
|
13138
|
+
executeLitAction: () => executeLitAction,
|
|
13139
|
+
executePkpOperation: () => executePkpOperation,
|
|
13140
|
+
generateSessionSignatures: () => generateSessionSignatures,
|
|
13141
|
+
generateSessionSignaturesWithCache: () => generateSessionSignaturesWithCache,
|
|
13142
|
+
getDeployedActions: () => getDeployedActions,
|
|
13143
|
+
getDeploymentsForNetwork: () => getDeploymentsForNetwork,
|
|
13144
|
+
getLitActionCID: () => getLitActionCID,
|
|
13145
|
+
getLitActionConfig: () => getLitActionConfig,
|
|
13146
|
+
getNetworkTimeouts: () => getNetworkTimeouts,
|
|
13147
|
+
getPKPValidatorSetup: () => getPKPValidatorSetup,
|
|
13148
|
+
getRetryConfigFromClassification: () => getRetryConfigFromClassification,
|
|
13149
|
+
getSessionSignatureCacheStats: () => getSessionSignatureCacheStats,
|
|
13150
|
+
isLitActionDeployed: () => isLitActionDeployed,
|
|
13151
|
+
isRetryableError: () => isRetryableError,
|
|
13152
|
+
litProtocolErrors: () => litProtocolErrors,
|
|
13153
|
+
logConnectionAttempt: () => logConnectionAttempt,
|
|
13154
|
+
logConnectionFailure: () => logConnectionFailure,
|
|
13155
|
+
logConnectionSuccess: () => logConnectionSuccess,
|
|
13156
|
+
logError: () => logError,
|
|
13157
|
+
logLitActionExecution: () => logLitActionExecution,
|
|
13158
|
+
logLitActionResult: () => logLitActionResult,
|
|
13159
|
+
logPkpOperation: () => logPkpOperation,
|
|
13160
|
+
logRequest: () => logRequest,
|
|
13161
|
+
logResponse: () => logResponse,
|
|
13162
|
+
logSessionSignatures: () => logSessionSignatures,
|
|
13163
|
+
logTestEnd: () => logTestEnd,
|
|
13164
|
+
logTestStart: () => logTestStart,
|
|
13165
|
+
networkMetrics: () => networkMetrics,
|
|
13166
|
+
sessionSignatureCache: () => sessionSignatureCache,
|
|
13167
|
+
sleep: () => sleep,
|
|
13168
|
+
validateDeployedActions: () => validateDeployedActions,
|
|
13169
|
+
validateLitNodeConnection: () => validateLitNodeConnection,
|
|
13170
|
+
validateLitNodeReadiness: () => validateLitNodeReadiness,
|
|
13171
|
+
withRetry: () => withRetry
|
|
13172
|
+
});
|
|
13173
|
+
module.exports = __toCommonJS2(index_exports);
|
|
13174
|
+
function base2(ALPHABET2) {
|
|
13175
|
+
if (ALPHABET2.length >= 255) {
|
|
12765
13176
|
throw new TypeError("Alphabet too long");
|
|
12766
13177
|
}
|
|
12767
13178
|
const BASE_MAP = new Uint8Array(256);
|
|
12768
13179
|
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
12769
13180
|
BASE_MAP[j] = 255;
|
|
12770
13181
|
}
|
|
12771
|
-
for (let i = 0; i <
|
|
12772
|
-
const x =
|
|
13182
|
+
for (let i = 0; i < ALPHABET2.length; i++) {
|
|
13183
|
+
const x = ALPHABET2.charAt(i);
|
|
12773
13184
|
const xc = x.charCodeAt(0);
|
|
12774
13185
|
if (BASE_MAP[xc] !== 255) {
|
|
12775
13186
|
throw new TypeError(x + " is ambiguous");
|
|
12776
13187
|
}
|
|
12777
13188
|
BASE_MAP[xc] = i;
|
|
12778
13189
|
}
|
|
12779
|
-
const BASE =
|
|
12780
|
-
const LEADER =
|
|
13190
|
+
const BASE = ALPHABET2.length;
|
|
13191
|
+
const LEADER = ALPHABET2.charAt(0);
|
|
12781
13192
|
const FACTOR = Math.log(BASE) / Math.log(256);
|
|
12782
13193
|
const iFACTOR = Math.log(256) / Math.log(BASE);
|
|
12783
13194
|
function encode4(source) {
|
|
@@ -12823,7 +13234,7 @@ var require_cjs = __commonJS({
|
|
|
12823
13234
|
}
|
|
12824
13235
|
let str = LEADER.repeat(zeroes);
|
|
12825
13236
|
for (; it2 < size; ++it2) {
|
|
12826
|
-
str +=
|
|
13237
|
+
str += ALPHABET2.charAt(b58[it2]);
|
|
12827
13238
|
}
|
|
12828
13239
|
return str;
|
|
12829
13240
|
}
|
|
@@ -12888,38 +13299,13 @@ var require_cjs = __commonJS({
|
|
|
12888
13299
|
decode: decode3
|
|
12889
13300
|
};
|
|
12890
13301
|
}
|
|
12891
|
-
|
|
12892
|
-
}
|
|
12893
|
-
});
|
|
12894
|
-
|
|
12895
|
-
// node_modules/bs58/src/cjs/index.cjs
|
|
12896
|
-
var require_cjs2 = __commonJS({
|
|
12897
|
-
"node_modules/bs58/src/cjs/index.cjs"(exports) {
|
|
12898
|
-
"use strict";
|
|
12899
|
-
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
12900
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
12901
|
-
};
|
|
12902
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12903
|
-
var base_x_1 = __importDefault(require_cjs());
|
|
13302
|
+
var esm_default = base2;
|
|
12904
13303
|
var ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
12905
|
-
|
|
12906
|
-
}
|
|
12907
|
-
});
|
|
12908
|
-
|
|
12909
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/cid-utils.js
|
|
12910
|
-
var require_cid_utils = __commonJS({
|
|
12911
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/cid-utils.js"(exports) {
|
|
12912
|
-
"use strict";
|
|
12913
|
-
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
12914
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
12915
|
-
};
|
|
12916
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12917
|
-
exports.cidToHex = cidToHex;
|
|
12918
|
-
var bs58_1 = __importDefault(require_cjs2());
|
|
13304
|
+
var esm_default2 = esm_default(ALPHABET);
|
|
12919
13305
|
function cidToHex(cid) {
|
|
12920
13306
|
try {
|
|
12921
13307
|
if (cid.startsWith("Qm")) {
|
|
12922
|
-
const bytes =
|
|
13308
|
+
const bytes = esm_default2.decode(cid);
|
|
12923
13309
|
return "0x" + Buffer.from(bytes).toString("hex");
|
|
12924
13310
|
} else if (cid.startsWith("0x")) {
|
|
12925
13311
|
return cid;
|
|
@@ -12933,21 +13319,12 @@ var require_cid_utils = __commonJS({
|
|
|
12933
13319
|
throw new Error(`Failed to convert CID ${cid} to hex: ${error instanceof Error ? error.message : String(error)}`);
|
|
12934
13320
|
}
|
|
12935
13321
|
}
|
|
12936
|
-
|
|
12937
|
-
});
|
|
12938
|
-
|
|
12939
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.js
|
|
12940
|
-
var require_lit_actions_registry = __commonJS({
|
|
12941
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.js"(exports) {
|
|
12942
|
-
"use strict";
|
|
12943
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12944
|
-
exports.CHIPOTLE_DEPLOYMENTS = exports.DH_LIT_ACTIONS_CHIPOTLE = void 0;
|
|
12945
|
-
exports.getDeploymentsForNetwork = getDeploymentsForNetwork;
|
|
12946
|
-
var cid_utils_1 = require_cid_utils();
|
|
12947
|
-
exports.DH_LIT_ACTIONS_CHIPOTLE = {
|
|
13322
|
+
var DH_LIT_ACTIONS_CHIPOTLE3 = {
|
|
12948
13323
|
authorizationDummy: {
|
|
12949
13324
|
cid: "QmXPh5RTReLqjqZDRNhgVKi1TWMJK2vS9QSRPkWPhLBQJN",
|
|
12950
|
-
authorizedCidHex:
|
|
13325
|
+
authorizedCidHex: cidToHex(
|
|
13326
|
+
"QmXPh5RTReLqjqZDRNhgVKi1TWMJK2vS9QSRPkWPhLBQJN"
|
|
13327
|
+
),
|
|
12951
13328
|
name: "Authorization Dummy",
|
|
12952
13329
|
description: "Production Authorization Dummy",
|
|
12953
13330
|
version: "1.0.0",
|
|
@@ -12958,7 +13335,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
12958
13335
|
},
|
|
12959
13336
|
authorizationDummyB: {
|
|
12960
13337
|
cid: "QmQXTcAU9tr4YAVrzHujEJw9moJgM1o5gnJU2ojcvhigua",
|
|
12961
|
-
authorizedCidHex:
|
|
13338
|
+
authorizedCidHex: cidToHex(
|
|
13339
|
+
"QmQXTcAU9tr4YAVrzHujEJw9moJgM1o5gnJU2ojcvhigua"
|
|
13340
|
+
),
|
|
12962
13341
|
name: "Authorization Dummy B",
|
|
12963
13342
|
description: "Production Authorization Dummy B",
|
|
12964
13343
|
version: "1.0.0",
|
|
@@ -12969,7 +13348,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
12969
13348
|
},
|
|
12970
13349
|
pkpValidator: {
|
|
12971
13350
|
cid: "QmTqsmXkjib7CRGFcEhmCs61Z3EZTaRPznaZDDLk5Wq9NX",
|
|
12972
|
-
authorizedCidHex:
|
|
13351
|
+
authorizedCidHex: cidToHex(
|
|
13352
|
+
"QmTqsmXkjib7CRGFcEhmCs61Z3EZTaRPznaZDDLk5Wq9NX"
|
|
13353
|
+
),
|
|
12973
13354
|
name: "Pkp Validator",
|
|
12974
13355
|
description: "Production Pkp Validator",
|
|
12975
13356
|
version: "1.0.0",
|
|
@@ -12985,7 +13366,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
12985
13366
|
},
|
|
12986
13367
|
btcTransactionSigner: {
|
|
12987
13368
|
cid: "QmYSvuDcn2EPjRoDsPBLK2e3PGYEUHtWAPxwB51s4unkaG",
|
|
12988
|
-
authorizedCidHex:
|
|
13369
|
+
authorizedCidHex: cidToHex(
|
|
13370
|
+
"QmYSvuDcn2EPjRoDsPBLK2e3PGYEUHtWAPxwB51s4unkaG"
|
|
13371
|
+
),
|
|
12989
13372
|
name: "Btc Transaction Signer",
|
|
12990
13373
|
description: "Production Btc Transaction Signer",
|
|
12991
13374
|
version: "1.0.0",
|
|
@@ -12996,7 +13379,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
12996
13379
|
},
|
|
12997
13380
|
ucdMintValidator: {
|
|
12998
13381
|
cid: "QmbYWJkLBdxTCNUkYTVmBzcp4CFhAn7ZcCyMZjhhbjAUMB",
|
|
12999
|
-
authorizedCidHex:
|
|
13382
|
+
authorizedCidHex: cidToHex(
|
|
13383
|
+
"QmbYWJkLBdxTCNUkYTVmBzcp4CFhAn7ZcCyMZjhhbjAUMB"
|
|
13384
|
+
),
|
|
13000
13385
|
name: "Ucd Mint Validator",
|
|
13001
13386
|
description: "Production Ucd Mint Validator",
|
|
13002
13387
|
version: "1.0.0",
|
|
@@ -13012,7 +13397,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13012
13397
|
},
|
|
13013
13398
|
processPaymentValidator: {
|
|
13014
13399
|
cid: "Qmc9gkDVY1SK9vvyQ9cXa3PSSuv8q6Ki9o9rsG87qpXCYi",
|
|
13015
|
-
authorizedCidHex:
|
|
13400
|
+
authorizedCidHex: cidToHex(
|
|
13401
|
+
"Qmc9gkDVY1SK9vvyQ9cXa3PSSuv8q6Ki9o9rsG87qpXCYi"
|
|
13402
|
+
),
|
|
13016
13403
|
name: "Process Payment Validator",
|
|
13017
13404
|
description: "Production Process Payment Validator",
|
|
13018
13405
|
version: "1.0.0",
|
|
@@ -13028,7 +13415,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13028
13415
|
},
|
|
13029
13416
|
extendPositionValidator: {
|
|
13030
13417
|
cid: "Qmc5MDW6ZxTRe3nXJEKa5KKUCVXFznV9vDqFL4n7ayRZ4p",
|
|
13031
|
-
authorizedCidHex:
|
|
13418
|
+
authorizedCidHex: cidToHex(
|
|
13419
|
+
"Qmc5MDW6ZxTRe3nXJEKa5KKUCVXFznV9vDqFL4n7ayRZ4p"
|
|
13420
|
+
),
|
|
13032
13421
|
name: "Extend Position Validator",
|
|
13033
13422
|
description: "Production Extend Position Validator",
|
|
13034
13423
|
version: "1.0.0",
|
|
@@ -13044,7 +13433,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13044
13433
|
},
|
|
13045
13434
|
btcWithdrawal: {
|
|
13046
13435
|
cid: "QmQC7QKobtNJKArGK7rgGj8ZCcEWt1pBKXPyd5SZ2fi4tt",
|
|
13047
|
-
authorizedCidHex:
|
|
13436
|
+
authorizedCidHex: cidToHex(
|
|
13437
|
+
"QmQC7QKobtNJKArGK7rgGj8ZCcEWt1pBKXPyd5SZ2fi4tt"
|
|
13438
|
+
),
|
|
13048
13439
|
name: "Btc Withdrawal",
|
|
13049
13440
|
description: "Production Btc Withdrawal",
|
|
13050
13441
|
version: "1.0.1",
|
|
@@ -13060,7 +13451,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13060
13451
|
},
|
|
13061
13452
|
liquidationValidator: {
|
|
13062
13453
|
cid: "QmZscQTKzwqWDZwYfaE57vdG4vYoNeQMkC2DwgJsnRNgQf",
|
|
13063
|
-
authorizedCidHex:
|
|
13454
|
+
authorizedCidHex: cidToHex(
|
|
13455
|
+
"QmZscQTKzwqWDZwYfaE57vdG4vYoNeQMkC2DwgJsnRNgQf"
|
|
13456
|
+
),
|
|
13064
13457
|
name: "Liquidation Validator",
|
|
13065
13458
|
description: "Production Liquidation Validator",
|
|
13066
13459
|
version: "1.0.0",
|
|
@@ -13076,7 +13469,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13076
13469
|
},
|
|
13077
13470
|
priceOracle: {
|
|
13078
13471
|
cid: "Qma6vTTnn3AFy3A4u3A7T5tT6eEp26vXt7rPHSWpmBpdsp",
|
|
13079
|
-
authorizedCidHex:
|
|
13472
|
+
authorizedCidHex: cidToHex(
|
|
13473
|
+
"Qma6vTTnn3AFy3A4u3A7T5tT6eEp26vXt7rPHSWpmBpdsp"
|
|
13474
|
+
),
|
|
13080
13475
|
name: "Price Oracle",
|
|
13081
13476
|
description: "Production Price Oracle (Chipotle main+getPrivateKey)",
|
|
13082
13477
|
version: "1.1.0",
|
|
@@ -13092,7 +13487,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13092
13487
|
},
|
|
13093
13488
|
loanVaultBtcBalance: {
|
|
13094
13489
|
cid: "QmWGEg79snhDQ5Fkm9pLhNmLKUJY5uXfp3t3276Jybritq",
|
|
13095
|
-
authorizedCidHex:
|
|
13490
|
+
authorizedCidHex: cidToHex(
|
|
13491
|
+
"QmWGEg79snhDQ5Fkm9pLhNmLKUJY5uXfp3t3276Jybritq"
|
|
13492
|
+
),
|
|
13096
13493
|
name: "Loan Vault Btc Balance",
|
|
13097
13494
|
description: "Production Loan Vault Btc Balance",
|
|
13098
13495
|
version: "1.0.0",
|
|
@@ -13108,7 +13505,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13108
13505
|
},
|
|
13109
13506
|
adminLiquidationValidator: {
|
|
13110
13507
|
cid: "QmYJJFgFPF4BR4ts9GrAkwfEoQbVSXEwnrciZ5Jj9WTDgd",
|
|
13111
|
-
authorizedCidHex:
|
|
13508
|
+
authorizedCidHex: cidToHex(
|
|
13509
|
+
"QmYJJFgFPF4BR4ts9GrAkwfEoQbVSXEwnrciZ5Jj9WTDgd"
|
|
13510
|
+
),
|
|
13112
13511
|
name: "Admin Liquidation Validator",
|
|
13113
13512
|
description: "Production Admin Liquidation Validator",
|
|
13114
13513
|
version: "1.0.0",
|
|
@@ -13124,7 +13523,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13124
13523
|
},
|
|
13125
13524
|
alwaysSigner: {
|
|
13126
13525
|
cid: "QmXQjybSsdE19Da66to9Hh7X2dLFwpZPhjoqojxbpk7Nvs",
|
|
13127
|
-
authorizedCidHex:
|
|
13526
|
+
authorizedCidHex: cidToHex(
|
|
13527
|
+
"QmXQjybSsdE19Da66to9Hh7X2dLFwpZPhjoqojxbpk7Nvs"
|
|
13528
|
+
),
|
|
13128
13529
|
name: "Always Signer",
|
|
13129
13530
|
description: "Production Always Signer",
|
|
13130
13531
|
version: "1.0.0",
|
|
@@ -13136,336 +13537,80 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13136
13537
|
};
|
|
13137
13538
|
function getDeploymentsForNetwork(network) {
|
|
13138
13539
|
if (network === "chipotle")
|
|
13139
|
-
return
|
|
13540
|
+
return DH_LIT_ACTIONS_CHIPOTLE3;
|
|
13140
13541
|
throw new Error(`Unsupported LIT network: ${network}`);
|
|
13141
13542
|
}
|
|
13142
|
-
|
|
13143
|
-
}
|
|
13144
|
-
});
|
|
13145
|
-
|
|
13146
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/lit-action-helpers.js
|
|
13147
|
-
var require_lit_action_helpers = __commonJS({
|
|
13148
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/lit-action-helpers.js"(exports) {
|
|
13149
|
-
"use strict";
|
|
13150
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13151
|
-
exports.getLitActionCID = getLitActionCID;
|
|
13152
|
-
exports.getLitActionConfig = getLitActionConfig;
|
|
13153
|
-
exports.isLitActionDeployed = isLitActionDeployed;
|
|
13154
|
-
exports.validateDeployedActions = validateDeployedActions;
|
|
13155
|
-
exports.getDeployedActions = getDeployedActions;
|
|
13156
|
-
var lit_actions_registry_1 = require_lit_actions_registry();
|
|
13543
|
+
var CHIPOTLE_DEPLOYMENTS = DH_LIT_ACTIONS_CHIPOTLE3;
|
|
13157
13544
|
function getLitActionCID(litNetwork = "chipotle", actionName) {
|
|
13158
|
-
const deployments =
|
|
13545
|
+
const deployments = getDeploymentsForNetwork(litNetwork);
|
|
13159
13546
|
const action = deployments[actionName];
|
|
13160
13547
|
if (!action || !action.deployed || !action.cid) {
|
|
13161
|
-
throw new Error(
|
|
13548
|
+
throw new Error(
|
|
13549
|
+
`LIT Action '${actionName}' not deployed on network '${litNetwork}'. Check deployment status.`
|
|
13550
|
+
);
|
|
13162
13551
|
}
|
|
13163
13552
|
return action.cid;
|
|
13164
13553
|
}
|
|
13165
13554
|
function getLitActionConfig(actionName, litNetwork = "chipotle") {
|
|
13166
|
-
const deployments =
|
|
13555
|
+
const deployments = getDeploymentsForNetwork(litNetwork);
|
|
13167
13556
|
const action = deployments[actionName];
|
|
13168
13557
|
if (!action) {
|
|
13169
|
-
throw new Error(
|
|
13558
|
+
throw new Error(
|
|
13559
|
+
`LIT Action '${actionName}' not found in registry for network '${litNetwork}'.`
|
|
13560
|
+
);
|
|
13170
13561
|
}
|
|
13171
13562
|
return action;
|
|
13172
13563
|
}
|
|
13173
13564
|
function isLitActionDeployed(actionName, litNetwork = "chipotle") {
|
|
13174
|
-
const deployments =
|
|
13565
|
+
const deployments = getDeploymentsForNetwork(litNetwork);
|
|
13175
13566
|
const action = deployments[actionName];
|
|
13176
13567
|
return !!(action && action.deployed && action.cid);
|
|
13177
13568
|
}
|
|
13178
13569
|
function validateDeployedActions(requiredActions, litNetwork = "chipotle") {
|
|
13179
|
-
return requiredActions.every(
|
|
13570
|
+
return requiredActions.every(
|
|
13571
|
+
(actionName) => isLitActionDeployed(actionName, litNetwork)
|
|
13572
|
+
);
|
|
13180
13573
|
}
|
|
13181
13574
|
function getDeployedActions(litNetwork = "chipotle") {
|
|
13182
|
-
const deployments =
|
|
13183
|
-
return Object.values(deployments).filter(
|
|
13575
|
+
const deployments = getDeploymentsForNetwork(litNetwork);
|
|
13576
|
+
return Object.values(deployments).filter(
|
|
13577
|
+
(action) => action && action.deployed
|
|
13578
|
+
);
|
|
13184
13579
|
}
|
|
13185
|
-
}
|
|
13186
|
-
});
|
|
13187
|
-
|
|
13188
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/pkp-setup.js
|
|
13189
|
-
var require_pkp_setup = __commonJS({
|
|
13190
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/pkp-setup.js"(exports) {
|
|
13191
|
-
"use strict";
|
|
13192
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13193
|
-
exports.getPKPValidatorSetup = getPKPValidatorSetup;
|
|
13194
|
-
var lit_actions_registry_1 = require_lit_actions_registry();
|
|
13195
13580
|
function getPKPValidatorSetup(litNetwork = "chipotle") {
|
|
13196
|
-
const deployments =
|
|
13581
|
+
const deployments = getDeploymentsForNetwork(litNetwork);
|
|
13197
13582
|
const litAction = deployments.pkpValidator;
|
|
13198
13583
|
if (!litAction || !litAction.pkp) {
|
|
13199
|
-
throw new Error(
|
|
13584
|
+
throw new Error(
|
|
13585
|
+
`PKP validator setup is not available for litNetwork='${litNetwork}'. Ensure the pkpValidator action (with pkp attached) is defined in the registry.`
|
|
13586
|
+
);
|
|
13200
13587
|
}
|
|
13201
13588
|
return {
|
|
13202
13589
|
litAction,
|
|
13203
13590
|
pkp: litAction.pkp
|
|
13204
13591
|
};
|
|
13205
13592
|
}
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
|
|
13210
|
-
|
|
13211
|
-
|
|
13212
|
-
|
|
13213
|
-
|
|
13214
|
-
|
|
13215
|
-
|
|
13216
|
-
|
|
13217
|
-
|
|
13218
|
-
|
|
13219
|
-
|
|
13220
|
-
exports.debugTrace = debugTrace;
|
|
13221
|
-
exports.logRequest = logRequest;
|
|
13222
|
-
exports.logResponse = logResponse;
|
|
13223
|
-
exports.logError = logError;
|
|
13224
|
-
exports.logConnectionAttempt = logConnectionAttempt;
|
|
13225
|
-
exports.logConnectionSuccess = logConnectionSuccess;
|
|
13226
|
-
exports.logConnectionFailure = logConnectionFailure;
|
|
13227
|
-
exports.logPkpOperation = logPkpOperation;
|
|
13228
|
-
exports.logSessionSignatures = logSessionSignatures;
|
|
13229
|
-
exports.logLitActionExecution = logLitActionExecution;
|
|
13230
|
-
exports.logLitActionResult = logLitActionResult;
|
|
13231
|
-
exports.logTestStart = logTestStart;
|
|
13232
|
-
exports.logTestEnd = logTestEnd;
|
|
13233
|
-
var LogLevel2;
|
|
13234
|
-
(function(LogLevel3) {
|
|
13235
|
-
LogLevel3[LogLevel3["ERROR"] = 0] = "ERROR";
|
|
13236
|
-
LogLevel3[LogLevel3["WARN"] = 1] = "WARN";
|
|
13237
|
-
LogLevel3[LogLevel3["INFO"] = 2] = "INFO";
|
|
13238
|
-
LogLevel3[LogLevel3["DEBUG"] = 3] = "DEBUG";
|
|
13239
|
-
LogLevel3[LogLevel3["TRACE"] = 4] = "TRACE";
|
|
13240
|
-
})(LogLevel2 || (exports.LogLevel = LogLevel2 = {}));
|
|
13241
|
-
exports.DEFAULT_DEBUG_CONFIG = {
|
|
13242
|
-
level: LogLevel2.INFO,
|
|
13243
|
-
enableTimestamps: true,
|
|
13244
|
-
enablePerformanceMetrics: true,
|
|
13245
|
-
enableRequestLogging: true,
|
|
13246
|
-
enableNetworkMetrics: true
|
|
13247
|
-
};
|
|
13248
|
-
var debugConfig = { ...exports.DEFAULT_DEBUG_CONFIG };
|
|
13249
|
-
function configureDebugLogging(config) {
|
|
13250
|
-
debugConfig = { ...debugConfig, ...config };
|
|
13251
|
-
}
|
|
13252
|
-
function getTimestamp() {
|
|
13253
|
-
return (/* @__PURE__ */ new Date()).toISOString();
|
|
13254
|
-
}
|
|
13255
|
-
function formatMessage(level, component, message, metadata) {
|
|
13256
|
-
const timestamp = debugConfig.enableTimestamps ? `[${getTimestamp()}] ` : "";
|
|
13257
|
-
const metadataStr = metadata ? ` ${JSON.stringify(metadata)}` : "";
|
|
13258
|
-
return `${timestamp}[${level}] [${component}] ${message}${metadataStr}`;
|
|
13259
|
-
}
|
|
13260
|
-
var PerformanceTracker = class {
|
|
13261
|
-
constructor(operationName) {
|
|
13262
|
-
this.operationName = operationName;
|
|
13263
|
-
this.markers = /* @__PURE__ */ new Map();
|
|
13264
|
-
this.startTime = Date.now();
|
|
13265
|
-
this.log("PERF", `Started: ${operationName}`);
|
|
13266
|
-
}
|
|
13267
|
-
mark(label) {
|
|
13268
|
-
const elapsed = Date.now() - this.startTime;
|
|
13269
|
-
this.markers.set(label, elapsed);
|
|
13270
|
-
this.log("PERF", `${this.operationName} - ${label}: ${elapsed}ms`);
|
|
13271
|
-
}
|
|
13272
|
-
end(success2 = true) {
|
|
13273
|
-
const totalTime = Date.now() - this.startTime;
|
|
13274
|
-
const status = success2 ? "SUCCESS" : "FAILED";
|
|
13275
|
-
this.log("PERF", `${this.operationName} - ${status}: ${totalTime}ms`);
|
|
13276
|
-
if (debugConfig.enablePerformanceMetrics && this.markers.size > 0) {
|
|
13277
|
-
console.log(`\u{1F4CA} Performance Breakdown for ${this.operationName}:`);
|
|
13278
|
-
for (const [label, time] of this.markers) {
|
|
13279
|
-
console.log(` ${label}: ${time}ms`);
|
|
13280
|
-
}
|
|
13281
|
-
console.log(` Total: ${totalTime}ms`);
|
|
13282
|
-
}
|
|
13283
|
-
return totalTime;
|
|
13284
|
-
}
|
|
13285
|
-
log(level, message) {
|
|
13286
|
-
if (debugConfig.enablePerformanceMetrics) {
|
|
13287
|
-
console.log(formatMessage(level, "PERFORMANCE", message));
|
|
13288
|
-
}
|
|
13289
|
-
}
|
|
13290
|
-
};
|
|
13291
|
-
exports.PerformanceTracker = PerformanceTracker;
|
|
13292
|
-
var NetworkMetricsCollector = class {
|
|
13293
|
-
constructor() {
|
|
13294
|
-
this.metrics = /* @__PURE__ */ new Map();
|
|
13295
|
-
}
|
|
13296
|
-
getMetrics(operation) {
|
|
13297
|
-
if (!this.metrics.has(operation)) {
|
|
13298
|
-
this.metrics.set(operation, {
|
|
13299
|
-
requestCount: 0,
|
|
13300
|
-
successCount: 0,
|
|
13301
|
-
failureCount: 0,
|
|
13302
|
-
averageLatency: 0,
|
|
13303
|
-
startTime: Date.now()
|
|
13304
|
-
});
|
|
13305
|
-
}
|
|
13306
|
-
return this.metrics.get(operation);
|
|
13307
|
-
}
|
|
13308
|
-
recordRequest(operation, success2, latency, error) {
|
|
13309
|
-
const metrics = this.getMetrics(operation);
|
|
13310
|
-
metrics.requestCount++;
|
|
13311
|
-
if (success2) {
|
|
13312
|
-
metrics.successCount++;
|
|
13313
|
-
metrics.averageLatency = (metrics.averageLatency * (metrics.successCount - 1) + latency) / metrics.successCount;
|
|
13314
|
-
} else {
|
|
13315
|
-
metrics.failureCount++;
|
|
13316
|
-
if (error)
|
|
13317
|
-
metrics.lastError = error;
|
|
13318
|
-
}
|
|
13319
|
-
if (debugConfig.enableNetworkMetrics) {
|
|
13320
|
-
const successRate = (metrics.successCount / metrics.requestCount * 100).toFixed(1);
|
|
13321
|
-
debugLog("NETWORK", `${operation} - Success: ${success2}, Latency: ${latency}ms, Success Rate: ${successRate}%`);
|
|
13322
|
-
}
|
|
13323
|
-
}
|
|
13324
|
-
printSummary() {
|
|
13325
|
-
if (!debugConfig.enableNetworkMetrics)
|
|
13326
|
-
return;
|
|
13327
|
-
console.log("\n\u{1F4C8} Network Metrics Summary:");
|
|
13328
|
-
for (const [operation, metrics] of this.metrics) {
|
|
13329
|
-
const successRate = (metrics.successCount / metrics.requestCount * 100).toFixed(1);
|
|
13330
|
-
const runtime = Date.now() - metrics.startTime;
|
|
13331
|
-
console.log(` ${operation}:`);
|
|
13332
|
-
console.log(` Requests: ${metrics.requestCount}`);
|
|
13333
|
-
console.log(` Success Rate: ${successRate}%`);
|
|
13334
|
-
console.log(` Avg Latency: ${metrics.averageLatency.toFixed(0)}ms`);
|
|
13335
|
-
console.log(` Runtime: ${runtime}ms`);
|
|
13336
|
-
if (metrics.lastError) {
|
|
13337
|
-
console.log(` Last Error: ${metrics.lastError}`);
|
|
13338
|
-
}
|
|
13339
|
-
}
|
|
13340
|
-
}
|
|
13341
|
-
};
|
|
13342
|
-
exports.networkMetrics = new NetworkMetricsCollector();
|
|
13343
|
-
function debugError(component, message, metadata) {
|
|
13344
|
-
if (debugConfig.level >= LogLevel2.ERROR) {
|
|
13345
|
-
console.error(formatMessage("ERROR", component, message, metadata));
|
|
13346
|
-
}
|
|
13347
|
-
}
|
|
13348
|
-
function debugWarn(component, message, metadata) {
|
|
13349
|
-
if (debugConfig.level >= LogLevel2.WARN) {
|
|
13350
|
-
console.warn(formatMessage("WARN", component, message, metadata));
|
|
13351
|
-
}
|
|
13352
|
-
}
|
|
13353
|
-
function debugInfo(component, message, metadata) {
|
|
13354
|
-
if (debugConfig.level >= LogLevel2.INFO) {
|
|
13355
|
-
console.log(formatMessage("INFO", component, message, metadata));
|
|
13356
|
-
}
|
|
13357
|
-
}
|
|
13358
|
-
function debugLog(component, message, metadata) {
|
|
13359
|
-
if (debugConfig.level >= LogLevel2.DEBUG) {
|
|
13360
|
-
console.log(formatMessage("DEBUG", component, message, metadata));
|
|
13361
|
-
}
|
|
13362
|
-
}
|
|
13363
|
-
function debugTrace(component, message, metadata) {
|
|
13364
|
-
if (debugConfig.level >= LogLevel2.TRACE) {
|
|
13365
|
-
console.log(formatMessage("TRACE", component, message, metadata));
|
|
13366
|
-
}
|
|
13367
|
-
}
|
|
13368
|
-
function logRequest(component, operation, params) {
|
|
13369
|
-
if (!debugConfig.enableRequestLogging)
|
|
13370
|
-
return;
|
|
13371
|
-
debugLog(component, `\u{1F504} Request: ${operation}`, {
|
|
13372
|
-
operation,
|
|
13373
|
-
params: JSON.stringify(params, null, 2)
|
|
13374
|
-
});
|
|
13375
|
-
}
|
|
13376
|
-
function logResponse(component, operation, response, duration) {
|
|
13377
|
-
if (!debugConfig.enableRequestLogging)
|
|
13378
|
-
return;
|
|
13379
|
-
debugLog(component, `\u2705 Response: ${operation} (${duration}ms)`, {
|
|
13380
|
-
operation,
|
|
13381
|
-
duration,
|
|
13382
|
-
response: typeof response === "object" ? JSON.stringify(response, null, 2) : response
|
|
13383
|
-
});
|
|
13384
|
-
}
|
|
13385
|
-
function logError(component, operation, error, duration) {
|
|
13386
|
-
const durationStr = duration ? ` (${duration}ms)` : "";
|
|
13387
|
-
debugError(component, `\u274C Error: ${operation}${durationStr}`, {
|
|
13388
|
-
operation,
|
|
13389
|
-
duration,
|
|
13390
|
-
error: error?.message || error?.toString() || "Unknown error",
|
|
13391
|
-
stack: error?.stack
|
|
13392
|
-
});
|
|
13393
|
-
}
|
|
13394
|
-
function logConnectionAttempt(network, attempt, maxAttempts) {
|
|
13395
|
-
debugInfo("CONNECTION", `\u{1F517} Connecting to ${network} (attempt ${attempt}/${maxAttempts})`);
|
|
13396
|
-
}
|
|
13397
|
-
function logConnectionSuccess(network, latency) {
|
|
13398
|
-
debugInfo("CONNECTION", `\u2705 Connected to ${network} (${latency}ms)`);
|
|
13399
|
-
exports.networkMetrics.recordRequest(`connection-${network}`, true, latency);
|
|
13400
|
-
}
|
|
13401
|
-
function logConnectionFailure(network, error, attempt) {
|
|
13402
|
-
debugError("CONNECTION", `\u274C Connection failed to ${network} (attempt ${attempt})`, { error });
|
|
13403
|
-
exports.networkMetrics.recordRequest(`connection-${network}`, false, 0, error);
|
|
13404
|
-
}
|
|
13405
|
-
function logPkpOperation(operation, pkpId, details) {
|
|
13406
|
-
const pkpStr = pkpId ? ` (PKP: ${pkpId.slice(0, 8)}...)` : "";
|
|
13407
|
-
debugInfo("PKP", `\u{1F511} ${operation}${pkpStr}`, details);
|
|
13408
|
-
}
|
|
13409
|
-
function logSessionSignatures(count, expiration) {
|
|
13410
|
-
debugInfo("SESSION", `\u{1F510} Generated ${count} session signatures (expires: ${expiration})`);
|
|
13411
|
-
}
|
|
13412
|
-
function logLitActionExecution(cid, params) {
|
|
13413
|
-
debugInfo("LIT_ACTION", `\u26A1 Executing LIT Action: ${cid}`, {
|
|
13414
|
-
cid,
|
|
13415
|
-
params
|
|
13416
|
-
});
|
|
13417
|
-
}
|
|
13418
|
-
function logLitActionResult(cid, success2, duration, result) {
|
|
13419
|
-
const status = success2 ? "\u2705" : "\u274C";
|
|
13420
|
-
debugInfo("LIT_ACTION", `${status} LIT Action completed: ${cid} (${duration}ms)`, {
|
|
13421
|
-
cid,
|
|
13422
|
-
success: success2,
|
|
13423
|
-
duration,
|
|
13424
|
-
result: success2 && result ? JSON.stringify(result, null, 2) : void 0
|
|
13425
|
-
});
|
|
13426
|
-
}
|
|
13427
|
-
function logTestStart(testName) {
|
|
13428
|
-
debugInfo("TEST", `\u{1F9EA} Starting test: ${testName}`);
|
|
13429
|
-
return new PerformanceTracker(testName);
|
|
13430
|
-
}
|
|
13431
|
-
function logTestEnd(testName, success2, duration) {
|
|
13432
|
-
const status = success2 ? "\u2705" : "\u274C";
|
|
13433
|
-
debugInfo("TEST", `${status} Test completed: ${testName} (${duration}ms)`);
|
|
13434
|
-
exports.networkMetrics.printSummary();
|
|
13435
|
-
}
|
|
13436
|
-
}
|
|
13437
|
-
});
|
|
13438
|
-
|
|
13439
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/error-classification.js
|
|
13440
|
-
var require_error_classification = __commonJS({
|
|
13441
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/error-classification.js"(exports) {
|
|
13442
|
-
"use strict";
|
|
13443
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13444
|
-
exports.litProtocolErrors = exports.RetryStrategy = exports.ErrorCategory = void 0;
|
|
13445
|
-
exports.classifyError = classifyError;
|
|
13446
|
-
exports.getRetryConfigFromClassification = getRetryConfigFromClassification;
|
|
13447
|
-
exports.analyzeError = analyzeError;
|
|
13448
|
-
exports.createErrorReport = createErrorReport;
|
|
13449
|
-
var ErrorCategory2;
|
|
13450
|
-
(function(ErrorCategory3) {
|
|
13451
|
-
ErrorCategory3["NETWORK"] = "network";
|
|
13452
|
-
ErrorCategory3["PROTOCOL"] = "protocol";
|
|
13453
|
-
ErrorCategory3["AUTHENTICATION"] = "authentication";
|
|
13454
|
-
ErrorCategory3["RESOURCE"] = "resource";
|
|
13455
|
-
ErrorCategory3["VALIDATION"] = "validation";
|
|
13456
|
-
ErrorCategory3["TIMEOUT"] = "timeout";
|
|
13457
|
-
ErrorCategory3["RATE_LIMIT"] = "rate_limit";
|
|
13458
|
-
ErrorCategory3["CONFIGURATION"] = "configuration";
|
|
13459
|
-
ErrorCategory3["UNKNOWN"] = "unknown";
|
|
13460
|
-
})(ErrorCategory2 || (exports.ErrorCategory = ErrorCategory2 = {}));
|
|
13461
|
-
var RetryStrategy;
|
|
13462
|
-
(function(RetryStrategy2) {
|
|
13593
|
+
init_debug_logger();
|
|
13594
|
+
var ErrorCategory2 = /* @__PURE__ */ ((ErrorCategory22) => {
|
|
13595
|
+
ErrorCategory22["NETWORK"] = "network";
|
|
13596
|
+
ErrorCategory22["PROTOCOL"] = "protocol";
|
|
13597
|
+
ErrorCategory22["AUTHENTICATION"] = "authentication";
|
|
13598
|
+
ErrorCategory22["RESOURCE"] = "resource";
|
|
13599
|
+
ErrorCategory22["VALIDATION"] = "validation";
|
|
13600
|
+
ErrorCategory22["TIMEOUT"] = "timeout";
|
|
13601
|
+
ErrorCategory22["RATE_LIMIT"] = "rate_limit";
|
|
13602
|
+
ErrorCategory22["CONFIGURATION"] = "configuration";
|
|
13603
|
+
ErrorCategory22["UNKNOWN"] = "unknown";
|
|
13604
|
+
return ErrorCategory22;
|
|
13605
|
+
})(ErrorCategory2 || {});
|
|
13606
|
+
var RetryStrategy = /* @__PURE__ */ ((RetryStrategy2) => {
|
|
13463
13607
|
RetryStrategy2["AGGRESSIVE"] = "aggressive";
|
|
13464
13608
|
RetryStrategy2["CONSERVATIVE"] = "conservative";
|
|
13465
13609
|
RetryStrategy2["EXPONENTIAL"] = "exponential";
|
|
13466
13610
|
RetryStrategy2["LINEAR"] = "linear";
|
|
13467
13611
|
RetryStrategy2["NONE"] = "none";
|
|
13468
|
-
|
|
13612
|
+
return RetryStrategy2;
|
|
13613
|
+
})(RetryStrategy || {});
|
|
13469
13614
|
var LIT_ERROR_PATTERNS = {
|
|
13470
13615
|
// Network and connection errors
|
|
13471
13616
|
network: [
|
|
@@ -13558,31 +13703,46 @@ var require_error_classification = __commonJS({
|
|
|
13558
13703
|
]
|
|
13559
13704
|
};
|
|
13560
13705
|
var RETRY_STRATEGIES = {
|
|
13561
|
-
[
|
|
13706
|
+
[
|
|
13707
|
+
"aggressive"
|
|
13708
|
+
/* AGGRESSIVE */
|
|
13709
|
+
]: {
|
|
13562
13710
|
maxAttempts: 5,
|
|
13563
13711
|
baseDelayMs: 500,
|
|
13564
13712
|
maxDelayMs: 5e3,
|
|
13565
13713
|
multiplier: 1.5
|
|
13566
13714
|
},
|
|
13567
|
-
[
|
|
13715
|
+
[
|
|
13716
|
+
"conservative"
|
|
13717
|
+
/* CONSERVATIVE */
|
|
13718
|
+
]: {
|
|
13568
13719
|
maxAttempts: 3,
|
|
13569
13720
|
baseDelayMs: 3e3,
|
|
13570
13721
|
maxDelayMs: 3e4,
|
|
13571
13722
|
multiplier: 2.5
|
|
13572
13723
|
},
|
|
13573
|
-
[
|
|
13724
|
+
[
|
|
13725
|
+
"exponential"
|
|
13726
|
+
/* EXPONENTIAL */
|
|
13727
|
+
]: {
|
|
13574
13728
|
maxAttempts: 4,
|
|
13575
13729
|
baseDelayMs: 1e3,
|
|
13576
13730
|
maxDelayMs: 15e3,
|
|
13577
13731
|
multiplier: 2
|
|
13578
13732
|
},
|
|
13579
|
-
[
|
|
13733
|
+
[
|
|
13734
|
+
"linear"
|
|
13735
|
+
/* LINEAR */
|
|
13736
|
+
]: {
|
|
13580
13737
|
maxAttempts: 3,
|
|
13581
13738
|
baseDelayMs: 2e3,
|
|
13582
13739
|
maxDelayMs: 1e4,
|
|
13583
13740
|
multiplier: 1
|
|
13584
13741
|
},
|
|
13585
|
-
[
|
|
13742
|
+
[
|
|
13743
|
+
"none"
|
|
13744
|
+
/* NONE */
|
|
13745
|
+
]: {
|
|
13586
13746
|
maxAttempts: 1,
|
|
13587
13747
|
baseDelayMs: 0,
|
|
13588
13748
|
maxDelayMs: 0,
|
|
@@ -13590,11 +13750,17 @@ var require_error_classification = __commonJS({
|
|
|
13590
13750
|
}
|
|
13591
13751
|
};
|
|
13592
13752
|
var CLASSIFICATION_RULES = {
|
|
13593
|
-
[
|
|
13594
|
-
|
|
13595
|
-
|
|
13753
|
+
[
|
|
13754
|
+
"network"
|
|
13755
|
+
/* NETWORK */
|
|
13756
|
+
]: {
|
|
13757
|
+
category: "network",
|
|
13758
|
+
retryStrategy: "aggressive",
|
|
13596
13759
|
isRetryable: true,
|
|
13597
|
-
...RETRY_STRATEGIES[
|
|
13760
|
+
...RETRY_STRATEGIES[
|
|
13761
|
+
"aggressive"
|
|
13762
|
+
/* AGGRESSIVE */
|
|
13763
|
+
],
|
|
13598
13764
|
description: "Network connectivity or communication error",
|
|
13599
13765
|
troubleshooting: [
|
|
13600
13766
|
"Check internet connection",
|
|
@@ -13603,11 +13769,17 @@ var require_error_classification = __commonJS({
|
|
|
13603
13769
|
"Try connecting to different node endpoints"
|
|
13604
13770
|
]
|
|
13605
13771
|
},
|
|
13606
|
-
[
|
|
13607
|
-
|
|
13608
|
-
|
|
13772
|
+
[
|
|
13773
|
+
"protocol"
|
|
13774
|
+
/* PROTOCOL */
|
|
13775
|
+
]: {
|
|
13776
|
+
category: "protocol",
|
|
13777
|
+
retryStrategy: "conservative",
|
|
13609
13778
|
isRetryable: true,
|
|
13610
|
-
...RETRY_STRATEGIES[
|
|
13779
|
+
...RETRY_STRATEGIES[
|
|
13780
|
+
"conservative"
|
|
13781
|
+
/* CONSERVATIVE */
|
|
13782
|
+
],
|
|
13611
13783
|
description: "LIT Protocol specific operational error",
|
|
13612
13784
|
troubleshooting: [
|
|
13613
13785
|
"Check LIT Protocol network status",
|
|
@@ -13616,11 +13788,17 @@ var require_error_classification = __commonJS({
|
|
|
13616
13788
|
"Wait for network consensus"
|
|
13617
13789
|
]
|
|
13618
13790
|
},
|
|
13619
|
-
[
|
|
13620
|
-
|
|
13621
|
-
|
|
13791
|
+
[
|
|
13792
|
+
"authentication"
|
|
13793
|
+
/* AUTHENTICATION */
|
|
13794
|
+
]: {
|
|
13795
|
+
category: "authentication",
|
|
13796
|
+
retryStrategy: "exponential",
|
|
13622
13797
|
isRetryable: true,
|
|
13623
|
-
...RETRY_STRATEGIES[
|
|
13798
|
+
...RETRY_STRATEGIES[
|
|
13799
|
+
"exponential"
|
|
13800
|
+
/* EXPONENTIAL */
|
|
13801
|
+
],
|
|
13624
13802
|
maxAttempts: 2,
|
|
13625
13803
|
// Override: limited retries for auth issues
|
|
13626
13804
|
description: "Authentication or authorization error",
|
|
@@ -13631,11 +13809,17 @@ var require_error_classification = __commonJS({
|
|
|
13631
13809
|
"Check PKP authorization status"
|
|
13632
13810
|
]
|
|
13633
13811
|
},
|
|
13634
|
-
[
|
|
13635
|
-
|
|
13636
|
-
|
|
13812
|
+
[
|
|
13813
|
+
"resource"
|
|
13814
|
+
/* RESOURCE */
|
|
13815
|
+
]: {
|
|
13816
|
+
category: "resource",
|
|
13817
|
+
retryStrategy: "linear",
|
|
13637
13818
|
isRetryable: true,
|
|
13638
|
-
...RETRY_STRATEGIES[
|
|
13819
|
+
...RETRY_STRATEGIES[
|
|
13820
|
+
"linear"
|
|
13821
|
+
/* LINEAR */
|
|
13822
|
+
],
|
|
13639
13823
|
maxAttempts: 2,
|
|
13640
13824
|
// Override: limited retries for resource issues
|
|
13641
13825
|
description: "Resource not found or validation error",
|
|
@@ -13646,11 +13830,17 @@ var require_error_classification = __commonJS({
|
|
|
13646
13830
|
"Wait for resource propagation"
|
|
13647
13831
|
]
|
|
13648
13832
|
},
|
|
13649
|
-
[
|
|
13650
|
-
|
|
13651
|
-
|
|
13833
|
+
[
|
|
13834
|
+
"validation"
|
|
13835
|
+
/* VALIDATION */
|
|
13836
|
+
]: {
|
|
13837
|
+
category: "validation",
|
|
13838
|
+
retryStrategy: "none",
|
|
13652
13839
|
isRetryable: false,
|
|
13653
|
-
...RETRY_STRATEGIES[
|
|
13840
|
+
...RETRY_STRATEGIES[
|
|
13841
|
+
"none"
|
|
13842
|
+
/* NONE */
|
|
13843
|
+
],
|
|
13654
13844
|
description: "Input validation or schema error",
|
|
13655
13845
|
troubleshooting: [
|
|
13656
13846
|
"Check input parameters format",
|
|
@@ -13659,11 +13849,17 @@ var require_error_classification = __commonJS({
|
|
|
13659
13849
|
"Review API documentation"
|
|
13660
13850
|
]
|
|
13661
13851
|
},
|
|
13662
|
-
[
|
|
13663
|
-
|
|
13664
|
-
|
|
13852
|
+
[
|
|
13853
|
+
"timeout"
|
|
13854
|
+
/* TIMEOUT */
|
|
13855
|
+
]: {
|
|
13856
|
+
category: "timeout",
|
|
13857
|
+
retryStrategy: "conservative",
|
|
13665
13858
|
isRetryable: true,
|
|
13666
|
-
...RETRY_STRATEGIES[
|
|
13859
|
+
...RETRY_STRATEGIES[
|
|
13860
|
+
"conservative"
|
|
13861
|
+
/* CONSERVATIVE */
|
|
13862
|
+
],
|
|
13667
13863
|
description: "Operation timeout error",
|
|
13668
13864
|
troubleshooting: [
|
|
13669
13865
|
"Increase timeout values",
|
|
@@ -13672,11 +13868,17 @@ var require_error_classification = __commonJS({
|
|
|
13672
13868
|
"Split operations into smaller chunks"
|
|
13673
13869
|
]
|
|
13674
13870
|
},
|
|
13675
|
-
[
|
|
13676
|
-
|
|
13677
|
-
|
|
13871
|
+
[
|
|
13872
|
+
"rate_limit"
|
|
13873
|
+
/* RATE_LIMIT */
|
|
13874
|
+
]: {
|
|
13875
|
+
category: "rate_limit",
|
|
13876
|
+
retryStrategy: "conservative",
|
|
13678
13877
|
isRetryable: true,
|
|
13679
|
-
...RETRY_STRATEGIES[
|
|
13878
|
+
...RETRY_STRATEGIES[
|
|
13879
|
+
"conservative"
|
|
13880
|
+
/* CONSERVATIVE */
|
|
13881
|
+
],
|
|
13680
13882
|
maxAttempts: 2,
|
|
13681
13883
|
// Override: limited retries to avoid further rate limiting
|
|
13682
13884
|
baseDelayMs: 5e3,
|
|
@@ -13689,11 +13891,17 @@ var require_error_classification = __commonJS({
|
|
|
13689
13891
|
"Wait for quota reset"
|
|
13690
13892
|
]
|
|
13691
13893
|
},
|
|
13692
|
-
[
|
|
13693
|
-
|
|
13694
|
-
|
|
13894
|
+
[
|
|
13895
|
+
"configuration"
|
|
13896
|
+
/* CONFIGURATION */
|
|
13897
|
+
]: {
|
|
13898
|
+
category: "configuration",
|
|
13899
|
+
retryStrategy: "none",
|
|
13695
13900
|
isRetryable: false,
|
|
13696
|
-
...RETRY_STRATEGIES[
|
|
13901
|
+
...RETRY_STRATEGIES[
|
|
13902
|
+
"none"
|
|
13903
|
+
/* NONE */
|
|
13904
|
+
],
|
|
13697
13905
|
description: "Configuration or setup error",
|
|
13698
13906
|
troubleshooting: [
|
|
13699
13907
|
"Check environment variables",
|
|
@@ -13702,11 +13910,17 @@ var require_error_classification = __commonJS({
|
|
|
13702
13910
|
"Check required dependencies"
|
|
13703
13911
|
]
|
|
13704
13912
|
},
|
|
13705
|
-
[
|
|
13706
|
-
|
|
13707
|
-
|
|
13913
|
+
[
|
|
13914
|
+
"unknown"
|
|
13915
|
+
/* UNKNOWN */
|
|
13916
|
+
]: {
|
|
13917
|
+
category: "unknown",
|
|
13918
|
+
retryStrategy: "exponential",
|
|
13708
13919
|
isRetryable: true,
|
|
13709
|
-
...RETRY_STRATEGIES[
|
|
13920
|
+
...RETRY_STRATEGIES[
|
|
13921
|
+
"exponential"
|
|
13922
|
+
/* EXPONENTIAL */
|
|
13923
|
+
],
|
|
13710
13924
|
maxAttempts: 2,
|
|
13711
13925
|
// Override: conservative retries for unknown errors
|
|
13712
13926
|
description: "Unknown or unclassified error",
|
|
@@ -13732,7 +13946,10 @@ var require_error_classification = __commonJS({
|
|
|
13732
13946
|
}
|
|
13733
13947
|
}
|
|
13734
13948
|
}
|
|
13735
|
-
const unknownClassification = CLASSIFICATION_RULES[
|
|
13949
|
+
const unknownClassification = CLASSIFICATION_RULES[
|
|
13950
|
+
"unknown"
|
|
13951
|
+
/* UNKNOWN */
|
|
13952
|
+
];
|
|
13736
13953
|
return {
|
|
13737
13954
|
...unknownClassification,
|
|
13738
13955
|
description: `${unknownClassification.description}: ${errorMessage.slice(0, 100)}`
|
|
@@ -13783,258 +14000,17 @@ var require_error_classification = __commonJS({
|
|
|
13783
14000
|
}
|
|
13784
14001
|
return report.join("\n");
|
|
13785
14002
|
}
|
|
13786
|
-
|
|
13787
|
-
isNetworkError: (error) => classifyError(error).category ===
|
|
13788
|
-
isProtocolError: (error) => classifyError(error).category ===
|
|
13789
|
-
isAuthenticationError: (error) => classifyError(error).category ===
|
|
13790
|
-
isResourceError: (error) => classifyError(error).category ===
|
|
13791
|
-
isTimeoutError: (error) => classifyError(error).category ===
|
|
13792
|
-
isRateLimitError: (error) => classifyError(error).category ===
|
|
13793
|
-
isConfigurationError: (error) => classifyError(error).category ===
|
|
14003
|
+
var litProtocolErrors = {
|
|
14004
|
+
isNetworkError: (error) => classifyError(error).category === "network",
|
|
14005
|
+
isProtocolError: (error) => classifyError(error).category === "protocol",
|
|
14006
|
+
isAuthenticationError: (error) => classifyError(error).category === "authentication",
|
|
14007
|
+
isResourceError: (error) => classifyError(error).category === "resource",
|
|
14008
|
+
isTimeoutError: (error) => classifyError(error).category === "timeout",
|
|
14009
|
+
isRateLimitError: (error) => classifyError(error).category === "rate_limit",
|
|
14010
|
+
isConfigurationError: (error) => classifyError(error).category === "configuration",
|
|
13794
14011
|
isRetryable: (error) => classifyError(error).isRetryable
|
|
13795
14012
|
};
|
|
13796
|
-
|
|
13797
|
-
});
|
|
13798
|
-
|
|
13799
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/session-signature-cache.js
|
|
13800
|
-
var require_session_signature_cache = __commonJS({
|
|
13801
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/session-signature-cache.js"(exports) {
|
|
13802
|
-
"use strict";
|
|
13803
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13804
|
-
exports.sessionSignatureCache = exports.DEFAULT_CACHE_CONFIG = void 0;
|
|
13805
|
-
exports.generateSessionSignaturesWithCache = generateSessionSignaturesWithCache;
|
|
13806
|
-
exports.configureSessionSignatureCache = configureSessionSignatureCache;
|
|
13807
|
-
exports.clearSessionSignatureCache = clearSessionSignatureCache;
|
|
13808
|
-
exports.getSessionSignatureCacheStats = getSessionSignatureCacheStats;
|
|
13809
|
-
var debug_logger_1 = require_debug_logger();
|
|
13810
|
-
exports.DEFAULT_CACHE_CONFIG = {
|
|
13811
|
-
maxEntries: 50,
|
|
13812
|
-
bufferTimeMs: 6e4,
|
|
13813
|
-
// 1 minute buffer before expiration
|
|
13814
|
-
enableLogging: true
|
|
13815
|
-
};
|
|
13816
|
-
var SessionSignatureCache = class {
|
|
13817
|
-
constructor(config = {}) {
|
|
13818
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
13819
|
-
this.config = { ...exports.DEFAULT_CACHE_CONFIG, ...config };
|
|
13820
|
-
}
|
|
13821
|
-
/**
|
|
13822
|
-
* Generate cache key from PKP and context
|
|
13823
|
-
*/
|
|
13824
|
-
generateCacheKey(pkpTokenId, litActionCid, signerAddress, network) {
|
|
13825
|
-
return `${signerAddress}-${network}-${pkpTokenId}-${litActionCid}`;
|
|
13826
|
-
}
|
|
13827
|
-
/**
|
|
13828
|
-
* Check if cache entry is still valid
|
|
13829
|
-
*/
|
|
13830
|
-
isEntryValid(entry) {
|
|
13831
|
-
const now2 = /* @__PURE__ */ new Date();
|
|
13832
|
-
const expirationWithBuffer = new Date(entry.expiration.getTime() - this.config.bufferTimeMs);
|
|
13833
|
-
return now2 < expirationWithBuffer;
|
|
13834
|
-
}
|
|
13835
|
-
/**
|
|
13836
|
-
* Clean expired entries from cache
|
|
13837
|
-
*/
|
|
13838
|
-
cleanExpiredEntries() {
|
|
13839
|
-
const now2 = /* @__PURE__ */ new Date();
|
|
13840
|
-
let cleanedCount = 0;
|
|
13841
|
-
for (const [key2, entry] of this.cache.entries()) {
|
|
13842
|
-
if (now2 >= entry.expiration) {
|
|
13843
|
-
this.cache.delete(key2);
|
|
13844
|
-
cleanedCount++;
|
|
13845
|
-
}
|
|
13846
|
-
}
|
|
13847
|
-
if (cleanedCount > 0 && this.config.enableLogging) {
|
|
13848
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u{1F9F9} Cleaned ${cleanedCount} expired session signature entries`);
|
|
13849
|
-
}
|
|
13850
|
-
}
|
|
13851
|
-
/**
|
|
13852
|
-
* Enforce cache size limits
|
|
13853
|
-
*/
|
|
13854
|
-
enforceCacheSize() {
|
|
13855
|
-
if (this.cache.size <= this.config.maxEntries) {
|
|
13856
|
-
return;
|
|
13857
|
-
}
|
|
13858
|
-
const entries = Array.from(this.cache.entries()).sort(([, a], [, b]) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
13859
|
-
const toRemove = entries.slice(0, this.cache.size - this.config.maxEntries);
|
|
13860
|
-
for (const [key2] of toRemove) {
|
|
13861
|
-
this.cache.delete(key2);
|
|
13862
|
-
}
|
|
13863
|
-
if (this.config.enableLogging) {
|
|
13864
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u{1F4E6} Removed ${toRemove.length} oldest cache entries to maintain size limit`);
|
|
13865
|
-
}
|
|
13866
|
-
}
|
|
13867
|
-
/**
|
|
13868
|
-
* Get cached session signatures if valid
|
|
13869
|
-
*/
|
|
13870
|
-
get(pkpTokenId, litActionCid, signerAddress, network) {
|
|
13871
|
-
this.cleanExpiredEntries();
|
|
13872
|
-
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13873
|
-
const entry = this.cache.get(cacheKey);
|
|
13874
|
-
if (!entry) {
|
|
13875
|
-
if (this.config.enableLogging) {
|
|
13876
|
-
(0, debug_logger_1.debugLog)("CACHE", `\u274C Session signatures cache miss: ${cacheKey}`);
|
|
13877
|
-
}
|
|
13878
|
-
return null;
|
|
13879
|
-
}
|
|
13880
|
-
if (!this.isEntryValid(entry)) {
|
|
13881
|
-
this.cache.delete(cacheKey);
|
|
13882
|
-
if (this.config.enableLogging) {
|
|
13883
|
-
(0, debug_logger_1.debugWarn)("CACHE", `\u23F0 Session signatures expired: ${cacheKey}`);
|
|
13884
|
-
}
|
|
13885
|
-
return null;
|
|
13886
|
-
}
|
|
13887
|
-
if (this.config.enableLogging) {
|
|
13888
|
-
const timeUntilExpiry = entry.expiration.getTime() - Date.now();
|
|
13889
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u2705 Session signatures cache hit: ${cacheKey} (expires in ${Math.round(timeUntilExpiry / 1e3)}s)`);
|
|
13890
|
-
}
|
|
13891
|
-
return entry.sessionSigs;
|
|
13892
|
-
}
|
|
13893
|
-
/**
|
|
13894
|
-
* Cache session signatures
|
|
13895
|
-
*/
|
|
13896
|
-
set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration) {
|
|
13897
|
-
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13898
|
-
const entry = {
|
|
13899
|
-
sessionSigs,
|
|
13900
|
-
expiration,
|
|
13901
|
-
pkpTokenId,
|
|
13902
|
-
litActionCid,
|
|
13903
|
-
signerAddress,
|
|
13904
|
-
network,
|
|
13905
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
13906
|
-
};
|
|
13907
|
-
this.cache.set(cacheKey, entry);
|
|
13908
|
-
if (this.config.enableLogging) {
|
|
13909
|
-
const timeUntilExpiry = expiration.getTime() - Date.now();
|
|
13910
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u{1F4BE} Cached session signatures: ${cacheKey} (expires in ${Math.round(timeUntilExpiry / 1e3)}s)`);
|
|
13911
|
-
}
|
|
13912
|
-
this.enforceCacheSize();
|
|
13913
|
-
}
|
|
13914
|
-
/**
|
|
13915
|
-
* Clear all cached session signatures
|
|
13916
|
-
*/
|
|
13917
|
-
clear() {
|
|
13918
|
-
const size = this.cache.size;
|
|
13919
|
-
this.cache.clear();
|
|
13920
|
-
if (this.config.enableLogging) {
|
|
13921
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u{1F5D1}\uFE0F Cleared ${size} cached session signature entries`);
|
|
13922
|
-
}
|
|
13923
|
-
}
|
|
13924
|
-
/**
|
|
13925
|
-
* Get cache statistics
|
|
13926
|
-
*/
|
|
13927
|
-
getStats() {
|
|
13928
|
-
this.cleanExpiredEntries();
|
|
13929
|
-
return {
|
|
13930
|
-
size: this.cache.size,
|
|
13931
|
-
maxEntries: this.config.maxEntries,
|
|
13932
|
-
utilizationPercent: Math.round(this.cache.size / this.config.maxEntries * 100)
|
|
13933
|
-
};
|
|
13934
|
-
}
|
|
13935
|
-
/**
|
|
13936
|
-
* Remove specific cache entry
|
|
13937
|
-
*/
|
|
13938
|
-
delete(pkpTokenId, litActionCid, signerAddress, network) {
|
|
13939
|
-
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13940
|
-
const deleted = this.cache.delete(cacheKey);
|
|
13941
|
-
if (deleted && this.config.enableLogging) {
|
|
13942
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u{1F5D1}\uFE0F Removed session signatures from cache: ${cacheKey}`);
|
|
13943
|
-
}
|
|
13944
|
-
return deleted;
|
|
13945
|
-
}
|
|
13946
|
-
};
|
|
13947
|
-
exports.sessionSignatureCache = new SessionSignatureCache();
|
|
13948
|
-
async function generateSessionSignaturesWithCache(litNodeClient, sessionConfig, pkpTokenId, litActionCid, signerAddress, network = "chipotle") {
|
|
13949
|
-
const cached = exports.sessionSignatureCache.get(pkpTokenId, litActionCid, signerAddress, network);
|
|
13950
|
-
if (cached) {
|
|
13951
|
-
return cached;
|
|
13952
|
-
}
|
|
13953
|
-
(0, debug_logger_1.debugInfo)("CACHE", "\u{1F510} Generating new session signatures (cache miss)...");
|
|
13954
|
-
const sessionSigs = await litNodeClient.getSessionSigs(sessionConfig);
|
|
13955
|
-
const expiration = new Date(sessionConfig.expiration);
|
|
13956
|
-
exports.sessionSignatureCache.set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration);
|
|
13957
|
-
const sigCount = Object.keys(sessionSigs).length;
|
|
13958
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u2705 Generated and cached ${sigCount} session signatures`);
|
|
13959
|
-
return sessionSigs;
|
|
13960
|
-
}
|
|
13961
|
-
function configureSessionSignatureCache(config) {
|
|
13962
|
-
Object.assign(exports.sessionSignatureCache["config"], config);
|
|
13963
|
-
}
|
|
13964
|
-
function clearSessionSignatureCache() {
|
|
13965
|
-
exports.sessionSignatureCache.clear();
|
|
13966
|
-
}
|
|
13967
|
-
function getSessionSignatureCacheStats() {
|
|
13968
|
-
return exports.sessionSignatureCache.getStats();
|
|
13969
|
-
}
|
|
13970
|
-
}
|
|
13971
|
-
});
|
|
13972
|
-
|
|
13973
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/connection-helpers.js
|
|
13974
|
-
var require_connection_helpers = __commonJS({
|
|
13975
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/connection-helpers.js"(exports) {
|
|
13976
|
-
"use strict";
|
|
13977
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
13978
|
-
if (k2 === void 0)
|
|
13979
|
-
k2 = k;
|
|
13980
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13981
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13982
|
-
desc = { enumerable: true, get: function() {
|
|
13983
|
-
return m[k];
|
|
13984
|
-
} };
|
|
13985
|
-
}
|
|
13986
|
-
Object.defineProperty(o, k2, desc);
|
|
13987
|
-
} : function(o, m, k, k2) {
|
|
13988
|
-
if (k2 === void 0)
|
|
13989
|
-
k2 = k;
|
|
13990
|
-
o[k2] = m[k];
|
|
13991
|
-
});
|
|
13992
|
-
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
13993
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
13994
|
-
} : function(o, v) {
|
|
13995
|
-
o["default"] = v;
|
|
13996
|
-
});
|
|
13997
|
-
var __importStar = exports && exports.__importStar || function() {
|
|
13998
|
-
var ownKeys = function(o) {
|
|
13999
|
-
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
14000
|
-
var ar = [];
|
|
14001
|
-
for (var k in o2)
|
|
14002
|
-
if (Object.prototype.hasOwnProperty.call(o2, k))
|
|
14003
|
-
ar[ar.length] = k;
|
|
14004
|
-
return ar;
|
|
14005
|
-
};
|
|
14006
|
-
return ownKeys(o);
|
|
14007
|
-
};
|
|
14008
|
-
return function(mod) {
|
|
14009
|
-
if (mod && mod.__esModule)
|
|
14010
|
-
return mod;
|
|
14011
|
-
var result = {};
|
|
14012
|
-
if (mod != null) {
|
|
14013
|
-
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
14014
|
-
if (k[i] !== "default")
|
|
14015
|
-
__createBinding(result, mod, k[i]);
|
|
14016
|
-
}
|
|
14017
|
-
__setModuleDefault(result, mod);
|
|
14018
|
-
return result;
|
|
14019
|
-
};
|
|
14020
|
-
}();
|
|
14021
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14022
|
-
exports.NETWORK_TIMEOUTS = exports.DEFAULT_RETRY_CONFIG = void 0;
|
|
14023
|
-
exports.sleep = sleep;
|
|
14024
|
-
exports.isRetryableError = isRetryableError;
|
|
14025
|
-
exports.calculateDelay = calculateDelay;
|
|
14026
|
-
exports.withRetry = withRetry;
|
|
14027
|
-
exports.connectLitNodeClient = connectLitNodeClient;
|
|
14028
|
-
exports.connectLitContracts = connectLitContracts;
|
|
14029
|
-
exports.validateLitNodeConnection = validateLitNodeConnection;
|
|
14030
|
-
exports.generateSessionSignatures = generateSessionSignatures;
|
|
14031
|
-
exports.validateLitNodeReadiness = validateLitNodeReadiness;
|
|
14032
|
-
exports.executeLitAction = executeLitAction;
|
|
14033
|
-
exports.executePkpOperation = executePkpOperation;
|
|
14034
|
-
exports.getNetworkTimeouts = getNetworkTimeouts;
|
|
14035
|
-
var debug_logger_1 = require_debug_logger();
|
|
14036
|
-
var error_classification_1 = require_error_classification();
|
|
14037
|
-
exports.DEFAULT_RETRY_CONFIG = {
|
|
14013
|
+
var DEFAULT_RETRY_CONFIG = {
|
|
14038
14014
|
maxAttempts: 5,
|
|
14039
14015
|
// Increased from 3 for PKP operations
|
|
14040
14016
|
initialDelayMs: 2e3,
|
|
@@ -14068,80 +14044,85 @@ var require_connection_helpers = __commonJS({
|
|
|
14068
14044
|
function sleep(ms) {
|
|
14069
14045
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
14070
14046
|
}
|
|
14071
|
-
function isRetryableError(error, retryableErrors =
|
|
14047
|
+
function isRetryableError(error, retryableErrors = DEFAULT_RETRY_CONFIG.retryableErrors) {
|
|
14072
14048
|
if (!error)
|
|
14073
14049
|
return false;
|
|
14074
|
-
const classification =
|
|
14050
|
+
const classification = classifyError(error);
|
|
14075
14051
|
if (classification.isRetryable !== void 0) {
|
|
14076
|
-
|
|
14052
|
+
debugInfo("ERROR_CLASSIFICATION", `Error classified as: ${classification.category} (retryable: ${classification.isRetryable})`);
|
|
14077
14053
|
return classification.isRetryable;
|
|
14078
14054
|
}
|
|
14079
14055
|
const errorMessage = error.message || error.toString() || "";
|
|
14080
14056
|
const errorLower = errorMessage.toLowerCase();
|
|
14081
|
-
return retryableErrors.some(
|
|
14057
|
+
return retryableErrors.some(
|
|
14058
|
+
(pattern) => errorLower.includes(pattern.toLowerCase())
|
|
14059
|
+
);
|
|
14082
14060
|
}
|
|
14083
14061
|
function calculateDelay(attempt, config) {
|
|
14084
|
-
const exponentialDelay = Math.min(
|
|
14062
|
+
const exponentialDelay = Math.min(
|
|
14063
|
+
config.initialDelayMs * Math.pow(config.backoffMultiplier, attempt - 1),
|
|
14064
|
+
config.maxDelayMs
|
|
14065
|
+
);
|
|
14085
14066
|
const jitter = exponentialDelay * 0.25 * (Math.random() - 0.5);
|
|
14086
14067
|
return Math.max(100, exponentialDelay + jitter);
|
|
14087
14068
|
}
|
|
14088
14069
|
async function withRetry(operation, config = {}, operationName = "operation") {
|
|
14089
|
-
let finalConfig = { ...
|
|
14090
|
-
const tracker = new
|
|
14070
|
+
let finalConfig = { ...DEFAULT_RETRY_CONFIG, ...config };
|
|
14071
|
+
const tracker = new PerformanceTracker(`Retry ${operationName}`);
|
|
14091
14072
|
let lastError;
|
|
14092
14073
|
let errorClassification = null;
|
|
14093
14074
|
for (let attempt = 1; attempt <= finalConfig.maxAttempts; attempt++) {
|
|
14094
14075
|
try {
|
|
14095
|
-
|
|
14076
|
+
debugInfo("RETRY", `\u{1F504} [${operationName}] Attempt ${attempt}/${finalConfig.maxAttempts}`);
|
|
14096
14077
|
const startTime = Date.now();
|
|
14097
14078
|
const result = await operation();
|
|
14098
14079
|
const duration = Date.now() - startTime;
|
|
14099
|
-
|
|
14100
|
-
|
|
14080
|
+
debugInfo("RETRY", `\u2705 [${operationName}] Success after ${duration}ms (attempt ${attempt})`);
|
|
14081
|
+
networkMetrics.recordRequest(operationName, true, duration);
|
|
14101
14082
|
tracker.end(true);
|
|
14102
14083
|
return result;
|
|
14103
14084
|
} catch (error) {
|
|
14104
14085
|
lastError = error;
|
|
14105
14086
|
const errorMessage = error?.message || error?.toString() || "Unknown error";
|
|
14106
|
-
errorClassification =
|
|
14087
|
+
errorClassification = classifyError(error);
|
|
14107
14088
|
if (attempt === 1 && errorClassification) {
|
|
14108
|
-
const intelligentConfig =
|
|
14089
|
+
const intelligentConfig = getRetryConfigFromClassification(errorClassification);
|
|
14109
14090
|
finalConfig = {
|
|
14110
14091
|
...finalConfig,
|
|
14111
14092
|
...intelligentConfig,
|
|
14112
14093
|
maxAttempts: Math.min(finalConfig.maxAttempts, intelligentConfig.maxAttempts)
|
|
14113
14094
|
};
|
|
14114
|
-
|
|
14115
|
-
|
|
14095
|
+
debugInfo("RETRY", `\u{1F9E0} Intelligent retry strategy applied: ${errorClassification.category} (${errorClassification.retryStrategy})`);
|
|
14096
|
+
debugInfo("RETRY", `\u{1F4CA} Adjusted config: max=${finalConfig.maxAttempts}, delay=${finalConfig.initialDelayMs}ms`);
|
|
14116
14097
|
}
|
|
14117
|
-
|
|
14098
|
+
debugWarn("RETRY", `\u26A0\uFE0F [${operationName}] Attempt ${attempt} failed:`, {
|
|
14118
14099
|
error: errorMessage,
|
|
14119
14100
|
attempt,
|
|
14120
14101
|
category: errorClassification.category,
|
|
14121
14102
|
retryable: errorClassification.isRetryable
|
|
14122
14103
|
});
|
|
14123
|
-
|
|
14104
|
+
networkMetrics.recordRequest(operationName, false, 0, errorMessage);
|
|
14124
14105
|
if (attempt >= finalConfig.maxAttempts) {
|
|
14125
|
-
|
|
14106
|
+
debugError("RETRY", `\u274C [${operationName}] All attempts failed. Last error:`, { error: errorMessage });
|
|
14126
14107
|
if (errorClassification) {
|
|
14127
|
-
const errorReport =
|
|
14128
|
-
|
|
14108
|
+
const errorReport = createErrorReport(error);
|
|
14109
|
+
debugError("RETRY", `\u{1F4CB} Error Analysis Report:
|
|
14129
14110
|
${errorReport}`);
|
|
14130
14111
|
}
|
|
14131
14112
|
tracker.end(false);
|
|
14132
14113
|
break;
|
|
14133
14114
|
}
|
|
14134
14115
|
if (!errorClassification.isRetryable) {
|
|
14135
|
-
|
|
14116
|
+
debugError("RETRY", `\u{1F6AB} [${operationName}] Non-retryable error (${errorClassification.category}):`, { error: errorMessage });
|
|
14136
14117
|
if (errorClassification.troubleshooting) {
|
|
14137
|
-
|
|
14118
|
+
debugInfo("RETRY", `\u{1F4A1} Troubleshooting suggestions:
|
|
14138
14119
|
${errorClassification.troubleshooting.join("\n ")}`);
|
|
14139
14120
|
}
|
|
14140
14121
|
tracker.end(false);
|
|
14141
14122
|
break;
|
|
14142
14123
|
}
|
|
14143
14124
|
const delayMs = calculateDelay(attempt, finalConfig);
|
|
14144
|
-
|
|
14125
|
+
debugInfo("RETRY", `\u23F3 [${operationName}] Waiting ${delayMs}ms before retry... (${errorClassification.retryStrategy} strategy)`);
|
|
14145
14126
|
await sleep(delayMs);
|
|
14146
14127
|
}
|
|
14147
14128
|
}
|
|
@@ -14149,36 +14130,44 @@ ${errorReport}`);
|
|
|
14149
14130
|
}
|
|
14150
14131
|
async function connectLitNodeClient(litNodeClient, config = {}) {
|
|
14151
14132
|
const network = litNodeClient?.config?.litNetwork || "unknown";
|
|
14152
|
-
return withRetry(
|
|
14153
|
-
|
|
14154
|
-
|
|
14155
|
-
|
|
14156
|
-
|
|
14157
|
-
|
|
14158
|
-
|
|
14159
|
-
|
|
14160
|
-
|
|
14161
|
-
|
|
14162
|
-
|
|
14163
|
-
|
|
14164
|
-
|
|
14165
|
-
|
|
14166
|
-
|
|
14167
|
-
|
|
14168
|
-
|
|
14169
|
-
|
|
14170
|
-
|
|
14171
|
-
|
|
14133
|
+
return withRetry(
|
|
14134
|
+
async () => {
|
|
14135
|
+
if (!litNodeClient) {
|
|
14136
|
+
throw new Error("LIT Node Client is null or undefined");
|
|
14137
|
+
}
|
|
14138
|
+
const startTime = Date.now();
|
|
14139
|
+
logConnectionAttempt(network, 1, config.maxAttempts || DEFAULT_RETRY_CONFIG.maxAttempts);
|
|
14140
|
+
await litNodeClient.connect();
|
|
14141
|
+
debugInfo("CONNECTION", `\u23F3 Waiting for LIT Node Client to be ready...`);
|
|
14142
|
+
const readyTimeout = 3e4;
|
|
14143
|
+
const readyStartTime = Date.now();
|
|
14144
|
+
while (!litNodeClient.ready && Date.now() - readyStartTime < readyTimeout) {
|
|
14145
|
+
await sleep(500);
|
|
14146
|
+
}
|
|
14147
|
+
if (!litNodeClient.ready) {
|
|
14148
|
+
throw new Error(`LIT Node Client failed to become ready within ${readyTimeout}ms`);
|
|
14149
|
+
}
|
|
14150
|
+
const latency = Date.now() - startTime;
|
|
14151
|
+
debugInfo("CONNECTION", `\u2705 LIT Node Client is ready (${litNodeClient.ready})`);
|
|
14152
|
+
logConnectionSuccess(network, latency);
|
|
14153
|
+
},
|
|
14154
|
+
config,
|
|
14155
|
+
"LIT Node Client Connection"
|
|
14156
|
+
);
|
|
14172
14157
|
}
|
|
14173
14158
|
async function connectLitContracts(litContracts, config = {}) {
|
|
14174
|
-
return withRetry(
|
|
14175
|
-
|
|
14176
|
-
|
|
14177
|
-
|
|
14178
|
-
|
|
14179
|
-
|
|
14180
|
-
|
|
14181
|
-
|
|
14159
|
+
return withRetry(
|
|
14160
|
+
async () => {
|
|
14161
|
+
if (!litContracts) {
|
|
14162
|
+
throw new Error("LIT Contracts is null or undefined");
|
|
14163
|
+
}
|
|
14164
|
+
console.log(`\u{1F517} Connecting to LIT Contracts: ${litContracts.network || "unknown"}`);
|
|
14165
|
+
await litContracts.connect();
|
|
14166
|
+
console.log("\u2705 LIT Contracts connected successfully");
|
|
14167
|
+
},
|
|
14168
|
+
config,
|
|
14169
|
+
"LIT Contracts Connection"
|
|
14170
|
+
);
|
|
14182
14171
|
}
|
|
14183
14172
|
async function validateLitNodeConnection(litNodeClient) {
|
|
14184
14173
|
try {
|
|
@@ -14198,33 +14187,37 @@ ${errorReport}`);
|
|
|
14198
14187
|
}
|
|
14199
14188
|
async function generateSessionSignatures(litNodeClient, sessionConfig, config = {}, pkpTokenId, litActionCid, signerAddress, network = "chipotle") {
|
|
14200
14189
|
if (pkpTokenId && litActionCid && signerAddress) {
|
|
14201
|
-
const { sessionSignatureCache } = await Promise.resolve().then(() =>
|
|
14202
|
-
const cached =
|
|
14190
|
+
const { sessionSignatureCache: sessionSignatureCache2 } = await Promise.resolve().then(() => (init_session_signature_cache(), session_signature_cache_exports));
|
|
14191
|
+
const cached = sessionSignatureCache2.get(pkpTokenId, litActionCid, signerAddress, network);
|
|
14203
14192
|
if (cached) {
|
|
14204
14193
|
const sigCount = Object.keys(cached).length;
|
|
14205
|
-
|
|
14194
|
+
debugInfo("SESSION", `\u{1F504} Using cached session signatures (${sigCount} sigs)`);
|
|
14206
14195
|
return cached;
|
|
14207
14196
|
}
|
|
14208
14197
|
}
|
|
14209
|
-
return withRetry(
|
|
14210
|
-
(
|
|
14211
|
-
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
|
|
14215
|
-
|
|
14216
|
-
|
|
14217
|
-
|
|
14218
|
-
|
|
14219
|
-
|
|
14220
|
-
|
|
14198
|
+
return withRetry(
|
|
14199
|
+
async () => {
|
|
14200
|
+
debugInfo("SESSION", "\u{1F510} Generating new session signatures...");
|
|
14201
|
+
const sessionSigs = await litNodeClient.getSessionSigs(sessionConfig);
|
|
14202
|
+
const sigCount = Object.keys(sessionSigs).length;
|
|
14203
|
+
if (pkpTokenId && litActionCid && signerAddress) {
|
|
14204
|
+
const { sessionSignatureCache: sessionSignatureCache2 } = await Promise.resolve().then(() => (init_session_signature_cache(), session_signature_cache_exports));
|
|
14205
|
+
const expiration = new Date(sessionConfig.expiration);
|
|
14206
|
+
sessionSignatureCache2.set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration);
|
|
14207
|
+
}
|
|
14208
|
+
debugInfo("SESSION", `\u2705 Generated ${sigCount} session signatures`);
|
|
14209
|
+
return sessionSigs;
|
|
14210
|
+
},
|
|
14211
|
+
config,
|
|
14212
|
+
"Session Signature Generation"
|
|
14213
|
+
);
|
|
14221
14214
|
}
|
|
14222
14215
|
async function validateLitNodeReadiness(litNodeClient) {
|
|
14223
14216
|
if (!litNodeClient) {
|
|
14224
14217
|
throw new Error("LIT Node Client is null or undefined");
|
|
14225
14218
|
}
|
|
14226
14219
|
if (!litNodeClient.ready) {
|
|
14227
|
-
|
|
14220
|
+
debugWarn("CONNECTION", "\u26A0\uFE0F LIT Node Client not ready, attempting to reconnect...");
|
|
14228
14221
|
await litNodeClient.connect();
|
|
14229
14222
|
const readyTimeout = 15e3;
|
|
14230
14223
|
const startTime = Date.now();
|
|
@@ -14235,32 +14228,36 @@ ${errorReport}`);
|
|
|
14235
14228
|
throw new Error("LIT Node Client is not ready for operations");
|
|
14236
14229
|
}
|
|
14237
14230
|
}
|
|
14238
|
-
|
|
14231
|
+
debugInfo("CONNECTION", "\u2705 LIT Node Client readiness validated");
|
|
14239
14232
|
}
|
|
14240
14233
|
async function executeLitAction(litNodeClient, executionConfig, config = {}) {
|
|
14241
14234
|
const cid = executionConfig.ipfsId;
|
|
14242
|
-
return withRetry(
|
|
14243
|
-
|
|
14244
|
-
|
|
14245
|
-
|
|
14246
|
-
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
(
|
|
14251
|
-
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
|
|
14255
|
-
|
|
14256
|
-
|
|
14235
|
+
return withRetry(
|
|
14236
|
+
async () => {
|
|
14237
|
+
const startTime = Date.now();
|
|
14238
|
+
await validateLitNodeReadiness(litNodeClient);
|
|
14239
|
+
logLitActionExecution(cid, executionConfig.jsParams);
|
|
14240
|
+
logRequest("LIT_ACTION", "executeJs", executionConfig);
|
|
14241
|
+
const result = await litNodeClient.executeJs(executionConfig);
|
|
14242
|
+
const duration = Date.now() - startTime;
|
|
14243
|
+
if (!result.response) {
|
|
14244
|
+
logError("LIT_ACTION", "executeJs", new Error("No response from LIT Action"), duration);
|
|
14245
|
+
throw new Error("No response from LIT Action");
|
|
14246
|
+
}
|
|
14247
|
+
logResponse("LIT_ACTION", "executeJs", result, duration);
|
|
14248
|
+
logLitActionResult(cid, true, duration, result);
|
|
14249
|
+
return result;
|
|
14250
|
+
},
|
|
14251
|
+
config,
|
|
14252
|
+
"LIT Action Execution"
|
|
14253
|
+
);
|
|
14257
14254
|
}
|
|
14258
14255
|
async function executePkpOperation(operation, operationName, config = {}) {
|
|
14259
14256
|
const pkpConfig = {
|
|
14260
|
-
...
|
|
14257
|
+
...DEFAULT_RETRY_CONFIG,
|
|
14261
14258
|
...config,
|
|
14262
14259
|
retryableErrors: [
|
|
14263
|
-
...
|
|
14260
|
+
...DEFAULT_RETRY_CONFIG.retryableErrors,
|
|
14264
14261
|
"pkp validation",
|
|
14265
14262
|
"signing shares",
|
|
14266
14263
|
"resource validation",
|
|
@@ -14269,7 +14266,7 @@ ${errorReport}`);
|
|
|
14269
14266
|
};
|
|
14270
14267
|
return withRetry(operation, pkpConfig, `PKP ${operationName}`);
|
|
14271
14268
|
}
|
|
14272
|
-
|
|
14269
|
+
var NETWORK_TIMEOUTS = {
|
|
14273
14270
|
chipotle: {
|
|
14274
14271
|
connection: 6e4,
|
|
14275
14272
|
operation: 12e4,
|
|
@@ -14277,82 +14274,10 @@ ${errorReport}`);
|
|
|
14277
14274
|
}
|
|
14278
14275
|
};
|
|
14279
14276
|
function getNetworkTimeouts(network) {
|
|
14280
|
-
return
|
|
14277
|
+
return NETWORK_TIMEOUTS[network] || NETWORK_TIMEOUTS["chipotle"];
|
|
14281
14278
|
}
|
|
14282
|
-
|
|
14283
|
-
|
|
14284
|
-
|
|
14285
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/index.js
|
|
14286
|
-
var require_utils4 = __commonJS({
|
|
14287
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/index.js"(exports) {
|
|
14288
|
-
"use strict";
|
|
14289
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
14290
|
-
if (k2 === void 0)
|
|
14291
|
-
k2 = k;
|
|
14292
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14293
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14294
|
-
desc = { enumerable: true, get: function() {
|
|
14295
|
-
return m[k];
|
|
14296
|
-
} };
|
|
14297
|
-
}
|
|
14298
|
-
Object.defineProperty(o, k2, desc);
|
|
14299
|
-
} : function(o, m, k, k2) {
|
|
14300
|
-
if (k2 === void 0)
|
|
14301
|
-
k2 = k;
|
|
14302
|
-
o[k2] = m[k];
|
|
14303
|
-
});
|
|
14304
|
-
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
14305
|
-
for (var p in m)
|
|
14306
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
14307
|
-
__createBinding(exports2, m, p);
|
|
14308
|
-
};
|
|
14309
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14310
|
-
__exportStar(require_lit_action_helpers(), exports);
|
|
14311
|
-
__exportStar(require_pkp_setup(), exports);
|
|
14312
|
-
__exportStar(require_cid_utils(), exports);
|
|
14313
|
-
__exportStar(require_connection_helpers(), exports);
|
|
14314
|
-
__exportStar(require_debug_logger(), exports);
|
|
14315
|
-
__exportStar(require_error_classification(), exports);
|
|
14316
|
-
__exportStar(require_session_signature_cache(), exports);
|
|
14317
|
-
}
|
|
14318
|
-
});
|
|
14319
|
-
|
|
14320
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js
|
|
14321
|
-
var require_pkg_src = __commonJS({
|
|
14322
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js"(exports) {
|
|
14323
|
-
"use strict";
|
|
14324
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
14325
|
-
if (k2 === void 0)
|
|
14326
|
-
k2 = k;
|
|
14327
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14328
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14329
|
-
desc = { enumerable: true, get: function() {
|
|
14330
|
-
return m[k];
|
|
14331
|
-
} };
|
|
14332
|
-
}
|
|
14333
|
-
Object.defineProperty(o, k2, desc);
|
|
14334
|
-
} : function(o, m, k, k2) {
|
|
14335
|
-
if (k2 === void 0)
|
|
14336
|
-
k2 = k;
|
|
14337
|
-
o[k2] = m[k];
|
|
14338
|
-
});
|
|
14339
|
-
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
14340
|
-
for (var p in m)
|
|
14341
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
14342
|
-
__createBinding(exports2, m, p);
|
|
14343
|
-
};
|
|
14344
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14345
|
-
exports.CHIPOTLE_DEPLOYMENTS = exports.DH_LIT_ACTIONS_CHIPOTLE = void 0;
|
|
14346
|
-
__exportStar(require_interfaces(), exports);
|
|
14347
|
-
__exportStar(require_lit_actions_registry(), exports);
|
|
14348
|
-
__exportStar(require_utils4(), exports);
|
|
14349
|
-
var lit_actions_registry_1 = require_lit_actions_registry();
|
|
14350
|
-
Object.defineProperty(exports, "DH_LIT_ACTIONS_CHIPOTLE", { enumerable: true, get: function() {
|
|
14351
|
-
return lit_actions_registry_1.DH_LIT_ACTIONS_CHIPOTLE;
|
|
14352
|
-
} });
|
|
14353
|
-
Object.defineProperty(exports, "CHIPOTLE_DEPLOYMENTS", { enumerable: true, get: function() {
|
|
14354
|
-
return lit_actions_registry_1.CHIPOTLE_DEPLOYMENTS;
|
|
14355
|
-
} });
|
|
14279
|
+
init_debug_logger();
|
|
14280
|
+
init_session_signature_cache();
|
|
14356
14281
|
}
|
|
14357
14282
|
});
|
|
14358
14283
|
|
|
@@ -14406,53 +14331,53 @@ var init_deployment_addresses = __esm({
|
|
|
14406
14331
|
},
|
|
14407
14332
|
upgraded: {
|
|
14408
14333
|
PositionManager: {
|
|
14409
|
-
previousImplementation: "
|
|
14410
|
-
newImplementation: "
|
|
14411
|
-
upgradedAt: "2026-04-
|
|
14334
|
+
previousImplementation: "0x1b854fE920AC409b5f407b3ABCd556C998F889E5",
|
|
14335
|
+
newImplementation: "0xd163965Ea2e33d58635bf24B7539f0df3D384933",
|
|
14336
|
+
upgradedAt: "2026-04-30T08:33:24.883Z",
|
|
14412
14337
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14413
14338
|
reason: "Shared upgrade script: PositionManager implementation update"
|
|
14414
14339
|
},
|
|
14415
14340
|
LoanOperationsManagerModule: {
|
|
14416
|
-
previousImplementation: "
|
|
14417
|
-
newImplementation: "
|
|
14418
|
-
upgradedAt: "2026-04-
|
|
14341
|
+
previousImplementation: "0x448Fb59Cad99FFe3d0766F6943E4B579A824d46b",
|
|
14342
|
+
newImplementation: "0x8880D85Da2F8e60D4e91AE2457C34d76659dfa71",
|
|
14343
|
+
upgradedAt: "2026-04-30T08:34:13.649Z",
|
|
14419
14344
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14420
14345
|
reason: "Shared upgrade script: LoanOperationsManagerModule implementation update"
|
|
14421
14346
|
},
|
|
14422
14347
|
UCDController: {
|
|
14423
|
-
previousImplementation: "
|
|
14424
|
-
newImplementation: "
|
|
14425
|
-
upgradedAt: "2026-04-
|
|
14348
|
+
previousImplementation: "0xB5322F0D4a07d4342FA38137ebD95ac41D1c6036",
|
|
14349
|
+
newImplementation: "0x2d4d689A70B56b6E0B9F70BffA6265A55173A4A1",
|
|
14350
|
+
upgradedAt: "2026-04-30T08:24:24.765Z",
|
|
14426
14351
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14427
14352
|
reason: "Shared upgrade script: UCDController implementation update"
|
|
14428
14353
|
},
|
|
14429
14354
|
TermManagerModule: {
|
|
14430
|
-
previousImplementation: "
|
|
14431
|
-
newImplementation: "
|
|
14432
|
-
upgradedAt: "2026-04-
|
|
14355
|
+
previousImplementation: "0x1D5E5A93215E49aA7260dA8d3B3de9faA686C087",
|
|
14356
|
+
newImplementation: "0x2EaF1052706120CAa6B6F75354F70f77ef2261eB",
|
|
14357
|
+
upgradedAt: "2026-04-30T08:26:37.176Z",
|
|
14433
14358
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14434
14359
|
reason: "Shared upgrade script: TermManagerModule implementation update"
|
|
14435
14360
|
},
|
|
14436
14361
|
CircuitBreakerModule: {
|
|
14437
|
-
previousImplementation: "
|
|
14438
|
-
newImplementation: "
|
|
14439
|
-
upgradedAt: "2026-04-
|
|
14362
|
+
previousImplementation: "0xa4940082a7b58c45C3885C4B59714C0dD048cDdC",
|
|
14363
|
+
newImplementation: "0x8e9e10B14E6a91ec271FBEb4FD3fB1FE06b545dD",
|
|
14364
|
+
upgradedAt: "2026-04-30T08:29:37.131Z",
|
|
14440
14365
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14441
14366
|
reason: "Shared upgrade script: CircuitBreakerModule implementation update"
|
|
14442
14367
|
},
|
|
14443
14368
|
AdminModule: {
|
|
14444
|
-
previousImplementation: "
|
|
14445
|
-
newImplementation: "
|
|
14446
|
-
upgradedAt: "2026-04-
|
|
14369
|
+
previousImplementation: "0x8bDe850573a947b816D1EC5C5Ca177853bDfD049",
|
|
14370
|
+
newImplementation: "0x67AE2F872c37f33db9bC631e135432B2845d308b",
|
|
14371
|
+
upgradedAt: "2026-04-30T08:31:13.444Z",
|
|
14447
14372
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14448
|
-
reason: "
|
|
14373
|
+
reason: "Shared upgrade script: AdminModule implementation update"
|
|
14449
14374
|
},
|
|
14450
14375
|
PositionManagerViews: {
|
|
14451
|
-
previousImplementation: "
|
|
14452
|
-
newImplementation: "
|
|
14453
|
-
upgradedAt: "2026-04-
|
|
14376
|
+
previousImplementation: "0xE8b4D4b6E3163EdfF8958da4cF8267ACa369D486",
|
|
14377
|
+
newImplementation: "0xadF8e0F34082a8fC23e727276e0aEf3af183C8Fd",
|
|
14378
|
+
upgradedAt: "2026-04-30T08:32:48.463Z",
|
|
14454
14379
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14455
|
-
reason: "
|
|
14380
|
+
reason: "Shared upgrade script: PositionManagerViews implementation update"
|
|
14456
14381
|
},
|
|
14457
14382
|
TestPositionManager: {
|
|
14458
14383
|
previousImplementation: "0x0B46Ee1a9C6b42559758B7FF78294Cd867BB08f8",
|
|
@@ -14462,51 +14387,51 @@ var init_deployment_addresses = __esm({
|
|
|
14462
14387
|
reason: "Add setPositionExpiry() for expiry-liquidation E2E testing"
|
|
14463
14388
|
},
|
|
14464
14389
|
UCDToken: {
|
|
14465
|
-
previousImplementation: "
|
|
14466
|
-
newImplementation: "
|
|
14467
|
-
upgradedAt: "2026-04-
|
|
14390
|
+
previousImplementation: "0xEFFF6f32Fc33C4Cb58a4d6858Bf90B8feA7D1D33",
|
|
14391
|
+
newImplementation: "0x155Da00Ee0beb1d9D5BA34Aeb62c9ad4E8227d5D",
|
|
14392
|
+
upgradedAt: "2026-04-30T08:25:01.929Z",
|
|
14468
14393
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14469
14394
|
reason: "Shared upgrade script: UCDToken implementation update"
|
|
14470
14395
|
},
|
|
14471
14396
|
PositionManagerCoreModule: {
|
|
14472
|
-
previousImplementation: "
|
|
14473
|
-
newImplementation: "
|
|
14474
|
-
upgradedAt: "2026-04-
|
|
14397
|
+
previousImplementation: "0xeA5234c8E3a5F61c660db529d9d6f91fd989B56E",
|
|
14398
|
+
newImplementation: "0x41168d9BF8e696eBAB05ea539321ac212859d80b",
|
|
14399
|
+
upgradedAt: "2026-04-30T09:32:01.570Z",
|
|
14475
14400
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14476
14401
|
reason: "Shared upgrade script: PositionManagerCoreModule implementation update"
|
|
14477
14402
|
},
|
|
14478
14403
|
CollateralManagerModule: {
|
|
14479
|
-
previousImplementation: "
|
|
14480
|
-
newImplementation: "
|
|
14481
|
-
upgradedAt: "2026-04-
|
|
14404
|
+
previousImplementation: "0x84C5B89f60415F8df3Fee46Ef1a10a6484aa8e0A",
|
|
14405
|
+
newImplementation: "0xd021ca6Dc2377F361E3c64f60C93E0e4075c2840",
|
|
14406
|
+
upgradedAt: "2026-04-30T08:27:24.702Z",
|
|
14482
14407
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14483
14408
|
reason: "Shared upgrade script: CollateralManagerModule implementation update"
|
|
14484
14409
|
},
|
|
14485
14410
|
LiquidationManagerModule: {
|
|
14486
|
-
previousImplementation: "
|
|
14487
|
-
newImplementation: "
|
|
14488
|
-
upgradedAt: "2026-04-
|
|
14411
|
+
previousImplementation: "0xBb625E44d72f3F1acDCbB08F73AFdAc38fCE3F64",
|
|
14412
|
+
newImplementation: "0xf74d5437691df92087170861213e26064358A7fb",
|
|
14413
|
+
upgradedAt: "2026-04-30T08:29:01.327Z",
|
|
14489
14414
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14490
14415
|
reason: "Shared upgrade script: LiquidationManagerModule implementation update"
|
|
14491
14416
|
},
|
|
14492
14417
|
BTCSpendAuthorizer: {
|
|
14493
|
-
previousImplementation: "
|
|
14494
|
-
newImplementation: "
|
|
14495
|
-
upgradedAt: "2026-04-
|
|
14418
|
+
previousImplementation: "0x0B46DCdB63CB9928789ef1979C367da6ef04beAf",
|
|
14419
|
+
newImplementation: "0x4CD021181bD2583d10aB37D27FE2994b75c41b77",
|
|
14420
|
+
upgradedAt: "2026-04-30T08:32:02.761Z",
|
|
14496
14421
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14497
14422
|
reason: "Shared upgrade script: BTCSpendAuthorizer implementation update"
|
|
14498
14423
|
},
|
|
14499
14424
|
SimplePSMV2: {
|
|
14500
|
-
previousImplementation: "
|
|
14501
|
-
newImplementation: "
|
|
14502
|
-
upgradedAt: "2026-04-
|
|
14425
|
+
previousImplementation: "0xBdEFa375db7F9A498B81bcfdDd14FD16D02ca0BF",
|
|
14426
|
+
newImplementation: "0x4107104fDF61AACC674f1F168c275f034c8112BF",
|
|
14427
|
+
upgradedAt: "2026-04-30T08:35:01.138Z",
|
|
14503
14428
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14504
14429
|
reason: "Shared upgrade script: SimplePSMV2 implementation update"
|
|
14505
14430
|
},
|
|
14506
14431
|
UpgradeValidator: {
|
|
14507
|
-
previousImplementation: "
|
|
14508
|
-
newImplementation: "
|
|
14509
|
-
upgradedAt: "2026-04-
|
|
14432
|
+
previousImplementation: "0xE410d1028Cdf2D94E3F5049F2D04B573703A2804",
|
|
14433
|
+
newImplementation: "0x974C6F4e0F67Fa9d7Ab1aee8C10Bd85B201ec5D7",
|
|
14434
|
+
upgradedAt: "2026-04-30T09:32:25.094Z",
|
|
14510
14435
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14511
14436
|
reason: "Shared upgrade script: UpgradeValidator implementation update"
|
|
14512
14437
|
},
|
|
@@ -14583,26 +14508,26 @@ var init_deployment_addresses = __esm({
|
|
|
14583
14508
|
POSITION_MANAGER_VIEWS: "0x3b970E41a0668508B4B2ACb83653b2A402F745AE",
|
|
14584
14509
|
CIRCUIT_BREAKER_MODULE: "0x3D0B2cAE481821E57BA9CC3807bCC0d0D7F18bd8",
|
|
14585
14510
|
ADMIN_MODULE: "0xAcd1f07915b17CA3727e7fE89BdF618A1545a1ed",
|
|
14586
|
-
UCD_CONTROLLER_IMPL: "
|
|
14587
|
-
LOAN_OPERATIONS_MANAGER_MODULE_IMPL: "
|
|
14588
|
-
TERM_MANAGER_MODULE_IMPL: "
|
|
14589
|
-
CIRCUIT_BREAKER_MODULE_IMPL: "
|
|
14590
|
-
ADMIN_MODULE_IMPL: "
|
|
14591
|
-
POSITION_MANAGER_VIEWS_IMPL: "
|
|
14592
|
-
POSITION_MANAGER_IMPL: "
|
|
14511
|
+
UCD_CONTROLLER_IMPL: "0x2d4d689A70B56b6E0B9F70BffA6265A55173A4A1",
|
|
14512
|
+
LOAN_OPERATIONS_MANAGER_MODULE_IMPL: "0x8880D85Da2F8e60D4e91AE2457C34d76659dfa71",
|
|
14513
|
+
TERM_MANAGER_MODULE_IMPL: "0x2EaF1052706120CAa6B6F75354F70f77ef2261eB",
|
|
14514
|
+
CIRCUIT_BREAKER_MODULE_IMPL: "0x8e9e10B14E6a91ec271FBEb4FD3fB1FE06b545dD",
|
|
14515
|
+
ADMIN_MODULE_IMPL: "0x67AE2F872c37f33db9bC631e135432B2845d308b",
|
|
14516
|
+
POSITION_MANAGER_VIEWS_IMPL: "0xadF8e0F34082a8fC23e727276e0aEf3af183C8Fd",
|
|
14517
|
+
POSITION_MANAGER_IMPL: "0xd163965Ea2e33d58635bf24B7539f0df3D384933",
|
|
14593
14518
|
SIMPLE_PSM_V2: "0x19EcF7BA26e054fd4Ff06009A03070103dbBB058",
|
|
14594
|
-
SIMPLE_PSM_V2_IMPL: "
|
|
14595
|
-
UCD_TOKEN_IMPL: "
|
|
14519
|
+
SIMPLE_PSM_V2_IMPL: "0x4107104fDF61AACC674f1F168c275f034c8112BF",
|
|
14520
|
+
UCD_TOKEN_IMPL: "0x155Da00Ee0beb1d9D5BA34Aeb62c9ad4E8227d5D",
|
|
14596
14521
|
POSITION_MANAGER_CORE_MODULE: "0xfFAA39a08887FeFB697eBC8691A8630CbCC33391",
|
|
14597
|
-
POSITION_MANAGER_CORE_MODULE_IMPL: "
|
|
14522
|
+
POSITION_MANAGER_CORE_MODULE_IMPL: "0x41168d9BF8e696eBAB05ea539321ac212859d80b",
|
|
14598
14523
|
COLLATERAL_MANAGER_MODULE: "0x967E92c976Fc0fa8268D37D4d6B7245d912aA7dB",
|
|
14599
|
-
COLLATERAL_MANAGER_MODULE_IMPL: "
|
|
14524
|
+
COLLATERAL_MANAGER_MODULE_IMPL: "0xd021ca6Dc2377F361E3c64f60C93E0e4075c2840",
|
|
14600
14525
|
LIQUIDATION_MANAGER_MODULE: "0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76",
|
|
14601
|
-
LIQUIDATION_MANAGER_MODULE_IMPL: "
|
|
14526
|
+
LIQUIDATION_MANAGER_MODULE_IMPL: "0xf74d5437691df92087170861213e26064358A7fb",
|
|
14602
14527
|
BTC_SPEND_AUTHORIZER: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
|
|
14603
|
-
BTC_SPEND_AUTHORIZER_IMPL: "
|
|
14528
|
+
BTC_SPEND_AUTHORIZER_IMPL: "0x4CD021181bD2583d10aB37D27FE2994b75c41b77",
|
|
14604
14529
|
UPGRADE_VALIDATOR: "0x592e650edD9bA26ecc407989fdd6F9cdcDeC27A6",
|
|
14605
|
-
UPGRADE_VALIDATOR_IMPL: "
|
|
14530
|
+
UPGRADE_VALIDATOR_IMPL: "0x974C6F4e0F67Fa9d7Ab1aee8C10Bd85B201ec5D7",
|
|
14606
14531
|
BITCOIN_PROVIDER_REGISTRY: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
|
|
14607
14532
|
BITCOIN_PROVIDER_REGISTRY_IMPL: "0x225309A4ae6D146ba93A3278A7b40224FfC81448",
|
|
14608
14533
|
LIT_ACTION_VALIDATOR: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
|
|
@@ -14633,68 +14558,66 @@ var init_deployment_addresses = __esm({
|
|
|
14633
14558
|
LOCALHOST_DEPLOYMENT = {
|
|
14634
14559
|
network: "localhost",
|
|
14635
14560
|
chainId: 31337,
|
|
14636
|
-
timestamp: "2026-
|
|
14561
|
+
timestamp: "2026-03-23T15:33:34.068Z",
|
|
14637
14562
|
deployer: "",
|
|
14638
14563
|
contracts: {
|
|
14639
|
-
MessageHashBuilder: "
|
|
14640
|
-
UpgradeValidator: "
|
|
14564
|
+
MessageHashBuilder: "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
|
|
14565
|
+
UpgradeValidator: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
|
|
14641
14566
|
UCDToken: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
14642
14567
|
UCDController: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
14643
|
-
PositionManagerCoreModule: "
|
|
14644
|
-
TermManagerModule: "
|
|
14645
|
-
LoanOperationsManagerModule: "
|
|
14568
|
+
PositionManagerCoreModule: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
14569
|
+
TermManagerModule: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
|
|
14570
|
+
LoanOperationsManagerModule: "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
|
|
14646
14571
|
BTCSpendAuthorizer: "0x59b670e9fA9D0A427751Af201D676719a970857b",
|
|
14647
14572
|
CollateralManagerModule: "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
|
|
14648
14573
|
LiquidationManagerModule: "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
|
|
14649
|
-
CircuitBreakerModule: "
|
|
14574
|
+
CircuitBreakerModule: "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
|
|
14650
14575
|
AdminModule: "0xc5a5C42992dECbae36851359345FE25997F5C42d",
|
|
14651
|
-
PositionManagerViews: "
|
|
14652
|
-
PositionManager: "
|
|
14653
|
-
OperationAuthorizationRegistry: "
|
|
14654
|
-
PKPValidation: "
|
|
14576
|
+
PositionManagerViews: "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
|
|
14577
|
+
PositionManager: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
|
|
14578
|
+
OperationAuthorizationRegistry: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
|
|
14579
|
+
PKPValidation: "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc"
|
|
14655
14580
|
},
|
|
14656
14581
|
latestEnv: {
|
|
14657
14582
|
UCD_TOKEN: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
14658
14583
|
UCD_CONTROLLER: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
14659
|
-
POSITION_MANAGER: "
|
|
14660
|
-
PKP_VALIDATION_REGISTRY: "
|
|
14661
|
-
PKP_VALIDATION_CID_V1: "
|
|
14662
|
-
|
|
14663
|
-
|
|
14664
|
-
|
|
14665
|
-
UCD_MINT_VALIDATOR_ADDRESS: "0x4D9299055093938d0CD2F26C42A87260CB50adD8",
|
|
14584
|
+
POSITION_MANAGER: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
|
|
14585
|
+
PKP_VALIDATION_REGISTRY: "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc",
|
|
14586
|
+
PKP_VALIDATION_CID_V1: "QmfHJKA4RnW7RepsdLmrDwKjVTzPXB2K3qMTco3JNPDexm",
|
|
14587
|
+
PKP_ETH_ADDRESS: "0x9624C46073E1d1F5AB975c67Fc899536d599bb57",
|
|
14588
|
+
OPERATION_AUTHORIZATION_REGISTRY: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
|
|
14589
|
+
UCD_MINT_VALIDATOR_ADDRESS: "0x80f81afb9e6dF27afCD752ad46cD286e705e42be",
|
|
14666
14590
|
UCD_MINT_VALIDATOR_VERSION: 1,
|
|
14667
|
-
BTC_WITHDRAWAL_VALIDATOR_ADDRESS: "
|
|
14591
|
+
BTC_WITHDRAWAL_VALIDATOR_ADDRESS: "0xa751ad81E1CAe61d6cF5Cf64839Fe8D28A1372Df",
|
|
14668
14592
|
BTC_WITHDRAWAL_VALIDATOR_VERSION: 1,
|
|
14669
|
-
UPDATE_BALANCE_VALIDATOR_ADDRESS: "
|
|
14593
|
+
UPDATE_BALANCE_VALIDATOR_ADDRESS: "0x8A40C22B03348bc10df9ae0dc54346b4AE8e909c",
|
|
14670
14594
|
UPDATE_BALANCE_VALIDATOR_VERSION: 1,
|
|
14671
|
-
PROCESS_PAYMENT_VALIDATOR_ADDRESS: "
|
|
14595
|
+
PROCESS_PAYMENT_VALIDATOR_ADDRESS: "0x28f50E07532d3aF677b8E0bcF220422d159b0dd6",
|
|
14672
14596
|
PROCESS_PAYMENT_VALIDATOR_VERSION: 1,
|
|
14673
|
-
EXTEND_POSITION_VALIDATOR_ADDRESS: "
|
|
14597
|
+
EXTEND_POSITION_VALIDATOR_ADDRESS: "0xc7aC43F2F907123465449575e853f5D0229898e1",
|
|
14674
14598
|
EXTEND_POSITION_VALIDATOR_VERSION: 1,
|
|
14675
|
-
POSITION_MANAGER_CORE_MODULE: "
|
|
14676
|
-
LOAN_OPERATIONS_MANAGER_MODULE: "
|
|
14677
|
-
TERM_MANAGER_MODULE: "
|
|
14678
|
-
COMMUNITY_MANAGER_MODULE: ""
|
|
14599
|
+
POSITION_MANAGER_CORE_MODULE: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
14600
|
+
LOAN_OPERATIONS_MANAGER_MODULE: "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
|
|
14601
|
+
TERM_MANAGER_MODULE: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82"
|
|
14679
14602
|
}
|
|
14680
14603
|
};
|
|
14681
14604
|
LOCALHOST_CONTRACTS = {
|
|
14682
|
-
MessageHashBuilder: "
|
|
14683
|
-
UpgradeValidator: "
|
|
14605
|
+
MessageHashBuilder: "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
|
|
14606
|
+
UpgradeValidator: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
|
|
14684
14607
|
UCDToken: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
14685
14608
|
UCDController: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
14686
|
-
PositionManagerCoreModule: "
|
|
14687
|
-
TermManagerModule: "
|
|
14688
|
-
LoanOperationsManagerModule: "
|
|
14609
|
+
PositionManagerCoreModule: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
14610
|
+
TermManagerModule: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
|
|
14611
|
+
LoanOperationsManagerModule: "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
|
|
14689
14612
|
BTCSpendAuthorizer: "0x59b670e9fA9D0A427751Af201D676719a970857b",
|
|
14690
14613
|
CollateralManagerModule: "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
|
|
14691
14614
|
LiquidationManagerModule: "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
|
|
14692
|
-
CircuitBreakerModule: "
|
|
14615
|
+
CircuitBreakerModule: "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
|
|
14693
14616
|
AdminModule: "0xc5a5C42992dECbae36851359345FE25997F5C42d",
|
|
14694
|
-
PositionManagerViews: "
|
|
14695
|
-
PositionManager: "
|
|
14696
|
-
OperationAuthorizationRegistry: "
|
|
14697
|
-
PKPValidation: "
|
|
14617
|
+
PositionManagerViews: "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
|
|
14618
|
+
PositionManager: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
|
|
14619
|
+
OperationAuthorizationRegistry: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
|
|
14620
|
+
PKPValidation: "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc"
|
|
14698
14621
|
};
|
|
14699
14622
|
ALL_DEPLOYMENTS = {
|
|
14700
14623
|
sepolia: SEPOLIA_DEPLOYMENT,
|
|
@@ -31189,11 +31112,62 @@ async function generatePaymentAuthorization(positionId, amount, chainId, signer)
|
|
|
31189
31112
|
signature: signature2
|
|
31190
31113
|
};
|
|
31191
31114
|
}
|
|
31192
|
-
|
|
31115
|
+
function isChipotlePkpId(pkpTokenId) {
|
|
31193
31116
|
const rawHex = pkpTokenId.startsWith("0x") ? pkpTokenId.slice(2) : pkpTokenId;
|
|
31194
|
-
|
|
31117
|
+
return rawHex.length === 64 && rawHex.startsWith("000000000000000000000000") && rawHex !== "0".repeat(64);
|
|
31118
|
+
}
|
|
31119
|
+
async function deriveChipotlePublicKeyViaService(pkpTokenId, fallback) {
|
|
31120
|
+
const url = `${fallback.serviceEndpoint}/api/lit/pkp/derive-public-key`;
|
|
31121
|
+
const controller = new AbortController();
|
|
31122
|
+
const timeout = setTimeout(
|
|
31123
|
+
() => controller.abort(),
|
|
31124
|
+
fallback.timeoutMs ?? 6e4
|
|
31125
|
+
);
|
|
31126
|
+
try {
|
|
31127
|
+
const headers = {
|
|
31128
|
+
"Content-Type": "application/json"
|
|
31129
|
+
};
|
|
31130
|
+
if (fallback.serviceAuthToken) {
|
|
31131
|
+
headers["Authorization"] = `Bearer ${fallback.serviceAuthToken}`;
|
|
31132
|
+
}
|
|
31133
|
+
const response = await fetch(url, {
|
|
31134
|
+
method: "POST",
|
|
31135
|
+
headers,
|
|
31136
|
+
body: JSON.stringify({
|
|
31137
|
+
pkpId: pkpTokenId,
|
|
31138
|
+
...fallback.borrowerAddress && {
|
|
31139
|
+
borrowerAddress: fallback.borrowerAddress
|
|
31140
|
+
}
|
|
31141
|
+
}),
|
|
31142
|
+
signal: controller.signal
|
|
31143
|
+
});
|
|
31144
|
+
if (!response.ok) {
|
|
31145
|
+
const errorText = await response.text();
|
|
31146
|
+
throw new Error(
|
|
31147
|
+
`derive-public-key service error (${response.status}): ${errorText}`
|
|
31148
|
+
);
|
|
31149
|
+
}
|
|
31150
|
+
const envelope = await response.json();
|
|
31151
|
+
const publicKey = envelope?.data?.publicKey;
|
|
31152
|
+
if (!envelope?.success || !publicKey) {
|
|
31153
|
+
throw new Error(
|
|
31154
|
+
`derive-public-key returned no publicKey (envelope keys: ${Object.keys(
|
|
31155
|
+
envelope ?? {}
|
|
31156
|
+
).join(", ")})`
|
|
31157
|
+
);
|
|
31158
|
+
}
|
|
31159
|
+
return publicKey.startsWith("0x") ? publicKey : `0x${publicKey}`;
|
|
31160
|
+
} finally {
|
|
31161
|
+
clearTimeout(timeout);
|
|
31162
|
+
}
|
|
31163
|
+
}
|
|
31164
|
+
async function getPKPPublicKeyFromTokenId(pkpTokenId, provider, pkpNftContractAddress, chipotleFallback) {
|
|
31165
|
+
if (isChipotlePkpId(pkpTokenId)) {
|
|
31166
|
+
if (chipotleFallback?.serviceEndpoint) {
|
|
31167
|
+
return deriveChipotlePublicKeyViaService(pkpTokenId, chipotleFallback);
|
|
31168
|
+
}
|
|
31195
31169
|
throw new Error(
|
|
31196
|
-
`pkpId ${pkpTokenId} is a Chipotle wallet address (ABI-encoded ETH address). Chipotle PKPs are not NFTs and have no on-chain public key lookup.
|
|
31170
|
+
`pkpId ${pkpTokenId} is a Chipotle wallet address (ABI-encoded ETH address). Chipotle PKPs are not NFTs and have no on-chain public key lookup. Provide chipotleFallback.serviceEndpoint to recover via lit-ops-server, or ensure the PKP public key is populated in cache during position creation.`
|
|
31197
31171
|
);
|
|
31198
31172
|
}
|
|
31199
31173
|
if (!provider) {
|
|
@@ -31488,7 +31462,7 @@ function extractOptionalLitSignature(raw) {
|
|
|
31488
31462
|
|
|
31489
31463
|
// src/modules/contract/contract-manager.module.ts
|
|
31490
31464
|
var POSITION_MANAGER_ABI = [
|
|
31491
|
-
"function createPosition(bytes32 pkpId, bytes calldata validatorSignature, string mainnetVaultAddress, string regtestVaultAddress, uint256 selectedTermMonths, uint256 validatorVersion) external returns (bytes32 positionId)",
|
|
31465
|
+
"function createPosition(bytes32 pkpId, bytes calldata validatorSignature, string mainnetVaultAddress, string regtestVaultAddress, uint256 selectedTermMonths, uint256 validatorVersion, bytes calldata pkpPublicKey) external returns (bytes32 positionId)",
|
|
31492
31466
|
"function mintUCD(bytes32 positionId, uint256 mintAmount, uint256 mintFee, uint256 newDebt, uint256 newCollateral, uint256 btcPrice, bytes32 authorizedSpendsHash, bytes32 ucdDebtHash, bytes32 contractHash, uint256 quantumTimestamp, bytes calldata mintValidatorSignature) external returns (bool)",
|
|
31493
31467
|
"function makePayment(bytes32 positionId, uint256 paymentAmount, uint256 quantumTimestamp, uint256 btcPrice, bytes calldata paymentValidatorSignature) external returns (bool)",
|
|
31494
31468
|
"function extendPosition(bytes32 positionId, uint256 selectedTerm, uint256 quantumTimestamp, uint256 btcPrice, uint256 availableBTCBalance, uint256 proRataRenewalFee, bytes calldata extensionValidatorSignature) external returns (bool)",
|
|
@@ -31812,106 +31786,333 @@ function createContractManager(config) {
|
|
|
31812
31786
|
}
|
|
31813
31787
|
|
|
31814
31788
|
// src/modules/cache/cache-manager.module.ts
|
|
31815
|
-
var
|
|
31816
|
-
cache
|
|
31789
|
+
var LRUCache = class {
|
|
31790
|
+
cache;
|
|
31817
31791
|
maxSize;
|
|
31818
31792
|
ttlMs;
|
|
31819
|
-
|
|
31820
|
-
|
|
31821
|
-
|
|
31793
|
+
debug;
|
|
31794
|
+
name;
|
|
31795
|
+
// Statistics
|
|
31796
|
+
stats = {
|
|
31797
|
+
hits: 0,
|
|
31798
|
+
misses: 0,
|
|
31799
|
+
evictions: 0
|
|
31800
|
+
};
|
|
31801
|
+
constructor(config = {}) {
|
|
31802
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
31803
|
+
this.maxSize = config.maxSize || 1e3;
|
|
31804
|
+
this.ttlMs = config.ttlMs || 6e4;
|
|
31805
|
+
this.debug = config.debug || false;
|
|
31806
|
+
this.name = config.name || "Cache";
|
|
31807
|
+
if (this.debug) {
|
|
31808
|
+
console.log(
|
|
31809
|
+
`\u{1F4BE} [${this.name}] Initialized: maxSize=${this.maxSize}, ttl=${this.ttlMs}ms`
|
|
31810
|
+
);
|
|
31811
|
+
}
|
|
31822
31812
|
}
|
|
31823
31813
|
/**
|
|
31824
31814
|
* Get value from cache
|
|
31815
|
+
*
|
|
31816
|
+
* Returns null if:
|
|
31817
|
+
* - Key not found
|
|
31818
|
+
* - Entry has expired
|
|
31819
|
+
*
|
|
31820
|
+
* @param key - Cache key
|
|
31821
|
+
* @returns Cached value or null
|
|
31825
31822
|
*/
|
|
31826
31823
|
get(key2) {
|
|
31827
31824
|
const entry = this.cache.get(key2);
|
|
31828
31825
|
if (!entry) {
|
|
31829
|
-
|
|
31826
|
+
this.stats.misses++;
|
|
31827
|
+
if (this.debug) {
|
|
31828
|
+
console.log(`\u274C [${this.name}] Cache MISS: ${String(key2)}`);
|
|
31829
|
+
}
|
|
31830
|
+
return null;
|
|
31830
31831
|
}
|
|
31831
|
-
|
|
31832
|
-
if (now2 - entry.timestamp > entry.ttl) {
|
|
31832
|
+
if (this.isExpired(entry)) {
|
|
31833
31833
|
this.cache.delete(key2);
|
|
31834
|
-
|
|
31834
|
+
this.stats.misses++;
|
|
31835
|
+
if (this.debug) {
|
|
31836
|
+
const age = Date.now() - entry.timestamp;
|
|
31837
|
+
console.log(`\u23F0 [${this.name}] Cache EXPIRED: ${String(key2)} (age: ${age}ms)`);
|
|
31838
|
+
}
|
|
31839
|
+
return null;
|
|
31840
|
+
}
|
|
31841
|
+
entry.hits++;
|
|
31842
|
+
entry.lastAccessed = Date.now();
|
|
31843
|
+
this.cache.set(key2, entry);
|
|
31844
|
+
this.stats.hits++;
|
|
31845
|
+
if (this.debug) {
|
|
31846
|
+
const age = Date.now() - entry.timestamp;
|
|
31847
|
+
console.log(
|
|
31848
|
+
`\u2705 [${this.name}] Cache HIT: ${String(key2)} (age: ${age}ms, hits: ${entry.hits})`
|
|
31849
|
+
);
|
|
31835
31850
|
}
|
|
31836
31851
|
return entry.value;
|
|
31837
31852
|
}
|
|
31853
|
+
/**
|
|
31854
|
+
* Get value from cache with Result wrapper
|
|
31855
|
+
*
|
|
31856
|
+
* Useful when you want to distinguish between "not found" and "expired"
|
|
31857
|
+
*/
|
|
31858
|
+
getResult(key2) {
|
|
31859
|
+
const value = this.get(key2);
|
|
31860
|
+
if (value === null) {
|
|
31861
|
+
return failure(
|
|
31862
|
+
new SDKError({
|
|
31863
|
+
message: `Cache miss for key: ${String(key2)}`,
|
|
31864
|
+
category: "CACHE" /* CACHE */,
|
|
31865
|
+
severity: "LOW" /* LOW */,
|
|
31866
|
+
originalError: new Error("Cache miss")
|
|
31867
|
+
})
|
|
31868
|
+
);
|
|
31869
|
+
}
|
|
31870
|
+
return success(value);
|
|
31871
|
+
}
|
|
31838
31872
|
/**
|
|
31839
31873
|
* Set value in cache
|
|
31874
|
+
*
|
|
31875
|
+
* If cache is full, evicts the least recently used entry
|
|
31876
|
+
*
|
|
31877
|
+
* @param key - Cache key
|
|
31878
|
+
* @param value - Value to cache
|
|
31879
|
+
* @param ttl - Optional custom TTL for this entry (ms)
|
|
31840
31880
|
*/
|
|
31841
31881
|
set(key2, value, ttl) {
|
|
31842
31882
|
if (this.cache.size >= this.maxSize && !this.cache.has(key2)) {
|
|
31843
|
-
|
|
31844
|
-
if (firstKey) {
|
|
31845
|
-
this.cache.delete(firstKey);
|
|
31846
|
-
}
|
|
31883
|
+
this.evictLRU();
|
|
31847
31884
|
}
|
|
31848
|
-
|
|
31885
|
+
const entry = {
|
|
31849
31886
|
value,
|
|
31850
31887
|
timestamp: Date.now(),
|
|
31851
|
-
|
|
31852
|
-
|
|
31888
|
+
hits: 0,
|
|
31889
|
+
lastAccessed: Date.now()
|
|
31890
|
+
};
|
|
31891
|
+
this.cache.set(key2, entry);
|
|
31892
|
+
if (this.debug) {
|
|
31893
|
+
const effectiveTtl = ttl || this.ttlMs;
|
|
31894
|
+
console.log(
|
|
31895
|
+
`\u{1F4BE} [${this.name}] Cache SET: ${String(key2)} (ttl: ${effectiveTtl}ms, size: ${this.cache.size}/${this.maxSize})`
|
|
31896
|
+
);
|
|
31897
|
+
}
|
|
31898
|
+
}
|
|
31899
|
+
/**
|
|
31900
|
+
* Set value in cache with Result wrapper
|
|
31901
|
+
*/
|
|
31902
|
+
setResult(key2, value, ttl) {
|
|
31903
|
+
try {
|
|
31904
|
+
this.set(key2, value, ttl);
|
|
31905
|
+
return success(void 0);
|
|
31906
|
+
} catch (error) {
|
|
31907
|
+
return failure(
|
|
31908
|
+
new SDKError({
|
|
31909
|
+
message: `Failed to set cache value for key: ${String(key2)}`,
|
|
31910
|
+
category: "CACHE" /* CACHE */,
|
|
31911
|
+
severity: "MEDIUM" /* MEDIUM */,
|
|
31912
|
+
originalError: error instanceof Error ? error : new Error(String(error))
|
|
31913
|
+
})
|
|
31914
|
+
);
|
|
31915
|
+
}
|
|
31853
31916
|
}
|
|
31854
31917
|
/**
|
|
31855
|
-
* Check if key exists in cache
|
|
31918
|
+
* Check if key exists in cache (without affecting stats)
|
|
31856
31919
|
*/
|
|
31857
31920
|
has(key2) {
|
|
31858
|
-
|
|
31921
|
+
const entry = this.cache.get(key2);
|
|
31922
|
+
return entry !== void 0 && !this.isExpired(entry);
|
|
31859
31923
|
}
|
|
31860
31924
|
/**
|
|
31861
|
-
* Delete key from cache
|
|
31925
|
+
* Delete specific key from cache
|
|
31862
31926
|
*/
|
|
31863
31927
|
delete(key2) {
|
|
31864
|
-
|
|
31928
|
+
const deleted = this.cache.delete(key2);
|
|
31929
|
+
if (deleted && this.debug) {
|
|
31930
|
+
console.log(`\u{1F5D1}\uFE0F [${this.name}] Cache DELETE: ${String(key2)}`);
|
|
31931
|
+
}
|
|
31932
|
+
return deleted;
|
|
31865
31933
|
}
|
|
31866
31934
|
/**
|
|
31867
|
-
* Clear
|
|
31935
|
+
* Clear entire cache
|
|
31868
31936
|
*/
|
|
31869
31937
|
clear() {
|
|
31938
|
+
const previousSize = this.cache.size;
|
|
31870
31939
|
this.cache.clear();
|
|
31940
|
+
this.stats = {
|
|
31941
|
+
hits: 0,
|
|
31942
|
+
misses: 0,
|
|
31943
|
+
evictions: 0
|
|
31944
|
+
};
|
|
31945
|
+
if (this.debug) {
|
|
31946
|
+
console.log(`\u{1F9F9} [${this.name}] Cache CLEARED: removed ${previousSize} entries`);
|
|
31947
|
+
}
|
|
31948
|
+
}
|
|
31949
|
+
/**
|
|
31950
|
+
* Get current cache size
|
|
31951
|
+
*/
|
|
31952
|
+
size() {
|
|
31953
|
+
return this.cache.size;
|
|
31871
31954
|
}
|
|
31872
31955
|
/**
|
|
31873
|
-
*
|
|
31956
|
+
* Get cache statistics
|
|
31957
|
+
*/
|
|
31958
|
+
getStats() {
|
|
31959
|
+
const entries = Array.from(this.cache.values());
|
|
31960
|
+
const timestamps = entries.map((e) => e.timestamp);
|
|
31961
|
+
const total = this.stats.hits + this.stats.misses;
|
|
31962
|
+
const hitRate = total === 0 ? 0 : this.stats.hits / total * 100;
|
|
31963
|
+
return {
|
|
31964
|
+
size: this.cache.size,
|
|
31965
|
+
hits: this.stats.hits,
|
|
31966
|
+
misses: this.stats.misses,
|
|
31967
|
+
evictions: this.stats.evictions,
|
|
31968
|
+
oldestEntry: timestamps.length > 0 ? Math.min(...timestamps) : 0,
|
|
31969
|
+
newestEntry: timestamps.length > 0 ? Math.max(...timestamps) : 0,
|
|
31970
|
+
hitRate
|
|
31971
|
+
};
|
|
31972
|
+
}
|
|
31973
|
+
/**
|
|
31974
|
+
* Get hit rate percentage
|
|
31975
|
+
*/
|
|
31976
|
+
getHitRate() {
|
|
31977
|
+
const total = this.stats.hits + this.stats.misses;
|
|
31978
|
+
return total === 0 ? 0 : this.stats.hits / total * 100;
|
|
31979
|
+
}
|
|
31980
|
+
/**
|
|
31981
|
+
* Get all cached keys (for debugging)
|
|
31982
|
+
*/
|
|
31983
|
+
getKeys() {
|
|
31984
|
+
return Array.from(this.cache.keys());
|
|
31985
|
+
}
|
|
31986
|
+
/**
|
|
31987
|
+
* Get all cached values (for debugging)
|
|
31988
|
+
*/
|
|
31989
|
+
getValues() {
|
|
31990
|
+
return Array.from(this.cache.values()).map((entry) => entry.value);
|
|
31991
|
+
}
|
|
31992
|
+
/**
|
|
31993
|
+
* Get all cache entries with metadata (for debugging)
|
|
31994
|
+
*/
|
|
31995
|
+
getEntries() {
|
|
31996
|
+
return Array.from(this.cache.entries()).map(([key2, entry]) => ({
|
|
31997
|
+
key: key2,
|
|
31998
|
+
value: entry.value,
|
|
31999
|
+
metadata: {
|
|
32000
|
+
timestamp: entry.timestamp,
|
|
32001
|
+
hits: entry.hits,
|
|
32002
|
+
lastAccessed: entry.lastAccessed
|
|
32003
|
+
}
|
|
32004
|
+
}));
|
|
32005
|
+
}
|
|
32006
|
+
/**
|
|
32007
|
+
* Clean up expired entries
|
|
32008
|
+
*
|
|
32009
|
+
* Useful for periodic maintenance
|
|
32010
|
+
*
|
|
32011
|
+
* @returns Number of entries cleaned
|
|
31874
32012
|
*/
|
|
31875
32013
|
cleanExpired() {
|
|
31876
32014
|
const now2 = Date.now();
|
|
31877
|
-
let
|
|
32015
|
+
let cleanedCount = 0;
|
|
31878
32016
|
for (const [key2, entry] of this.cache.entries()) {
|
|
31879
|
-
if (now2 - entry.timestamp >
|
|
32017
|
+
if (now2 - entry.timestamp > this.ttlMs) {
|
|
31880
32018
|
this.cache.delete(key2);
|
|
31881
|
-
|
|
32019
|
+
cleanedCount++;
|
|
31882
32020
|
}
|
|
31883
32021
|
}
|
|
31884
|
-
|
|
32022
|
+
if (cleanedCount > 0 && this.debug) {
|
|
32023
|
+
console.log(`\u{1F9F9} [${this.name}] Cleaned ${cleanedCount} expired entries`);
|
|
32024
|
+
}
|
|
32025
|
+
return cleanedCount;
|
|
31885
32026
|
}
|
|
31886
32027
|
/**
|
|
31887
|
-
*
|
|
32028
|
+
* Check if cache entry is expired
|
|
31888
32029
|
*/
|
|
31889
|
-
|
|
31890
|
-
return
|
|
31891
|
-
|
|
31892
|
-
|
|
31893
|
-
|
|
31894
|
-
|
|
32030
|
+
isExpired(entry) {
|
|
32031
|
+
return Date.now() - entry.timestamp > this.ttlMs;
|
|
32032
|
+
}
|
|
32033
|
+
/**
|
|
32034
|
+
* Evict least recently used entry
|
|
32035
|
+
*/
|
|
32036
|
+
evictLRU() {
|
|
32037
|
+
let oldestKey = null;
|
|
32038
|
+
let oldestAccess = Infinity;
|
|
32039
|
+
for (const [key2, entry] of this.cache.entries()) {
|
|
32040
|
+
if (entry.lastAccessed < oldestAccess) {
|
|
32041
|
+
oldestAccess = entry.lastAccessed;
|
|
32042
|
+
oldestKey = key2;
|
|
32043
|
+
}
|
|
32044
|
+
}
|
|
32045
|
+
if (oldestKey !== null) {
|
|
32046
|
+
this.cache.delete(oldestKey);
|
|
32047
|
+
this.stats.evictions++;
|
|
32048
|
+
if (this.debug) {
|
|
32049
|
+
const timeSinceAccess = Date.now() - oldestAccess;
|
|
32050
|
+
console.log(
|
|
32051
|
+
`\u267B\uFE0F [${this.name}] Cache EVICT (LRU): ${String(oldestKey)} (last accessed: ${timeSinceAccess}ms ago)`
|
|
32052
|
+
);
|
|
32053
|
+
}
|
|
32054
|
+
}
|
|
32055
|
+
}
|
|
32056
|
+
/**
|
|
32057
|
+
* Get or compute value
|
|
32058
|
+
*
|
|
32059
|
+
* If key exists in cache, returns cached value.
|
|
32060
|
+
* Otherwise, computes value using provided function and caches it.
|
|
32061
|
+
*
|
|
32062
|
+
* @param key - Cache key
|
|
32063
|
+
* @param compute - Function to compute value if not in cache
|
|
32064
|
+
* @param ttl - Optional custom TTL for this entry
|
|
32065
|
+
* @returns Cached or computed value
|
|
32066
|
+
*/
|
|
32067
|
+
async getOrCompute(key2, compute, ttl) {
|
|
32068
|
+
const cached = this.get(key2);
|
|
32069
|
+
if (cached !== null) {
|
|
32070
|
+
return cached;
|
|
32071
|
+
}
|
|
32072
|
+
const value = await compute();
|
|
32073
|
+
this.set(key2, value, ttl);
|
|
32074
|
+
return value;
|
|
32075
|
+
}
|
|
32076
|
+
/**
|
|
32077
|
+
* Get or compute value with Result wrapper
|
|
32078
|
+
*/
|
|
32079
|
+
async getOrComputeResult(key2, compute, ttl) {
|
|
32080
|
+
const cached = this.get(key2);
|
|
32081
|
+
if (cached !== null) {
|
|
32082
|
+
return success(cached);
|
|
32083
|
+
}
|
|
32084
|
+
const result = await compute();
|
|
32085
|
+
if (result.success) {
|
|
32086
|
+
this.set(key2, result.value, ttl);
|
|
32087
|
+
}
|
|
32088
|
+
return result;
|
|
31895
32089
|
}
|
|
31896
32090
|
};
|
|
31897
32091
|
var CacheManager = class {
|
|
31898
32092
|
caches = /* @__PURE__ */ new Map();
|
|
31899
|
-
|
|
31900
|
-
constructor(
|
|
31901
|
-
this.
|
|
32093
|
+
globalConfig;
|
|
32094
|
+
constructor(globalConfig = {}) {
|
|
32095
|
+
this.globalConfig = globalConfig;
|
|
31902
32096
|
}
|
|
31903
32097
|
/**
|
|
31904
|
-
*
|
|
32098
|
+
* Create or get a named cache
|
|
32099
|
+
*
|
|
32100
|
+
* @param name - Unique cache name
|
|
32101
|
+
* @param config - Optional cache-specific configuration
|
|
32102
|
+
* @returns LRU cache instance
|
|
31905
32103
|
*/
|
|
31906
32104
|
getCache(name, config) {
|
|
31907
|
-
|
|
31908
|
-
|
|
32105
|
+
const existingCache = this.caches.get(name);
|
|
32106
|
+
if (existingCache) {
|
|
32107
|
+
return existingCache;
|
|
31909
32108
|
}
|
|
31910
|
-
const
|
|
32109
|
+
const mergedConfig = {
|
|
32110
|
+
...this.globalConfig,
|
|
32111
|
+
...config,
|
|
32112
|
+
name
|
|
32113
|
+
};
|
|
32114
|
+
const cache = new LRUCache(mergedConfig);
|
|
31911
32115
|
this.caches.set(name, cache);
|
|
31912
|
-
if (this.debug) {
|
|
31913
|
-
console.log(`[CacheManager] Created cache: ${name}`, config);
|
|
31914
|
-
}
|
|
31915
32116
|
return cache;
|
|
31916
32117
|
}
|
|
31917
32118
|
/**
|
|
@@ -31926,11 +32127,11 @@ var CacheManager = class {
|
|
|
31926
32127
|
* Clean expired entries from all caches
|
|
31927
32128
|
*/
|
|
31928
32129
|
cleanAllExpired() {
|
|
31929
|
-
let
|
|
32130
|
+
let totalCleaned = 0;
|
|
31930
32131
|
for (const cache of this.caches.values()) {
|
|
31931
|
-
|
|
32132
|
+
totalCleaned += cache.cleanExpired();
|
|
31932
32133
|
}
|
|
31933
|
-
return
|
|
32134
|
+
return totalCleaned;
|
|
31934
32135
|
}
|
|
31935
32136
|
/**
|
|
31936
32137
|
* Get statistics for all caches
|
|
@@ -31943,11 +32144,16 @@ var CacheManager = class {
|
|
|
31943
32144
|
return stats;
|
|
31944
32145
|
}
|
|
31945
32146
|
/**
|
|
31946
|
-
*
|
|
32147
|
+
* Get list of all cache names
|
|
31947
32148
|
*/
|
|
31948
|
-
|
|
31949
|
-
this.
|
|
31950
|
-
|
|
32149
|
+
getCacheNames() {
|
|
32150
|
+
return Array.from(this.caches.keys());
|
|
32151
|
+
}
|
|
32152
|
+
/**
|
|
32153
|
+
* Delete a named cache
|
|
32154
|
+
*/
|
|
32155
|
+
deleteCache(name) {
|
|
32156
|
+
return this.caches.delete(name);
|
|
31951
32157
|
}
|
|
31952
32158
|
};
|
|
31953
32159
|
function createCacheManager(config) {
|
|
@@ -32905,6 +33111,10 @@ var LoanCreator = class {
|
|
|
32905
33111
|
ethers_exports.utils.hexlify(BigInt(pkpData.tokenId)),
|
|
32906
33112
|
32
|
|
32907
33113
|
);
|
|
33114
|
+
const pkpPublicKeyUncompressed = ethers_exports.utils.computePublicKey(
|
|
33115
|
+
pkpData.publicKey,
|
|
33116
|
+
false
|
|
33117
|
+
);
|
|
32908
33118
|
console.log("\n\u{1F50D} PKP TOKEN ID CONVERSION TRACE (SDK):");
|
|
32909
33119
|
console.log("==========================================");
|
|
32910
33120
|
console.log(
|
|
@@ -32955,7 +33165,8 @@ var LoanCreator = class {
|
|
|
32955
33165
|
mainnetVaultAddress,
|
|
32956
33166
|
regtestVaultAddress,
|
|
32957
33167
|
request.selectedTerm,
|
|
32958
|
-
validatorVersion
|
|
33168
|
+
validatorVersion,
|
|
33169
|
+
pkpPublicKeyUncompressed
|
|
32959
33170
|
]);
|
|
32960
33171
|
console.log("\u{1F50D} ENCODED CALLDATA (first 256 chars):", encoded.substring(0, 256));
|
|
32961
33172
|
console.log("\u{1F50D} ENCODED CALLDATA full length:", encoded.length);
|
|
@@ -32968,7 +33179,8 @@ var LoanCreator = class {
|
|
|
32968
33179
|
mainnetVaultAddress,
|
|
32969
33180
|
regtestVaultAddress,
|
|
32970
33181
|
request.selectedTerm,
|
|
32971
|
-
validatorVersion
|
|
33182
|
+
validatorVersion,
|
|
33183
|
+
pkpPublicKeyUncompressed
|
|
32972
33184
|
);
|
|
32973
33185
|
if (!tx) {
|
|
32974
33186
|
return failure(
|
|
@@ -33520,8 +33732,8 @@ var LoanQuery = class {
|
|
|
33520
33732
|
batch.map(async (loan) => {
|
|
33521
33733
|
try {
|
|
33522
33734
|
const rawId = loan.pkpId?.startsWith("0x") ? loan.pkpId.slice(2) : loan.pkpId;
|
|
33523
|
-
const
|
|
33524
|
-
if (
|
|
33735
|
+
const isChipotlePkpId2 = typeof rawId === "string" && rawId.length === 40 && !rawId.toLowerCase().startsWith("04");
|
|
33736
|
+
if (isChipotlePkpId2) {
|
|
33525
33737
|
if (this.config.positionManagerCoreAddress && this.config.provider) {
|
|
33526
33738
|
const pmContract = new ethers_exports.Contract(
|
|
33527
33739
|
this.config.positionManagerCoreAddress,
|
|
@@ -36138,7 +36350,7 @@ var DiamondHandsGraph = class {
|
|
|
36138
36350
|
}
|
|
36139
36351
|
|
|
36140
36352
|
${shouldQuery.mint ? `
|
|
36141
|
-
|
|
36353
|
+
ucdmintEvents(
|
|
36142
36354
|
${buildPositionWhereClause()}
|
|
36143
36355
|
first: $limit,
|
|
36144
36356
|
orderBy: timestamp,
|
|
@@ -36327,7 +36539,7 @@ var DiamondHandsGraph = class {
|
|
|
36327
36539
|
commitTimestamp: result.position.liquidation.commitTimestamp,
|
|
36328
36540
|
revealDelay: result.position.liquidation.revealDelay
|
|
36329
36541
|
} : void 0;
|
|
36330
|
-
const mints = (result.
|
|
36542
|
+
const mints = (result.ucdmintEvents || []).map((m) => ({
|
|
36331
36543
|
id: m.id,
|
|
36332
36544
|
positionId,
|
|
36333
36545
|
amount: m.amount,
|
|
@@ -36671,7 +36883,7 @@ function formatLoanCreationMessage(positionId, pkpId, vaultAddress) {
|
|
|
36671
36883
|
}
|
|
36672
36884
|
function formatBTCWithdrawalFailureMessage(withdrawalAmount, btcVault, btcDestinationAddress, loanId) {
|
|
36673
36885
|
const formattedAmount = formatBTCAmount(withdrawalAmount);
|
|
36674
|
-
return
|
|
36886
|
+
return `\u274C BTC withdrawal FAILED: ${formattedAmount} from ${btcVault} to ${btcDestinationAddress} for loan id: ${loanId}`;
|
|
36675
36887
|
}
|
|
36676
36888
|
function formatLoanRenewalMessage(positionId, txHash) {
|
|
36677
36889
|
return `Loan id ${positionId} was successfully renewed. Tx: https://sepolia.etherscan.io/tx/${txHash}`;
|
|
@@ -36685,9 +36897,10 @@ function formatBalanceConfirmationMessage(loanId) {
|
|
|
36685
36897
|
function formatBalanceConfirmationFailureMessage(loanId) {
|
|
36686
36898
|
return `FAILED to update to PENDING_MINT for loan id ${loanId}`;
|
|
36687
36899
|
}
|
|
36688
|
-
function formatBTCWithdrawalSuccessMessage(withdrawalAmount, btcVault, btcDestinationAddress, loanId) {
|
|
36900
|
+
function formatBTCWithdrawalSuccessMessage(withdrawalAmount, btcVault, btcDestinationAddress, loanId, btcTxId) {
|
|
36689
36901
|
const formattedAmount = formatBTCAmount(withdrawalAmount);
|
|
36690
|
-
|
|
36902
|
+
const txSuffix = btcTxId ? ` (tx: ${btcTxId})` : "";
|
|
36903
|
+
return `\u2705 BTC withdrawal SUCCEEDED: ${formattedAmount} sent from ${btcVault} to ${btcDestinationAddress} for loan id: ${loanId}${txSuffix}`;
|
|
36691
36904
|
}
|
|
36692
36905
|
function formatLiquidationSkippedMessage(loanId, ratio, threshold, btcVault, btcVaultBalance, ucdDebt, btcPrice) {
|
|
36693
36906
|
const formattedPrice = formatBTCPrice(btcPrice);
|
|
@@ -36931,12 +37144,6 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
36931
37144
|
* @param config - SDK configuration
|
|
36932
37145
|
*/
|
|
36933
37146
|
constructor(config) {
|
|
36934
|
-
console.log(
|
|
36935
|
-
"[DEBUG] Constructor START - config keys:",
|
|
36936
|
-
Object.keys(config),
|
|
36937
|
-
"serviceEndpoint:",
|
|
36938
|
-
config["serviceEndpoint"]
|
|
36939
|
-
);
|
|
36940
37147
|
if (!config.provider && config.ethRpcUrl) {
|
|
36941
37148
|
config.provider = new ethers_exports.providers.JsonRpcProvider(config.ethRpcUrl);
|
|
36942
37149
|
}
|
|
@@ -36947,12 +37154,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
36947
37154
|
network: config.litNetwork
|
|
36948
37155
|
});
|
|
36949
37156
|
}
|
|
36950
|
-
console.log("[DEBUG] Before CacheManager init");
|
|
36951
37157
|
this.cacheManager = new CacheManager({
|
|
36952
37158
|
debug: config.debug
|
|
36953
37159
|
});
|
|
36954
|
-
console.log("[DEBUG] After CacheManager init");
|
|
36955
|
-
console.log("[DEBUG] Before ContractManager init");
|
|
36956
37160
|
const contractManagerResult = createContractManager({
|
|
36957
37161
|
provider: config.provider,
|
|
36958
37162
|
signer: config.contractSigner,
|
|
@@ -37132,17 +37336,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37132
37336
|
*/
|
|
37133
37337
|
static async create(config) {
|
|
37134
37338
|
const userProvidedServiceEndpoint = config.serviceEndpoint;
|
|
37135
|
-
console.log(
|
|
37136
|
-
"[DEBUG] DiamondHandsSDK.create - userProvidedServiceEndpoint:",
|
|
37137
|
-
userProvidedServiceEndpoint
|
|
37138
|
-
);
|
|
37139
37339
|
const enrichedConfig = await _DiamondHandsSDK.enrichConfigWithNetworkDefaults(config);
|
|
37140
37340
|
if (userProvidedServiceEndpoint) {
|
|
37141
37341
|
enrichedConfig.serviceEndpoint = userProvidedServiceEndpoint;
|
|
37142
|
-
console.log(
|
|
37143
|
-
"[DEBUG] DiamondHandsSDK.create - restored userProvidedServiceEndpoint:",
|
|
37144
|
-
userProvidedServiceEndpoint
|
|
37145
|
-
);
|
|
37146
37342
|
}
|
|
37147
37343
|
const configError = validateSDKConfig(enrichedConfig);
|
|
37148
37344
|
if (configError) {
|
|
@@ -37182,10 +37378,6 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37182
37378
|
*/
|
|
37183
37379
|
static async enrichConfigWithNetworkDefaults(config) {
|
|
37184
37380
|
const { getNetworkConfig: getNetworkConfig2, getNetworkConfigByName: getNetworkConfigByName2 } = await Promise.resolve().then(() => (init_network_configs(), network_configs_exports));
|
|
37185
|
-
console.log(
|
|
37186
|
-
"[DEBUG] enrichConfigWithNetworkDefaults - input config.serviceEndpoint:",
|
|
37187
|
-
config.serviceEndpoint
|
|
37188
|
-
);
|
|
37189
37381
|
let chainId = config.chainId;
|
|
37190
37382
|
if (!chainId) {
|
|
37191
37383
|
try {
|
|
@@ -37270,9 +37462,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37270
37462
|
...config.contractAddresses || {}
|
|
37271
37463
|
// User-provided individual overrides (only specified fields)
|
|
37272
37464
|
};
|
|
37273
|
-
|
|
37274
|
-
"[SDK] enrichConfigWithNetworkDefaults - contractAddresses after merge",
|
|
37275
|
-
{
|
|
37465
|
+
if (config.debug) {
|
|
37466
|
+
log.info("[SDK] enrichConfigWithNetworkDefaults - contractAddresses after merge", {
|
|
37276
37467
|
keys: Object.keys(enrichedConfig.contractAddresses || {}),
|
|
37277
37468
|
hasPositionManager: !!enrichedConfig.contractAddresses?.positionManager,
|
|
37278
37469
|
hasLoanOperationsManager: !!enrichedConfig.contractAddresses?.loanOperationsManager,
|
|
@@ -37282,8 +37473,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37282
37473
|
loanOperationsManager: enrichedConfig.contractAddresses?.loanOperationsManager || "MISSING",
|
|
37283
37474
|
termManager: enrichedConfig.contractAddresses?.termManager || "MISSING",
|
|
37284
37475
|
ucdController: enrichedConfig.contractAddresses?.ucdController || "MISSING"
|
|
37285
|
-
}
|
|
37286
|
-
|
|
37476
|
+
});
|
|
37477
|
+
}
|
|
37287
37478
|
if (config.debug) {
|
|
37288
37479
|
log.info("\u2705 Contract addresses loaded from network config", {
|
|
37289
37480
|
overridden: Object.keys(config.contractAddresses || {}).length,
|
|
@@ -37302,10 +37493,6 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37302
37493
|
});
|
|
37303
37494
|
}
|
|
37304
37495
|
}
|
|
37305
|
-
console.log(
|
|
37306
|
-
"[DEBUG] enrichConfigWithNetworkDefaults - output config.serviceEndpoint:",
|
|
37307
|
-
enrichedConfig.serviceEndpoint
|
|
37308
|
-
);
|
|
37309
37496
|
if (!enrichedConfig.validators) {
|
|
37310
37497
|
enrichedConfig.validators = {
|
|
37311
37498
|
loanCreation: 1,
|
|
@@ -37753,7 +37940,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37753
37940
|
pkpPublicKey = await getPKPPublicKeyFromTokenId(
|
|
37754
37941
|
position2.pkpId,
|
|
37755
37942
|
this.getProviderOrThrow(),
|
|
37756
|
-
nagaPkpNftAddress
|
|
37943
|
+
nagaPkpNftAddress,
|
|
37944
|
+
this.getChipotlePublicKeyFallback()
|
|
37757
37945
|
);
|
|
37758
37946
|
pkpEthAddress = ethers_exports.utils.computeAddress(pkpPublicKey);
|
|
37759
37947
|
pkpCache.set(request.positionId, {
|
|
@@ -38856,7 +39044,8 @@ Error data: ${errorData || "none"}`
|
|
|
38856
39044
|
const pkpPublicKey = await getPKPPublicKeyFromTokenId(
|
|
38857
39045
|
position.pkpId,
|
|
38858
39046
|
this.getProviderOrThrow(),
|
|
38859
|
-
nagaPkpNftAddressLiq
|
|
39047
|
+
nagaPkpNftAddressLiq,
|
|
39048
|
+
this.getChipotlePublicKeyFallback()
|
|
38860
39049
|
);
|
|
38861
39050
|
const pkpEthAddress = ethers_exports.utils.computeAddress(pkpPublicKey);
|
|
38862
39051
|
pkpData = {
|
|
@@ -40797,11 +40986,13 @@ Error data: ${errorData || "none"}`
|
|
|
40797
40986
|
transactionHash: transactionHash || "none"
|
|
40798
40987
|
});
|
|
40799
40988
|
}
|
|
40800
|
-
|
|
40801
|
-
error:
|
|
40802
|
-
|
|
40803
|
-
|
|
40804
|
-
|
|
40989
|
+
if (this.config.debug) {
|
|
40990
|
+
log.error("\u274C PAYMENT ERROR:", {
|
|
40991
|
+
error: errorMsg,
|
|
40992
|
+
errorType: typeof error,
|
|
40993
|
+
transactionHash: transactionHash || "none"
|
|
40994
|
+
});
|
|
40995
|
+
}
|
|
40805
40996
|
if (this.config.debug) {
|
|
40806
40997
|
log.error("\u274C Payment failed", {
|
|
40807
40998
|
transactionHash: transactionHash || "not available",
|
|
@@ -40937,7 +41128,8 @@ Error data: ${errorData || "none"}`
|
|
|
40937
41128
|
pkpPublicKey = await getPKPPublicKeyFromTokenId(
|
|
40938
41129
|
position.pkpId,
|
|
40939
41130
|
this.getProviderOrThrow(),
|
|
40940
|
-
nagaPkpNftAddress
|
|
41131
|
+
nagaPkpNftAddress,
|
|
41132
|
+
this.getChipotlePublicKeyFallback()
|
|
40941
41133
|
);
|
|
40942
41134
|
pkpEthAddress = ethers_exports.utils.computeAddress(pkpPublicKey);
|
|
40943
41135
|
pkpCache.set(positionId, {
|
|
@@ -41407,22 +41599,6 @@ Error data: ${errorData || "none"}`
|
|
|
41407
41599
|
gasUsed: receipt.gasUsed?.toString() || "unknown"
|
|
41408
41600
|
});
|
|
41409
41601
|
}
|
|
41410
|
-
try {
|
|
41411
|
-
const position = await this.getPosition(positionId);
|
|
41412
|
-
const btcAmount = (Number(withdrawalAmount) / 1e8).toFixed(8);
|
|
41413
|
-
const message = formatBTCWithdrawalSuccessMessage(
|
|
41414
|
-
btcAmount,
|
|
41415
|
-
position?.vaultAddress || "unknown",
|
|
41416
|
-
validationResponse.destinationAddress,
|
|
41417
|
-
positionId
|
|
41418
|
-
);
|
|
41419
|
-
await this._relayNotification(message);
|
|
41420
|
-
} catch (telegramError) {
|
|
41421
|
-
console.error(
|
|
41422
|
-
"Telegram notification failed:",
|
|
41423
|
-
telegramError instanceof Error ? telegramError.message : String(telegramError)
|
|
41424
|
-
);
|
|
41425
|
-
}
|
|
41426
41602
|
return {
|
|
41427
41603
|
success: true,
|
|
41428
41604
|
positionId,
|
|
@@ -41595,7 +41771,8 @@ Error data: ${errorData || "none"}`
|
|
|
41595
41771
|
pkpPublicKey = await getPKPPublicKeyFromTokenId(
|
|
41596
41772
|
pkpId,
|
|
41597
41773
|
this.getProviderOrThrow(),
|
|
41598
|
-
nagaPkpNftAddress
|
|
41774
|
+
nagaPkpNftAddress,
|
|
41775
|
+
this.getChipotlePublicKeyFallback()
|
|
41599
41776
|
);
|
|
41600
41777
|
pkpCache.set(request.positionId, {
|
|
41601
41778
|
publicKey: pkpPublicKey,
|
|
@@ -42311,6 +42488,27 @@ Error data: ${errorData || "none"}`
|
|
|
42311
42488
|
txid: executionResult.txid
|
|
42312
42489
|
});
|
|
42313
42490
|
}
|
|
42491
|
+
try {
|
|
42492
|
+
const btcAmount = (Number(withdrawalAmount) / 1e8).toFixed(8);
|
|
42493
|
+
const message = executionResult.success ? formatBTCWithdrawalSuccessMessage(
|
|
42494
|
+
btcAmount,
|
|
42495
|
+
vaultAddress,
|
|
42496
|
+
withdrawalAddress,
|
|
42497
|
+
positionId,
|
|
42498
|
+
executionResult.txid
|
|
42499
|
+
) : formatBTCWithdrawalFailureMessage(
|
|
42500
|
+
btcAmount,
|
|
42501
|
+
vaultAddress,
|
|
42502
|
+
withdrawalAddress,
|
|
42503
|
+
positionId
|
|
42504
|
+
);
|
|
42505
|
+
await this._relayNotification(message);
|
|
42506
|
+
} catch (telegramError) {
|
|
42507
|
+
console.error(
|
|
42508
|
+
"Telegram notification failed:",
|
|
42509
|
+
telegramError instanceof Error ? telegramError.message : String(telegramError)
|
|
42510
|
+
);
|
|
42511
|
+
}
|
|
42314
42512
|
const transfers = [
|
|
42315
42513
|
{
|
|
42316
42514
|
success: executionResult.success,
|
|
@@ -42718,6 +42916,19 @@ Error data: ${errorData || "none"}`
|
|
|
42718
42916
|
// ============================================================================
|
|
42719
42917
|
// PRIVATE HELPER METHODS
|
|
42720
42918
|
// ============================================================================
|
|
42919
|
+
/**
|
|
42920
|
+
* Build the Chipotle service-mode fallback config for getPKPPublicKeyFromTokenId.
|
|
42921
|
+
* Returns undefined in standalone mode so the helper falls back to throwing.
|
|
42922
|
+
*/
|
|
42923
|
+
getChipotlePublicKeyFallback() {
|
|
42924
|
+
if (!this.config.serviceEndpoint)
|
|
42925
|
+
return void 0;
|
|
42926
|
+
return {
|
|
42927
|
+
serviceEndpoint: this.config.serviceEndpoint,
|
|
42928
|
+
serviceAuthToken: this.config.serviceAuthToken,
|
|
42929
|
+
debug: this.config.debug
|
|
42930
|
+
};
|
|
42931
|
+
}
|
|
42721
42932
|
/**
|
|
42722
42933
|
* Get provider or throw error
|
|
42723
42934
|
*/
|
|
@@ -43369,7 +43580,7 @@ export {
|
|
|
43369
43580
|
ErrorSeverity,
|
|
43370
43581
|
EventHelpers,
|
|
43371
43582
|
LOCALHOST_CONTRACTS,
|
|
43372
|
-
|
|
43583
|
+
LRUCache,
|
|
43373
43584
|
LoanCreator,
|
|
43374
43585
|
LoanQuery,
|
|
43375
43586
|
LoanStatus,
|