@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.js
CHANGED
|
@@ -12685,93 +12685,504 @@ var require_elliptic = __commonJS({
|
|
|
12685
12685
|
}
|
|
12686
12686
|
});
|
|
12687
12687
|
|
|
12688
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/
|
|
12689
|
-
var
|
|
12690
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/
|
|
12691
|
-
"use strict";
|
|
12692
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12693
|
-
}
|
|
12694
|
-
});
|
|
12695
|
-
|
|
12696
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/lit-action-config.i.js
|
|
12697
|
-
var require_lit_action_config_i = __commonJS({
|
|
12698
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/lit-action-config.i.js"(exports) {
|
|
12699
|
-
"use strict";
|
|
12700
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12701
|
-
}
|
|
12702
|
-
});
|
|
12703
|
-
|
|
12704
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.js
|
|
12705
|
-
var require_diamond_hands_lit_actions_i = __commonJS({
|
|
12706
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.js"(exports) {
|
|
12707
|
-
"use strict";
|
|
12708
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12709
|
-
}
|
|
12710
|
-
});
|
|
12711
|
-
|
|
12712
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/lit-action-registry.i.js
|
|
12713
|
-
var require_lit_action_registry_i = __commonJS({
|
|
12714
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/lit-action-registry.i.js"(exports) {
|
|
12715
|
-
"use strict";
|
|
12716
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12717
|
-
}
|
|
12718
|
-
});
|
|
12719
|
-
|
|
12720
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/index.js
|
|
12721
|
-
var require_interfaces = __commonJS({
|
|
12722
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/index.js"(exports) {
|
|
12688
|
+
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js
|
|
12689
|
+
var require_pkg_src = __commonJS({
|
|
12690
|
+
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js"(exports, module2) {
|
|
12723
12691
|
"use strict";
|
|
12724
|
-
var
|
|
12725
|
-
|
|
12726
|
-
|
|
12727
|
-
|
|
12728
|
-
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
}
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
12692
|
+
var __defProp2 = Object.defineProperty;
|
|
12693
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
12694
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
12695
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
12696
|
+
var __esm2 = (fn, res) => function __init() {
|
|
12697
|
+
return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
|
|
12698
|
+
};
|
|
12699
|
+
var __export2 = (target, all) => {
|
|
12700
|
+
for (var name in all)
|
|
12701
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
12702
|
+
};
|
|
12703
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
12704
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12705
|
+
for (let key2 of __getOwnPropNames2(from))
|
|
12706
|
+
if (!__hasOwnProp2.call(to, key2) && key2 !== except)
|
|
12707
|
+
__defProp2(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc2(from, key2)) || desc.enumerable });
|
|
12708
|
+
}
|
|
12709
|
+
return to;
|
|
12710
|
+
};
|
|
12711
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
12712
|
+
function configureDebugLogging(config) {
|
|
12713
|
+
debugConfig = { ...debugConfig, ...config };
|
|
12714
|
+
}
|
|
12715
|
+
function getTimestamp() {
|
|
12716
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
12717
|
+
}
|
|
12718
|
+
function formatMessage(level, component, message, metadata) {
|
|
12719
|
+
const timestamp = debugConfig.enableTimestamps ? `[${getTimestamp()}] ` : "";
|
|
12720
|
+
const metadataStr = metadata ? ` ${JSON.stringify(metadata)}` : "";
|
|
12721
|
+
return `${timestamp}[${level}] [${component}] ${message}${metadataStr}`;
|
|
12722
|
+
}
|
|
12723
|
+
function debugError(component, message, metadata) {
|
|
12724
|
+
if (debugConfig.level >= 0) {
|
|
12725
|
+
console.error(formatMessage("ERROR", component, message, metadata));
|
|
12726
|
+
}
|
|
12727
|
+
}
|
|
12728
|
+
function debugWarn(component, message, metadata) {
|
|
12729
|
+
if (debugConfig.level >= 1) {
|
|
12730
|
+
console.warn(formatMessage("WARN", component, message, metadata));
|
|
12731
|
+
}
|
|
12732
|
+
}
|
|
12733
|
+
function debugInfo(component, message, metadata) {
|
|
12734
|
+
if (debugConfig.level >= 2) {
|
|
12735
|
+
console.log(formatMessage("INFO", component, message, metadata));
|
|
12736
|
+
}
|
|
12737
|
+
}
|
|
12738
|
+
function debugLog(component, message, metadata) {
|
|
12739
|
+
if (debugConfig.level >= 3) {
|
|
12740
|
+
console.log(formatMessage("DEBUG", component, message, metadata));
|
|
12741
|
+
}
|
|
12742
|
+
}
|
|
12743
|
+
function debugTrace(component, message, metadata) {
|
|
12744
|
+
if (debugConfig.level >= 4) {
|
|
12745
|
+
console.log(formatMessage("TRACE", component, message, metadata));
|
|
12746
|
+
}
|
|
12747
|
+
}
|
|
12748
|
+
function logRequest(component, operation, params) {
|
|
12749
|
+
if (!debugConfig.enableRequestLogging)
|
|
12750
|
+
return;
|
|
12751
|
+
debugLog(component, `\u{1F504} Request: ${operation}`, {
|
|
12752
|
+
operation,
|
|
12753
|
+
params: JSON.stringify(params, null, 2)
|
|
12754
|
+
});
|
|
12755
|
+
}
|
|
12756
|
+
function logResponse(component, operation, response, duration) {
|
|
12757
|
+
if (!debugConfig.enableRequestLogging)
|
|
12758
|
+
return;
|
|
12759
|
+
debugLog(component, `\u2705 Response: ${operation} (${duration}ms)`, {
|
|
12760
|
+
operation,
|
|
12761
|
+
duration,
|
|
12762
|
+
response: typeof response === "object" ? JSON.stringify(response, null, 2) : response
|
|
12763
|
+
});
|
|
12764
|
+
}
|
|
12765
|
+
function logError(component, operation, error, duration) {
|
|
12766
|
+
const durationStr = duration ? ` (${duration}ms)` : "";
|
|
12767
|
+
debugError(component, `\u274C Error: ${operation}${durationStr}`, {
|
|
12768
|
+
operation,
|
|
12769
|
+
duration,
|
|
12770
|
+
error: error?.message || error?.toString() || "Unknown error",
|
|
12771
|
+
stack: error?.stack
|
|
12772
|
+
});
|
|
12773
|
+
}
|
|
12774
|
+
function logConnectionAttempt(network, attempt, maxAttempts) {
|
|
12775
|
+
debugInfo("CONNECTION", `\u{1F517} Connecting to ${network} (attempt ${attempt}/${maxAttempts})`);
|
|
12776
|
+
}
|
|
12777
|
+
function logConnectionSuccess(network, latency) {
|
|
12778
|
+
debugInfo("CONNECTION", `\u2705 Connected to ${network} (${latency}ms)`);
|
|
12779
|
+
networkMetrics.recordRequest(`connection-${network}`, true, latency);
|
|
12780
|
+
}
|
|
12781
|
+
function logConnectionFailure(network, error, attempt) {
|
|
12782
|
+
debugError("CONNECTION", `\u274C Connection failed to ${network} (attempt ${attempt})`, { error });
|
|
12783
|
+
networkMetrics.recordRequest(`connection-${network}`, false, 0, error);
|
|
12784
|
+
}
|
|
12785
|
+
function logPkpOperation(operation, pkpId, details) {
|
|
12786
|
+
const pkpStr = pkpId ? ` (PKP: ${pkpId.slice(0, 8)}...)` : "";
|
|
12787
|
+
debugInfo("PKP", `\u{1F511} ${operation}${pkpStr}`, details);
|
|
12788
|
+
}
|
|
12789
|
+
function logSessionSignatures(count, expiration) {
|
|
12790
|
+
debugInfo("SESSION", `\u{1F510} Generated ${count} session signatures (expires: ${expiration})`);
|
|
12791
|
+
}
|
|
12792
|
+
function logLitActionExecution(cid, params) {
|
|
12793
|
+
debugInfo("LIT_ACTION", `\u26A1 Executing LIT Action: ${cid}`, {
|
|
12794
|
+
cid,
|
|
12795
|
+
params
|
|
12796
|
+
});
|
|
12797
|
+
}
|
|
12798
|
+
function logLitActionResult(cid, success2, duration, result) {
|
|
12799
|
+
const status = success2 ? "\u2705" : "\u274C";
|
|
12800
|
+
debugInfo("LIT_ACTION", `${status} LIT Action completed: ${cid} (${duration}ms)`, {
|
|
12801
|
+
cid,
|
|
12802
|
+
success: success2,
|
|
12803
|
+
duration,
|
|
12804
|
+
result: success2 && result ? JSON.stringify(result, null, 2) : void 0
|
|
12805
|
+
});
|
|
12806
|
+
}
|
|
12807
|
+
function logTestStart(testName) {
|
|
12808
|
+
debugInfo("TEST", `\u{1F9EA} Starting test: ${testName}`);
|
|
12809
|
+
return new PerformanceTracker(testName);
|
|
12810
|
+
}
|
|
12811
|
+
function logTestEnd(testName, success2, duration) {
|
|
12812
|
+
const status = success2 ? "\u2705" : "\u274C";
|
|
12813
|
+
debugInfo("TEST", `${status} Test completed: ${testName} (${duration}ms)`);
|
|
12814
|
+
networkMetrics.printSummary();
|
|
12815
|
+
}
|
|
12816
|
+
var LogLevel2;
|
|
12817
|
+
var DEFAULT_DEBUG_CONFIG;
|
|
12818
|
+
var debugConfig;
|
|
12819
|
+
var PerformanceTracker;
|
|
12820
|
+
var NetworkMetricsCollector;
|
|
12821
|
+
var networkMetrics;
|
|
12822
|
+
var init_debug_logger = __esm2({
|
|
12823
|
+
"pkg-src/utils/chunks/debug-logger.ts"() {
|
|
12824
|
+
"use strict";
|
|
12825
|
+
LogLevel2 = /* @__PURE__ */ ((LogLevel22) => {
|
|
12826
|
+
LogLevel22[LogLevel22["ERROR"] = 0] = "ERROR";
|
|
12827
|
+
LogLevel22[LogLevel22["WARN"] = 1] = "WARN";
|
|
12828
|
+
LogLevel22[LogLevel22["INFO"] = 2] = "INFO";
|
|
12829
|
+
LogLevel22[LogLevel22["DEBUG"] = 3] = "DEBUG";
|
|
12830
|
+
LogLevel22[LogLevel22["TRACE"] = 4] = "TRACE";
|
|
12831
|
+
return LogLevel22;
|
|
12832
|
+
})(LogLevel2 || {});
|
|
12833
|
+
DEFAULT_DEBUG_CONFIG = {
|
|
12834
|
+
level: 2,
|
|
12835
|
+
enableTimestamps: true,
|
|
12836
|
+
enablePerformanceMetrics: true,
|
|
12837
|
+
enableRequestLogging: true,
|
|
12838
|
+
enableNetworkMetrics: true
|
|
12839
|
+
};
|
|
12840
|
+
debugConfig = { ...DEFAULT_DEBUG_CONFIG };
|
|
12841
|
+
PerformanceTracker = class {
|
|
12842
|
+
constructor(operationName) {
|
|
12843
|
+
this.operationName = operationName;
|
|
12844
|
+
this.markers = /* @__PURE__ */ new Map();
|
|
12845
|
+
this.startTime = Date.now();
|
|
12846
|
+
this.log("PERF", `Started: ${operationName}`);
|
|
12847
|
+
}
|
|
12848
|
+
mark(label) {
|
|
12849
|
+
const elapsed = Date.now() - this.startTime;
|
|
12850
|
+
this.markers.set(label, elapsed);
|
|
12851
|
+
this.log("PERF", `${this.operationName} - ${label}: ${elapsed}ms`);
|
|
12852
|
+
}
|
|
12853
|
+
end(success2 = true) {
|
|
12854
|
+
const totalTime = Date.now() - this.startTime;
|
|
12855
|
+
const status = success2 ? "SUCCESS" : "FAILED";
|
|
12856
|
+
this.log("PERF", `${this.operationName} - ${status}: ${totalTime}ms`);
|
|
12857
|
+
if (debugConfig.enablePerformanceMetrics && this.markers.size > 0) {
|
|
12858
|
+
console.log(`\u{1F4CA} Performance Breakdown for ${this.operationName}:`);
|
|
12859
|
+
for (const [label, time] of this.markers) {
|
|
12860
|
+
console.log(` ${label}: ${time}ms`);
|
|
12861
|
+
}
|
|
12862
|
+
console.log(` Total: ${totalTime}ms`);
|
|
12863
|
+
}
|
|
12864
|
+
return totalTime;
|
|
12865
|
+
}
|
|
12866
|
+
log(level, message) {
|
|
12867
|
+
if (debugConfig.enablePerformanceMetrics) {
|
|
12868
|
+
console.log(formatMessage(level, "PERFORMANCE", message));
|
|
12869
|
+
}
|
|
12870
|
+
}
|
|
12871
|
+
};
|
|
12872
|
+
NetworkMetricsCollector = class {
|
|
12873
|
+
constructor() {
|
|
12874
|
+
this.metrics = /* @__PURE__ */ new Map();
|
|
12875
|
+
}
|
|
12876
|
+
getMetrics(operation) {
|
|
12877
|
+
if (!this.metrics.has(operation)) {
|
|
12878
|
+
this.metrics.set(operation, {
|
|
12879
|
+
requestCount: 0,
|
|
12880
|
+
successCount: 0,
|
|
12881
|
+
failureCount: 0,
|
|
12882
|
+
averageLatency: 0,
|
|
12883
|
+
startTime: Date.now()
|
|
12884
|
+
});
|
|
12885
|
+
}
|
|
12886
|
+
return this.metrics.get(operation);
|
|
12887
|
+
}
|
|
12888
|
+
recordRequest(operation, success2, latency, error) {
|
|
12889
|
+
const metrics = this.getMetrics(operation);
|
|
12890
|
+
metrics.requestCount++;
|
|
12891
|
+
if (success2) {
|
|
12892
|
+
metrics.successCount++;
|
|
12893
|
+
metrics.averageLatency = (metrics.averageLatency * (metrics.successCount - 1) + latency) / metrics.successCount;
|
|
12894
|
+
} else {
|
|
12895
|
+
metrics.failureCount++;
|
|
12896
|
+
if (error)
|
|
12897
|
+
metrics.lastError = error;
|
|
12898
|
+
}
|
|
12899
|
+
if (debugConfig.enableNetworkMetrics) {
|
|
12900
|
+
const successRate = (metrics.successCount / metrics.requestCount * 100).toFixed(1);
|
|
12901
|
+
debugLog("NETWORK", `${operation} - Success: ${success2}, Latency: ${latency}ms, Success Rate: ${successRate}%`);
|
|
12902
|
+
}
|
|
12903
|
+
}
|
|
12904
|
+
printSummary() {
|
|
12905
|
+
if (!debugConfig.enableNetworkMetrics)
|
|
12906
|
+
return;
|
|
12907
|
+
console.log("\n\u{1F4C8} Network Metrics Summary:");
|
|
12908
|
+
for (const [operation, metrics] of this.metrics) {
|
|
12909
|
+
const successRate = (metrics.successCount / metrics.requestCount * 100).toFixed(1);
|
|
12910
|
+
const runtime = Date.now() - metrics.startTime;
|
|
12911
|
+
console.log(` ${operation}:`);
|
|
12912
|
+
console.log(` Requests: ${metrics.requestCount}`);
|
|
12913
|
+
console.log(` Success Rate: ${successRate}%`);
|
|
12914
|
+
console.log(` Avg Latency: ${metrics.averageLatency.toFixed(0)}ms`);
|
|
12915
|
+
console.log(` Runtime: ${runtime}ms`);
|
|
12916
|
+
if (metrics.lastError) {
|
|
12917
|
+
console.log(` Last Error: ${metrics.lastError}`);
|
|
12918
|
+
}
|
|
12919
|
+
}
|
|
12920
|
+
}
|
|
12921
|
+
};
|
|
12922
|
+
networkMetrics = new NetworkMetricsCollector();
|
|
12923
|
+
}
|
|
12738
12924
|
});
|
|
12739
|
-
var
|
|
12740
|
-
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
|
|
12744
|
-
|
|
12745
|
-
|
|
12746
|
-
|
|
12747
|
-
|
|
12748
|
-
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
|
|
12925
|
+
var session_signature_cache_exports = {};
|
|
12926
|
+
__export2(session_signature_cache_exports, {
|
|
12927
|
+
DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
|
|
12928
|
+
clearSessionSignatureCache: () => clearSessionSignatureCache,
|
|
12929
|
+
configureSessionSignatureCache: () => configureSessionSignatureCache,
|
|
12930
|
+
generateSessionSignaturesWithCache: () => generateSessionSignaturesWithCache,
|
|
12931
|
+
getSessionSignatureCacheStats: () => getSessionSignatureCacheStats,
|
|
12932
|
+
sessionSignatureCache: () => sessionSignatureCache
|
|
12933
|
+
});
|
|
12934
|
+
async function generateSessionSignaturesWithCache(litNodeClient, sessionConfig, pkpTokenId, litActionCid, signerAddress, network = "chipotle") {
|
|
12935
|
+
const cached = sessionSignatureCache.get(pkpTokenId, litActionCid, signerAddress, network);
|
|
12936
|
+
if (cached) {
|
|
12937
|
+
return cached;
|
|
12938
|
+
}
|
|
12939
|
+
debugInfo("CACHE", "\u{1F510} Generating new session signatures (cache miss)...");
|
|
12940
|
+
const sessionSigs = await litNodeClient.getSessionSigs(sessionConfig);
|
|
12941
|
+
const expiration = new Date(sessionConfig.expiration);
|
|
12942
|
+
sessionSignatureCache.set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration);
|
|
12943
|
+
const sigCount = Object.keys(sessionSigs).length;
|
|
12944
|
+
debugInfo("CACHE", `\u2705 Generated and cached ${sigCount} session signatures`);
|
|
12945
|
+
return sessionSigs;
|
|
12946
|
+
}
|
|
12947
|
+
function configureSessionSignatureCache(config) {
|
|
12948
|
+
Object.assign(sessionSignatureCache["config"], config);
|
|
12949
|
+
}
|
|
12950
|
+
function clearSessionSignatureCache() {
|
|
12951
|
+
sessionSignatureCache.clear();
|
|
12952
|
+
}
|
|
12953
|
+
function getSessionSignatureCacheStats() {
|
|
12954
|
+
return sessionSignatureCache.getStats();
|
|
12955
|
+
}
|
|
12956
|
+
var DEFAULT_CACHE_CONFIG;
|
|
12957
|
+
var SessionSignatureCache;
|
|
12958
|
+
var sessionSignatureCache;
|
|
12959
|
+
var init_session_signature_cache = __esm2({
|
|
12960
|
+
"pkg-src/utils/chunks/session-signature-cache.ts"() {
|
|
12961
|
+
"use strict";
|
|
12962
|
+
init_debug_logger();
|
|
12963
|
+
DEFAULT_CACHE_CONFIG = {
|
|
12964
|
+
maxEntries: 50,
|
|
12965
|
+
bufferTimeMs: 6e4,
|
|
12966
|
+
// 1 minute buffer before expiration
|
|
12967
|
+
enableLogging: true
|
|
12968
|
+
};
|
|
12969
|
+
SessionSignatureCache = class {
|
|
12970
|
+
constructor(config = {}) {
|
|
12971
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
12972
|
+
this.config = { ...DEFAULT_CACHE_CONFIG, ...config };
|
|
12973
|
+
}
|
|
12974
|
+
/**
|
|
12975
|
+
* Generate cache key from PKP and context
|
|
12976
|
+
*/
|
|
12977
|
+
generateCacheKey(pkpTokenId, litActionCid, signerAddress, network) {
|
|
12978
|
+
return `${signerAddress}-${network}-${pkpTokenId}-${litActionCid}`;
|
|
12979
|
+
}
|
|
12980
|
+
/**
|
|
12981
|
+
* Check if cache entry is still valid
|
|
12982
|
+
*/
|
|
12983
|
+
isEntryValid(entry) {
|
|
12984
|
+
const now2 = /* @__PURE__ */ new Date();
|
|
12985
|
+
const expirationWithBuffer = new Date(
|
|
12986
|
+
entry.expiration.getTime() - this.config.bufferTimeMs
|
|
12987
|
+
);
|
|
12988
|
+
return now2 < expirationWithBuffer;
|
|
12989
|
+
}
|
|
12990
|
+
/**
|
|
12991
|
+
* Clean expired entries from cache
|
|
12992
|
+
*/
|
|
12993
|
+
cleanExpiredEntries() {
|
|
12994
|
+
const now2 = /* @__PURE__ */ new Date();
|
|
12995
|
+
let cleanedCount = 0;
|
|
12996
|
+
for (const [key2, entry] of this.cache.entries()) {
|
|
12997
|
+
if (now2 >= entry.expiration) {
|
|
12998
|
+
this.cache.delete(key2);
|
|
12999
|
+
cleanedCount++;
|
|
13000
|
+
}
|
|
13001
|
+
}
|
|
13002
|
+
if (cleanedCount > 0 && this.config.enableLogging) {
|
|
13003
|
+
debugInfo("CACHE", `\u{1F9F9} Cleaned ${cleanedCount} expired session signature entries`);
|
|
13004
|
+
}
|
|
13005
|
+
}
|
|
13006
|
+
/**
|
|
13007
|
+
* Enforce cache size limits
|
|
13008
|
+
*/
|
|
13009
|
+
enforceCacheSize() {
|
|
13010
|
+
if (this.cache.size <= this.config.maxEntries) {
|
|
13011
|
+
return;
|
|
13012
|
+
}
|
|
13013
|
+
const entries = Array.from(this.cache.entries()).sort(([, a], [, b]) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
13014
|
+
const toRemove = entries.slice(0, this.cache.size - this.config.maxEntries);
|
|
13015
|
+
for (const [key2] of toRemove) {
|
|
13016
|
+
this.cache.delete(key2);
|
|
13017
|
+
}
|
|
13018
|
+
if (this.config.enableLogging) {
|
|
13019
|
+
debugInfo("CACHE", `\u{1F4E6} Removed ${toRemove.length} oldest cache entries to maintain size limit`);
|
|
13020
|
+
}
|
|
13021
|
+
}
|
|
13022
|
+
/**
|
|
13023
|
+
* Get cached session signatures if valid
|
|
13024
|
+
*/
|
|
13025
|
+
get(pkpTokenId, litActionCid, signerAddress, network) {
|
|
13026
|
+
this.cleanExpiredEntries();
|
|
13027
|
+
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13028
|
+
const entry = this.cache.get(cacheKey);
|
|
13029
|
+
if (!entry) {
|
|
13030
|
+
if (this.config.enableLogging) {
|
|
13031
|
+
debugLog("CACHE", `\u274C Session signatures cache miss: ${cacheKey}`);
|
|
13032
|
+
}
|
|
13033
|
+
return null;
|
|
13034
|
+
}
|
|
13035
|
+
if (!this.isEntryValid(entry)) {
|
|
13036
|
+
this.cache.delete(cacheKey);
|
|
13037
|
+
if (this.config.enableLogging) {
|
|
13038
|
+
debugWarn("CACHE", `\u23F0 Session signatures expired: ${cacheKey}`);
|
|
13039
|
+
}
|
|
13040
|
+
return null;
|
|
13041
|
+
}
|
|
13042
|
+
if (this.config.enableLogging) {
|
|
13043
|
+
const timeUntilExpiry = entry.expiration.getTime() - Date.now();
|
|
13044
|
+
debugInfo("CACHE", `\u2705 Session signatures cache hit: ${cacheKey} (expires in ${Math.round(timeUntilExpiry / 1e3)}s)`);
|
|
13045
|
+
}
|
|
13046
|
+
return entry.sessionSigs;
|
|
13047
|
+
}
|
|
13048
|
+
/**
|
|
13049
|
+
* Cache session signatures
|
|
13050
|
+
*/
|
|
13051
|
+
set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration) {
|
|
13052
|
+
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13053
|
+
const entry = {
|
|
13054
|
+
sessionSigs,
|
|
13055
|
+
expiration,
|
|
13056
|
+
pkpTokenId,
|
|
13057
|
+
litActionCid,
|
|
13058
|
+
signerAddress,
|
|
13059
|
+
network,
|
|
13060
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
13061
|
+
};
|
|
13062
|
+
this.cache.set(cacheKey, entry);
|
|
13063
|
+
if (this.config.enableLogging) {
|
|
13064
|
+
const timeUntilExpiry = expiration.getTime() - Date.now();
|
|
13065
|
+
debugInfo("CACHE", `\u{1F4BE} Cached session signatures: ${cacheKey} (expires in ${Math.round(timeUntilExpiry / 1e3)}s)`);
|
|
13066
|
+
}
|
|
13067
|
+
this.enforceCacheSize();
|
|
13068
|
+
}
|
|
13069
|
+
/**
|
|
13070
|
+
* Clear all cached session signatures
|
|
13071
|
+
*/
|
|
13072
|
+
clear() {
|
|
13073
|
+
const size = this.cache.size;
|
|
13074
|
+
this.cache.clear();
|
|
13075
|
+
if (this.config.enableLogging) {
|
|
13076
|
+
debugInfo("CACHE", `\u{1F5D1}\uFE0F Cleared ${size} cached session signature entries`);
|
|
13077
|
+
}
|
|
13078
|
+
}
|
|
13079
|
+
/**
|
|
13080
|
+
* Get cache statistics
|
|
13081
|
+
*/
|
|
13082
|
+
getStats() {
|
|
13083
|
+
this.cleanExpiredEntries();
|
|
13084
|
+
return {
|
|
13085
|
+
size: this.cache.size,
|
|
13086
|
+
maxEntries: this.config.maxEntries,
|
|
13087
|
+
utilizationPercent: Math.round(this.cache.size / this.config.maxEntries * 100)
|
|
13088
|
+
};
|
|
13089
|
+
}
|
|
13090
|
+
/**
|
|
13091
|
+
* Remove specific cache entry
|
|
13092
|
+
*/
|
|
13093
|
+
delete(pkpTokenId, litActionCid, signerAddress, network) {
|
|
13094
|
+
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13095
|
+
const deleted = this.cache.delete(cacheKey);
|
|
13096
|
+
if (deleted && this.config.enableLogging) {
|
|
13097
|
+
debugInfo("CACHE", `\u{1F5D1}\uFE0F Removed session signatures from cache: ${cacheKey}`);
|
|
13098
|
+
}
|
|
13099
|
+
return deleted;
|
|
13100
|
+
}
|
|
13101
|
+
};
|
|
13102
|
+
sessionSignatureCache = new SessionSignatureCache();
|
|
13103
|
+
}
|
|
13104
|
+
});
|
|
13105
|
+
var index_exports = {};
|
|
13106
|
+
__export2(index_exports, {
|
|
13107
|
+
CHIPOTLE_DEPLOYMENTS: () => CHIPOTLE_DEPLOYMENTS,
|
|
13108
|
+
DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
|
|
13109
|
+
DEFAULT_DEBUG_CONFIG: () => DEFAULT_DEBUG_CONFIG,
|
|
13110
|
+
DEFAULT_RETRY_CONFIG: () => DEFAULT_RETRY_CONFIG,
|
|
13111
|
+
DH_LIT_ACTIONS_CHIPOTLE: () => DH_LIT_ACTIONS_CHIPOTLE3,
|
|
13112
|
+
ErrorCategory: () => ErrorCategory2,
|
|
13113
|
+
LogLevel: () => LogLevel2,
|
|
13114
|
+
NETWORK_TIMEOUTS: () => NETWORK_TIMEOUTS,
|
|
13115
|
+
PerformanceTracker: () => PerformanceTracker,
|
|
13116
|
+
RetryStrategy: () => RetryStrategy,
|
|
13117
|
+
analyzeError: () => analyzeError,
|
|
13118
|
+
calculateDelay: () => calculateDelay,
|
|
13119
|
+
cidToHex: () => cidToHex,
|
|
13120
|
+
classifyError: () => classifyError,
|
|
13121
|
+
clearSessionSignatureCache: () => clearSessionSignatureCache,
|
|
13122
|
+
configureDebugLogging: () => configureDebugLogging,
|
|
13123
|
+
configureSessionSignatureCache: () => configureSessionSignatureCache,
|
|
13124
|
+
connectLitContracts: () => connectLitContracts,
|
|
13125
|
+
connectLitNodeClient: () => connectLitNodeClient,
|
|
13126
|
+
createErrorReport: () => createErrorReport,
|
|
13127
|
+
debugError: () => debugError,
|
|
13128
|
+
debugInfo: () => debugInfo,
|
|
13129
|
+
debugLog: () => debugLog,
|
|
13130
|
+
debugTrace: () => debugTrace,
|
|
13131
|
+
debugWarn: () => debugWarn,
|
|
13132
|
+
executeLitAction: () => executeLitAction,
|
|
13133
|
+
executePkpOperation: () => executePkpOperation,
|
|
13134
|
+
generateSessionSignatures: () => generateSessionSignatures,
|
|
13135
|
+
generateSessionSignaturesWithCache: () => generateSessionSignaturesWithCache,
|
|
13136
|
+
getDeployedActions: () => getDeployedActions,
|
|
13137
|
+
getDeploymentsForNetwork: () => getDeploymentsForNetwork,
|
|
13138
|
+
getLitActionCID: () => getLitActionCID,
|
|
13139
|
+
getLitActionConfig: () => getLitActionConfig,
|
|
13140
|
+
getNetworkTimeouts: () => getNetworkTimeouts,
|
|
13141
|
+
getPKPValidatorSetup: () => getPKPValidatorSetup,
|
|
13142
|
+
getRetryConfigFromClassification: () => getRetryConfigFromClassification,
|
|
13143
|
+
getSessionSignatureCacheStats: () => getSessionSignatureCacheStats,
|
|
13144
|
+
isLitActionDeployed: () => isLitActionDeployed,
|
|
13145
|
+
isRetryableError: () => isRetryableError,
|
|
13146
|
+
litProtocolErrors: () => litProtocolErrors,
|
|
13147
|
+
logConnectionAttempt: () => logConnectionAttempt,
|
|
13148
|
+
logConnectionFailure: () => logConnectionFailure,
|
|
13149
|
+
logConnectionSuccess: () => logConnectionSuccess,
|
|
13150
|
+
logError: () => logError,
|
|
13151
|
+
logLitActionExecution: () => logLitActionExecution,
|
|
13152
|
+
logLitActionResult: () => logLitActionResult,
|
|
13153
|
+
logPkpOperation: () => logPkpOperation,
|
|
13154
|
+
logRequest: () => logRequest,
|
|
13155
|
+
logResponse: () => logResponse,
|
|
13156
|
+
logSessionSignatures: () => logSessionSignatures,
|
|
13157
|
+
logTestEnd: () => logTestEnd,
|
|
13158
|
+
logTestStart: () => logTestStart,
|
|
13159
|
+
networkMetrics: () => networkMetrics,
|
|
13160
|
+
sessionSignatureCache: () => sessionSignatureCache,
|
|
13161
|
+
sleep: () => sleep,
|
|
13162
|
+
validateDeployedActions: () => validateDeployedActions,
|
|
13163
|
+
validateLitNodeConnection: () => validateLitNodeConnection,
|
|
13164
|
+
validateLitNodeReadiness: () => validateLitNodeReadiness,
|
|
13165
|
+
withRetry: () => withRetry
|
|
13166
|
+
});
|
|
13167
|
+
module2.exports = __toCommonJS2(index_exports);
|
|
13168
|
+
function base2(ALPHABET2) {
|
|
13169
|
+
if (ALPHABET2.length >= 255) {
|
|
12759
13170
|
throw new TypeError("Alphabet too long");
|
|
12760
13171
|
}
|
|
12761
13172
|
const BASE_MAP = new Uint8Array(256);
|
|
12762
13173
|
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
12763
13174
|
BASE_MAP[j] = 255;
|
|
12764
13175
|
}
|
|
12765
|
-
for (let i = 0; i <
|
|
12766
|
-
const x =
|
|
13176
|
+
for (let i = 0; i < ALPHABET2.length; i++) {
|
|
13177
|
+
const x = ALPHABET2.charAt(i);
|
|
12767
13178
|
const xc = x.charCodeAt(0);
|
|
12768
13179
|
if (BASE_MAP[xc] !== 255) {
|
|
12769
13180
|
throw new TypeError(x + " is ambiguous");
|
|
12770
13181
|
}
|
|
12771
13182
|
BASE_MAP[xc] = i;
|
|
12772
13183
|
}
|
|
12773
|
-
const BASE =
|
|
12774
|
-
const LEADER =
|
|
13184
|
+
const BASE = ALPHABET2.length;
|
|
13185
|
+
const LEADER = ALPHABET2.charAt(0);
|
|
12775
13186
|
const FACTOR = Math.log(BASE) / Math.log(256);
|
|
12776
13187
|
const iFACTOR = Math.log(256) / Math.log(BASE);
|
|
12777
13188
|
function encode4(source) {
|
|
@@ -12817,7 +13228,7 @@ var require_cjs = __commonJS({
|
|
|
12817
13228
|
}
|
|
12818
13229
|
let str = LEADER.repeat(zeroes);
|
|
12819
13230
|
for (; it2 < size; ++it2) {
|
|
12820
|
-
str +=
|
|
13231
|
+
str += ALPHABET2.charAt(b58[it2]);
|
|
12821
13232
|
}
|
|
12822
13233
|
return str;
|
|
12823
13234
|
}
|
|
@@ -12882,38 +13293,13 @@ var require_cjs = __commonJS({
|
|
|
12882
13293
|
decode: decode3
|
|
12883
13294
|
};
|
|
12884
13295
|
}
|
|
12885
|
-
|
|
12886
|
-
}
|
|
12887
|
-
});
|
|
12888
|
-
|
|
12889
|
-
// node_modules/bs58/src/cjs/index.cjs
|
|
12890
|
-
var require_cjs2 = __commonJS({
|
|
12891
|
-
"node_modules/bs58/src/cjs/index.cjs"(exports) {
|
|
12892
|
-
"use strict";
|
|
12893
|
-
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
12894
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
12895
|
-
};
|
|
12896
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12897
|
-
var base_x_1 = __importDefault(require_cjs());
|
|
13296
|
+
var esm_default = base2;
|
|
12898
13297
|
var ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
12899
|
-
|
|
12900
|
-
}
|
|
12901
|
-
});
|
|
12902
|
-
|
|
12903
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/cid-utils.js
|
|
12904
|
-
var require_cid_utils = __commonJS({
|
|
12905
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/cid-utils.js"(exports) {
|
|
12906
|
-
"use strict";
|
|
12907
|
-
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
12908
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
12909
|
-
};
|
|
12910
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12911
|
-
exports.cidToHex = cidToHex;
|
|
12912
|
-
var bs58_1 = __importDefault(require_cjs2());
|
|
13298
|
+
var esm_default2 = esm_default(ALPHABET);
|
|
12913
13299
|
function cidToHex(cid) {
|
|
12914
13300
|
try {
|
|
12915
13301
|
if (cid.startsWith("Qm")) {
|
|
12916
|
-
const bytes =
|
|
13302
|
+
const bytes = esm_default2.decode(cid);
|
|
12917
13303
|
return "0x" + Buffer.from(bytes).toString("hex");
|
|
12918
13304
|
} else if (cid.startsWith("0x")) {
|
|
12919
13305
|
return cid;
|
|
@@ -12927,21 +13313,12 @@ var require_cid_utils = __commonJS({
|
|
|
12927
13313
|
throw new Error(`Failed to convert CID ${cid} to hex: ${error instanceof Error ? error.message : String(error)}`);
|
|
12928
13314
|
}
|
|
12929
13315
|
}
|
|
12930
|
-
|
|
12931
|
-
});
|
|
12932
|
-
|
|
12933
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.js
|
|
12934
|
-
var require_lit_actions_registry = __commonJS({
|
|
12935
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.js"(exports) {
|
|
12936
|
-
"use strict";
|
|
12937
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12938
|
-
exports.CHIPOTLE_DEPLOYMENTS = exports.DH_LIT_ACTIONS_CHIPOTLE = void 0;
|
|
12939
|
-
exports.getDeploymentsForNetwork = getDeploymentsForNetwork;
|
|
12940
|
-
var cid_utils_1 = require_cid_utils();
|
|
12941
|
-
exports.DH_LIT_ACTIONS_CHIPOTLE = {
|
|
13316
|
+
var DH_LIT_ACTIONS_CHIPOTLE3 = {
|
|
12942
13317
|
authorizationDummy: {
|
|
12943
13318
|
cid: "QmXPh5RTReLqjqZDRNhgVKi1TWMJK2vS9QSRPkWPhLBQJN",
|
|
12944
|
-
authorizedCidHex:
|
|
13319
|
+
authorizedCidHex: cidToHex(
|
|
13320
|
+
"QmXPh5RTReLqjqZDRNhgVKi1TWMJK2vS9QSRPkWPhLBQJN"
|
|
13321
|
+
),
|
|
12945
13322
|
name: "Authorization Dummy",
|
|
12946
13323
|
description: "Production Authorization Dummy",
|
|
12947
13324
|
version: "1.0.0",
|
|
@@ -12952,7 +13329,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
12952
13329
|
},
|
|
12953
13330
|
authorizationDummyB: {
|
|
12954
13331
|
cid: "QmQXTcAU9tr4YAVrzHujEJw9moJgM1o5gnJU2ojcvhigua",
|
|
12955
|
-
authorizedCidHex:
|
|
13332
|
+
authorizedCidHex: cidToHex(
|
|
13333
|
+
"QmQXTcAU9tr4YAVrzHujEJw9moJgM1o5gnJU2ojcvhigua"
|
|
13334
|
+
),
|
|
12956
13335
|
name: "Authorization Dummy B",
|
|
12957
13336
|
description: "Production Authorization Dummy B",
|
|
12958
13337
|
version: "1.0.0",
|
|
@@ -12963,7 +13342,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
12963
13342
|
},
|
|
12964
13343
|
pkpValidator: {
|
|
12965
13344
|
cid: "QmTqsmXkjib7CRGFcEhmCs61Z3EZTaRPznaZDDLk5Wq9NX",
|
|
12966
|
-
authorizedCidHex:
|
|
13345
|
+
authorizedCidHex: cidToHex(
|
|
13346
|
+
"QmTqsmXkjib7CRGFcEhmCs61Z3EZTaRPznaZDDLk5Wq9NX"
|
|
13347
|
+
),
|
|
12967
13348
|
name: "Pkp Validator",
|
|
12968
13349
|
description: "Production Pkp Validator",
|
|
12969
13350
|
version: "1.0.0",
|
|
@@ -12979,7 +13360,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
12979
13360
|
},
|
|
12980
13361
|
btcTransactionSigner: {
|
|
12981
13362
|
cid: "QmYSvuDcn2EPjRoDsPBLK2e3PGYEUHtWAPxwB51s4unkaG",
|
|
12982
|
-
authorizedCidHex:
|
|
13363
|
+
authorizedCidHex: cidToHex(
|
|
13364
|
+
"QmYSvuDcn2EPjRoDsPBLK2e3PGYEUHtWAPxwB51s4unkaG"
|
|
13365
|
+
),
|
|
12983
13366
|
name: "Btc Transaction Signer",
|
|
12984
13367
|
description: "Production Btc Transaction Signer",
|
|
12985
13368
|
version: "1.0.0",
|
|
@@ -12990,7 +13373,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
12990
13373
|
},
|
|
12991
13374
|
ucdMintValidator: {
|
|
12992
13375
|
cid: "QmbYWJkLBdxTCNUkYTVmBzcp4CFhAn7ZcCyMZjhhbjAUMB",
|
|
12993
|
-
authorizedCidHex:
|
|
13376
|
+
authorizedCidHex: cidToHex(
|
|
13377
|
+
"QmbYWJkLBdxTCNUkYTVmBzcp4CFhAn7ZcCyMZjhhbjAUMB"
|
|
13378
|
+
),
|
|
12994
13379
|
name: "Ucd Mint Validator",
|
|
12995
13380
|
description: "Production Ucd Mint Validator",
|
|
12996
13381
|
version: "1.0.0",
|
|
@@ -13006,7 +13391,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13006
13391
|
},
|
|
13007
13392
|
processPaymentValidator: {
|
|
13008
13393
|
cid: "Qmc9gkDVY1SK9vvyQ9cXa3PSSuv8q6Ki9o9rsG87qpXCYi",
|
|
13009
|
-
authorizedCidHex:
|
|
13394
|
+
authorizedCidHex: cidToHex(
|
|
13395
|
+
"Qmc9gkDVY1SK9vvyQ9cXa3PSSuv8q6Ki9o9rsG87qpXCYi"
|
|
13396
|
+
),
|
|
13010
13397
|
name: "Process Payment Validator",
|
|
13011
13398
|
description: "Production Process Payment Validator",
|
|
13012
13399
|
version: "1.0.0",
|
|
@@ -13022,7 +13409,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13022
13409
|
},
|
|
13023
13410
|
extendPositionValidator: {
|
|
13024
13411
|
cid: "Qmc5MDW6ZxTRe3nXJEKa5KKUCVXFznV9vDqFL4n7ayRZ4p",
|
|
13025
|
-
authorizedCidHex:
|
|
13412
|
+
authorizedCidHex: cidToHex(
|
|
13413
|
+
"Qmc5MDW6ZxTRe3nXJEKa5KKUCVXFznV9vDqFL4n7ayRZ4p"
|
|
13414
|
+
),
|
|
13026
13415
|
name: "Extend Position Validator",
|
|
13027
13416
|
description: "Production Extend Position Validator",
|
|
13028
13417
|
version: "1.0.0",
|
|
@@ -13038,7 +13427,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13038
13427
|
},
|
|
13039
13428
|
btcWithdrawal: {
|
|
13040
13429
|
cid: "QmQC7QKobtNJKArGK7rgGj8ZCcEWt1pBKXPyd5SZ2fi4tt",
|
|
13041
|
-
authorizedCidHex:
|
|
13430
|
+
authorizedCidHex: cidToHex(
|
|
13431
|
+
"QmQC7QKobtNJKArGK7rgGj8ZCcEWt1pBKXPyd5SZ2fi4tt"
|
|
13432
|
+
),
|
|
13042
13433
|
name: "Btc Withdrawal",
|
|
13043
13434
|
description: "Production Btc Withdrawal",
|
|
13044
13435
|
version: "1.0.1",
|
|
@@ -13054,7 +13445,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13054
13445
|
},
|
|
13055
13446
|
liquidationValidator: {
|
|
13056
13447
|
cid: "QmZscQTKzwqWDZwYfaE57vdG4vYoNeQMkC2DwgJsnRNgQf",
|
|
13057
|
-
authorizedCidHex:
|
|
13448
|
+
authorizedCidHex: cidToHex(
|
|
13449
|
+
"QmZscQTKzwqWDZwYfaE57vdG4vYoNeQMkC2DwgJsnRNgQf"
|
|
13450
|
+
),
|
|
13058
13451
|
name: "Liquidation Validator",
|
|
13059
13452
|
description: "Production Liquidation Validator",
|
|
13060
13453
|
version: "1.0.0",
|
|
@@ -13070,7 +13463,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13070
13463
|
},
|
|
13071
13464
|
priceOracle: {
|
|
13072
13465
|
cid: "Qma6vTTnn3AFy3A4u3A7T5tT6eEp26vXt7rPHSWpmBpdsp",
|
|
13073
|
-
authorizedCidHex:
|
|
13466
|
+
authorizedCidHex: cidToHex(
|
|
13467
|
+
"Qma6vTTnn3AFy3A4u3A7T5tT6eEp26vXt7rPHSWpmBpdsp"
|
|
13468
|
+
),
|
|
13074
13469
|
name: "Price Oracle",
|
|
13075
13470
|
description: "Production Price Oracle (Chipotle main+getPrivateKey)",
|
|
13076
13471
|
version: "1.1.0",
|
|
@@ -13086,7 +13481,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13086
13481
|
},
|
|
13087
13482
|
loanVaultBtcBalance: {
|
|
13088
13483
|
cid: "QmWGEg79snhDQ5Fkm9pLhNmLKUJY5uXfp3t3276Jybritq",
|
|
13089
|
-
authorizedCidHex:
|
|
13484
|
+
authorizedCidHex: cidToHex(
|
|
13485
|
+
"QmWGEg79snhDQ5Fkm9pLhNmLKUJY5uXfp3t3276Jybritq"
|
|
13486
|
+
),
|
|
13090
13487
|
name: "Loan Vault Btc Balance",
|
|
13091
13488
|
description: "Production Loan Vault Btc Balance",
|
|
13092
13489
|
version: "1.0.0",
|
|
@@ -13102,7 +13499,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13102
13499
|
},
|
|
13103
13500
|
adminLiquidationValidator: {
|
|
13104
13501
|
cid: "QmYJJFgFPF4BR4ts9GrAkwfEoQbVSXEwnrciZ5Jj9WTDgd",
|
|
13105
|
-
authorizedCidHex:
|
|
13502
|
+
authorizedCidHex: cidToHex(
|
|
13503
|
+
"QmYJJFgFPF4BR4ts9GrAkwfEoQbVSXEwnrciZ5Jj9WTDgd"
|
|
13504
|
+
),
|
|
13106
13505
|
name: "Admin Liquidation Validator",
|
|
13107
13506
|
description: "Production Admin Liquidation Validator",
|
|
13108
13507
|
version: "1.0.0",
|
|
@@ -13118,7 +13517,9 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13118
13517
|
},
|
|
13119
13518
|
alwaysSigner: {
|
|
13120
13519
|
cid: "QmXQjybSsdE19Da66to9Hh7X2dLFwpZPhjoqojxbpk7Nvs",
|
|
13121
|
-
authorizedCidHex:
|
|
13520
|
+
authorizedCidHex: cidToHex(
|
|
13521
|
+
"QmXQjybSsdE19Da66to9Hh7X2dLFwpZPhjoqojxbpk7Nvs"
|
|
13522
|
+
),
|
|
13122
13523
|
name: "Always Signer",
|
|
13123
13524
|
description: "Production Always Signer",
|
|
13124
13525
|
version: "1.0.0",
|
|
@@ -13130,336 +13531,80 @@ var require_lit_actions_registry = __commonJS({
|
|
|
13130
13531
|
};
|
|
13131
13532
|
function getDeploymentsForNetwork(network) {
|
|
13132
13533
|
if (network === "chipotle")
|
|
13133
|
-
return
|
|
13534
|
+
return DH_LIT_ACTIONS_CHIPOTLE3;
|
|
13134
13535
|
throw new Error(`Unsupported LIT network: ${network}`);
|
|
13135
13536
|
}
|
|
13136
|
-
|
|
13137
|
-
}
|
|
13138
|
-
});
|
|
13139
|
-
|
|
13140
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/lit-action-helpers.js
|
|
13141
|
-
var require_lit_action_helpers = __commonJS({
|
|
13142
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/lit-action-helpers.js"(exports) {
|
|
13143
|
-
"use strict";
|
|
13144
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13145
|
-
exports.getLitActionCID = getLitActionCID;
|
|
13146
|
-
exports.getLitActionConfig = getLitActionConfig;
|
|
13147
|
-
exports.isLitActionDeployed = isLitActionDeployed;
|
|
13148
|
-
exports.validateDeployedActions = validateDeployedActions;
|
|
13149
|
-
exports.getDeployedActions = getDeployedActions;
|
|
13150
|
-
var lit_actions_registry_1 = require_lit_actions_registry();
|
|
13537
|
+
var CHIPOTLE_DEPLOYMENTS = DH_LIT_ACTIONS_CHIPOTLE3;
|
|
13151
13538
|
function getLitActionCID(litNetwork = "chipotle", actionName) {
|
|
13152
|
-
const deployments =
|
|
13539
|
+
const deployments = getDeploymentsForNetwork(litNetwork);
|
|
13153
13540
|
const action = deployments[actionName];
|
|
13154
13541
|
if (!action || !action.deployed || !action.cid) {
|
|
13155
|
-
throw new Error(
|
|
13542
|
+
throw new Error(
|
|
13543
|
+
`LIT Action '${actionName}' not deployed on network '${litNetwork}'. Check deployment status.`
|
|
13544
|
+
);
|
|
13156
13545
|
}
|
|
13157
13546
|
return action.cid;
|
|
13158
13547
|
}
|
|
13159
13548
|
function getLitActionConfig(actionName, litNetwork = "chipotle") {
|
|
13160
|
-
const deployments =
|
|
13549
|
+
const deployments = getDeploymentsForNetwork(litNetwork);
|
|
13161
13550
|
const action = deployments[actionName];
|
|
13162
13551
|
if (!action) {
|
|
13163
|
-
throw new Error(
|
|
13552
|
+
throw new Error(
|
|
13553
|
+
`LIT Action '${actionName}' not found in registry for network '${litNetwork}'.`
|
|
13554
|
+
);
|
|
13164
13555
|
}
|
|
13165
13556
|
return action;
|
|
13166
13557
|
}
|
|
13167
13558
|
function isLitActionDeployed(actionName, litNetwork = "chipotle") {
|
|
13168
|
-
const deployments =
|
|
13559
|
+
const deployments = getDeploymentsForNetwork(litNetwork);
|
|
13169
13560
|
const action = deployments[actionName];
|
|
13170
13561
|
return !!(action && action.deployed && action.cid);
|
|
13171
13562
|
}
|
|
13172
13563
|
function validateDeployedActions(requiredActions, litNetwork = "chipotle") {
|
|
13173
|
-
return requiredActions.every(
|
|
13564
|
+
return requiredActions.every(
|
|
13565
|
+
(actionName) => isLitActionDeployed(actionName, litNetwork)
|
|
13566
|
+
);
|
|
13174
13567
|
}
|
|
13175
13568
|
function getDeployedActions(litNetwork = "chipotle") {
|
|
13176
|
-
const deployments =
|
|
13177
|
-
return Object.values(deployments).filter(
|
|
13569
|
+
const deployments = getDeploymentsForNetwork(litNetwork);
|
|
13570
|
+
return Object.values(deployments).filter(
|
|
13571
|
+
(action) => action && action.deployed
|
|
13572
|
+
);
|
|
13178
13573
|
}
|
|
13179
|
-
}
|
|
13180
|
-
});
|
|
13181
|
-
|
|
13182
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/pkp-setup.js
|
|
13183
|
-
var require_pkp_setup = __commonJS({
|
|
13184
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/pkp-setup.js"(exports) {
|
|
13185
|
-
"use strict";
|
|
13186
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13187
|
-
exports.getPKPValidatorSetup = getPKPValidatorSetup;
|
|
13188
|
-
var lit_actions_registry_1 = require_lit_actions_registry();
|
|
13189
13574
|
function getPKPValidatorSetup(litNetwork = "chipotle") {
|
|
13190
|
-
const deployments =
|
|
13575
|
+
const deployments = getDeploymentsForNetwork(litNetwork);
|
|
13191
13576
|
const litAction = deployments.pkpValidator;
|
|
13192
13577
|
if (!litAction || !litAction.pkp) {
|
|
13193
|
-
throw new Error(
|
|
13578
|
+
throw new Error(
|
|
13579
|
+
`PKP validator setup is not available for litNetwork='${litNetwork}'. Ensure the pkpValidator action (with pkp attached) is defined in the registry.`
|
|
13580
|
+
);
|
|
13194
13581
|
}
|
|
13195
13582
|
return {
|
|
13196
13583
|
litAction,
|
|
13197
13584
|
pkp: litAction.pkp
|
|
13198
13585
|
};
|
|
13199
13586
|
}
|
|
13200
|
-
|
|
13201
|
-
|
|
13202
|
-
|
|
13203
|
-
|
|
13204
|
-
|
|
13205
|
-
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
|
|
13210
|
-
|
|
13211
|
-
|
|
13212
|
-
|
|
13213
|
-
|
|
13214
|
-
exports.debugTrace = debugTrace;
|
|
13215
|
-
exports.logRequest = logRequest;
|
|
13216
|
-
exports.logResponse = logResponse;
|
|
13217
|
-
exports.logError = logError;
|
|
13218
|
-
exports.logConnectionAttempt = logConnectionAttempt;
|
|
13219
|
-
exports.logConnectionSuccess = logConnectionSuccess;
|
|
13220
|
-
exports.logConnectionFailure = logConnectionFailure;
|
|
13221
|
-
exports.logPkpOperation = logPkpOperation;
|
|
13222
|
-
exports.logSessionSignatures = logSessionSignatures;
|
|
13223
|
-
exports.logLitActionExecution = logLitActionExecution;
|
|
13224
|
-
exports.logLitActionResult = logLitActionResult;
|
|
13225
|
-
exports.logTestStart = logTestStart;
|
|
13226
|
-
exports.logTestEnd = logTestEnd;
|
|
13227
|
-
var LogLevel2;
|
|
13228
|
-
(function(LogLevel3) {
|
|
13229
|
-
LogLevel3[LogLevel3["ERROR"] = 0] = "ERROR";
|
|
13230
|
-
LogLevel3[LogLevel3["WARN"] = 1] = "WARN";
|
|
13231
|
-
LogLevel3[LogLevel3["INFO"] = 2] = "INFO";
|
|
13232
|
-
LogLevel3[LogLevel3["DEBUG"] = 3] = "DEBUG";
|
|
13233
|
-
LogLevel3[LogLevel3["TRACE"] = 4] = "TRACE";
|
|
13234
|
-
})(LogLevel2 || (exports.LogLevel = LogLevel2 = {}));
|
|
13235
|
-
exports.DEFAULT_DEBUG_CONFIG = {
|
|
13236
|
-
level: LogLevel2.INFO,
|
|
13237
|
-
enableTimestamps: true,
|
|
13238
|
-
enablePerformanceMetrics: true,
|
|
13239
|
-
enableRequestLogging: true,
|
|
13240
|
-
enableNetworkMetrics: true
|
|
13241
|
-
};
|
|
13242
|
-
var debugConfig = { ...exports.DEFAULT_DEBUG_CONFIG };
|
|
13243
|
-
function configureDebugLogging(config) {
|
|
13244
|
-
debugConfig = { ...debugConfig, ...config };
|
|
13245
|
-
}
|
|
13246
|
-
function getTimestamp() {
|
|
13247
|
-
return (/* @__PURE__ */ new Date()).toISOString();
|
|
13248
|
-
}
|
|
13249
|
-
function formatMessage(level, component, message, metadata) {
|
|
13250
|
-
const timestamp = debugConfig.enableTimestamps ? `[${getTimestamp()}] ` : "";
|
|
13251
|
-
const metadataStr = metadata ? ` ${JSON.stringify(metadata)}` : "";
|
|
13252
|
-
return `${timestamp}[${level}] [${component}] ${message}${metadataStr}`;
|
|
13253
|
-
}
|
|
13254
|
-
var PerformanceTracker = class {
|
|
13255
|
-
constructor(operationName) {
|
|
13256
|
-
this.operationName = operationName;
|
|
13257
|
-
this.markers = /* @__PURE__ */ new Map();
|
|
13258
|
-
this.startTime = Date.now();
|
|
13259
|
-
this.log("PERF", `Started: ${operationName}`);
|
|
13260
|
-
}
|
|
13261
|
-
mark(label) {
|
|
13262
|
-
const elapsed = Date.now() - this.startTime;
|
|
13263
|
-
this.markers.set(label, elapsed);
|
|
13264
|
-
this.log("PERF", `${this.operationName} - ${label}: ${elapsed}ms`);
|
|
13265
|
-
}
|
|
13266
|
-
end(success2 = true) {
|
|
13267
|
-
const totalTime = Date.now() - this.startTime;
|
|
13268
|
-
const status = success2 ? "SUCCESS" : "FAILED";
|
|
13269
|
-
this.log("PERF", `${this.operationName} - ${status}: ${totalTime}ms`);
|
|
13270
|
-
if (debugConfig.enablePerformanceMetrics && this.markers.size > 0) {
|
|
13271
|
-
console.log(`\u{1F4CA} Performance Breakdown for ${this.operationName}:`);
|
|
13272
|
-
for (const [label, time] of this.markers) {
|
|
13273
|
-
console.log(` ${label}: ${time}ms`);
|
|
13274
|
-
}
|
|
13275
|
-
console.log(` Total: ${totalTime}ms`);
|
|
13276
|
-
}
|
|
13277
|
-
return totalTime;
|
|
13278
|
-
}
|
|
13279
|
-
log(level, message) {
|
|
13280
|
-
if (debugConfig.enablePerformanceMetrics) {
|
|
13281
|
-
console.log(formatMessage(level, "PERFORMANCE", message));
|
|
13282
|
-
}
|
|
13283
|
-
}
|
|
13284
|
-
};
|
|
13285
|
-
exports.PerformanceTracker = PerformanceTracker;
|
|
13286
|
-
var NetworkMetricsCollector = class {
|
|
13287
|
-
constructor() {
|
|
13288
|
-
this.metrics = /* @__PURE__ */ new Map();
|
|
13289
|
-
}
|
|
13290
|
-
getMetrics(operation) {
|
|
13291
|
-
if (!this.metrics.has(operation)) {
|
|
13292
|
-
this.metrics.set(operation, {
|
|
13293
|
-
requestCount: 0,
|
|
13294
|
-
successCount: 0,
|
|
13295
|
-
failureCount: 0,
|
|
13296
|
-
averageLatency: 0,
|
|
13297
|
-
startTime: Date.now()
|
|
13298
|
-
});
|
|
13299
|
-
}
|
|
13300
|
-
return this.metrics.get(operation);
|
|
13301
|
-
}
|
|
13302
|
-
recordRequest(operation, success2, latency, error) {
|
|
13303
|
-
const metrics = this.getMetrics(operation);
|
|
13304
|
-
metrics.requestCount++;
|
|
13305
|
-
if (success2) {
|
|
13306
|
-
metrics.successCount++;
|
|
13307
|
-
metrics.averageLatency = (metrics.averageLatency * (metrics.successCount - 1) + latency) / metrics.successCount;
|
|
13308
|
-
} else {
|
|
13309
|
-
metrics.failureCount++;
|
|
13310
|
-
if (error)
|
|
13311
|
-
metrics.lastError = error;
|
|
13312
|
-
}
|
|
13313
|
-
if (debugConfig.enableNetworkMetrics) {
|
|
13314
|
-
const successRate = (metrics.successCount / metrics.requestCount * 100).toFixed(1);
|
|
13315
|
-
debugLog("NETWORK", `${operation} - Success: ${success2}, Latency: ${latency}ms, Success Rate: ${successRate}%`);
|
|
13316
|
-
}
|
|
13317
|
-
}
|
|
13318
|
-
printSummary() {
|
|
13319
|
-
if (!debugConfig.enableNetworkMetrics)
|
|
13320
|
-
return;
|
|
13321
|
-
console.log("\n\u{1F4C8} Network Metrics Summary:");
|
|
13322
|
-
for (const [operation, metrics] of this.metrics) {
|
|
13323
|
-
const successRate = (metrics.successCount / metrics.requestCount * 100).toFixed(1);
|
|
13324
|
-
const runtime = Date.now() - metrics.startTime;
|
|
13325
|
-
console.log(` ${operation}:`);
|
|
13326
|
-
console.log(` Requests: ${metrics.requestCount}`);
|
|
13327
|
-
console.log(` Success Rate: ${successRate}%`);
|
|
13328
|
-
console.log(` Avg Latency: ${metrics.averageLatency.toFixed(0)}ms`);
|
|
13329
|
-
console.log(` Runtime: ${runtime}ms`);
|
|
13330
|
-
if (metrics.lastError) {
|
|
13331
|
-
console.log(` Last Error: ${metrics.lastError}`);
|
|
13332
|
-
}
|
|
13333
|
-
}
|
|
13334
|
-
}
|
|
13335
|
-
};
|
|
13336
|
-
exports.networkMetrics = new NetworkMetricsCollector();
|
|
13337
|
-
function debugError(component, message, metadata) {
|
|
13338
|
-
if (debugConfig.level >= LogLevel2.ERROR) {
|
|
13339
|
-
console.error(formatMessage("ERROR", component, message, metadata));
|
|
13340
|
-
}
|
|
13341
|
-
}
|
|
13342
|
-
function debugWarn(component, message, metadata) {
|
|
13343
|
-
if (debugConfig.level >= LogLevel2.WARN) {
|
|
13344
|
-
console.warn(formatMessage("WARN", component, message, metadata));
|
|
13345
|
-
}
|
|
13346
|
-
}
|
|
13347
|
-
function debugInfo(component, message, metadata) {
|
|
13348
|
-
if (debugConfig.level >= LogLevel2.INFO) {
|
|
13349
|
-
console.log(formatMessage("INFO", component, message, metadata));
|
|
13350
|
-
}
|
|
13351
|
-
}
|
|
13352
|
-
function debugLog(component, message, metadata) {
|
|
13353
|
-
if (debugConfig.level >= LogLevel2.DEBUG) {
|
|
13354
|
-
console.log(formatMessage("DEBUG", component, message, metadata));
|
|
13355
|
-
}
|
|
13356
|
-
}
|
|
13357
|
-
function debugTrace(component, message, metadata) {
|
|
13358
|
-
if (debugConfig.level >= LogLevel2.TRACE) {
|
|
13359
|
-
console.log(formatMessage("TRACE", component, message, metadata));
|
|
13360
|
-
}
|
|
13361
|
-
}
|
|
13362
|
-
function logRequest(component, operation, params) {
|
|
13363
|
-
if (!debugConfig.enableRequestLogging)
|
|
13364
|
-
return;
|
|
13365
|
-
debugLog(component, `\u{1F504} Request: ${operation}`, {
|
|
13366
|
-
operation,
|
|
13367
|
-
params: JSON.stringify(params, null, 2)
|
|
13368
|
-
});
|
|
13369
|
-
}
|
|
13370
|
-
function logResponse(component, operation, response, duration) {
|
|
13371
|
-
if (!debugConfig.enableRequestLogging)
|
|
13372
|
-
return;
|
|
13373
|
-
debugLog(component, `\u2705 Response: ${operation} (${duration}ms)`, {
|
|
13374
|
-
operation,
|
|
13375
|
-
duration,
|
|
13376
|
-
response: typeof response === "object" ? JSON.stringify(response, null, 2) : response
|
|
13377
|
-
});
|
|
13378
|
-
}
|
|
13379
|
-
function logError(component, operation, error, duration) {
|
|
13380
|
-
const durationStr = duration ? ` (${duration}ms)` : "";
|
|
13381
|
-
debugError(component, `\u274C Error: ${operation}${durationStr}`, {
|
|
13382
|
-
operation,
|
|
13383
|
-
duration,
|
|
13384
|
-
error: error?.message || error?.toString() || "Unknown error",
|
|
13385
|
-
stack: error?.stack
|
|
13386
|
-
});
|
|
13387
|
-
}
|
|
13388
|
-
function logConnectionAttempt(network, attempt, maxAttempts) {
|
|
13389
|
-
debugInfo("CONNECTION", `\u{1F517} Connecting to ${network} (attempt ${attempt}/${maxAttempts})`);
|
|
13390
|
-
}
|
|
13391
|
-
function logConnectionSuccess(network, latency) {
|
|
13392
|
-
debugInfo("CONNECTION", `\u2705 Connected to ${network} (${latency}ms)`);
|
|
13393
|
-
exports.networkMetrics.recordRequest(`connection-${network}`, true, latency);
|
|
13394
|
-
}
|
|
13395
|
-
function logConnectionFailure(network, error, attempt) {
|
|
13396
|
-
debugError("CONNECTION", `\u274C Connection failed to ${network} (attempt ${attempt})`, { error });
|
|
13397
|
-
exports.networkMetrics.recordRequest(`connection-${network}`, false, 0, error);
|
|
13398
|
-
}
|
|
13399
|
-
function logPkpOperation(operation, pkpId, details) {
|
|
13400
|
-
const pkpStr = pkpId ? ` (PKP: ${pkpId.slice(0, 8)}...)` : "";
|
|
13401
|
-
debugInfo("PKP", `\u{1F511} ${operation}${pkpStr}`, details);
|
|
13402
|
-
}
|
|
13403
|
-
function logSessionSignatures(count, expiration) {
|
|
13404
|
-
debugInfo("SESSION", `\u{1F510} Generated ${count} session signatures (expires: ${expiration})`);
|
|
13405
|
-
}
|
|
13406
|
-
function logLitActionExecution(cid, params) {
|
|
13407
|
-
debugInfo("LIT_ACTION", `\u26A1 Executing LIT Action: ${cid}`, {
|
|
13408
|
-
cid,
|
|
13409
|
-
params
|
|
13410
|
-
});
|
|
13411
|
-
}
|
|
13412
|
-
function logLitActionResult(cid, success2, duration, result) {
|
|
13413
|
-
const status = success2 ? "\u2705" : "\u274C";
|
|
13414
|
-
debugInfo("LIT_ACTION", `${status} LIT Action completed: ${cid} (${duration}ms)`, {
|
|
13415
|
-
cid,
|
|
13416
|
-
success: success2,
|
|
13417
|
-
duration,
|
|
13418
|
-
result: success2 && result ? JSON.stringify(result, null, 2) : void 0
|
|
13419
|
-
});
|
|
13420
|
-
}
|
|
13421
|
-
function logTestStart(testName) {
|
|
13422
|
-
debugInfo("TEST", `\u{1F9EA} Starting test: ${testName}`);
|
|
13423
|
-
return new PerformanceTracker(testName);
|
|
13424
|
-
}
|
|
13425
|
-
function logTestEnd(testName, success2, duration) {
|
|
13426
|
-
const status = success2 ? "\u2705" : "\u274C";
|
|
13427
|
-
debugInfo("TEST", `${status} Test completed: ${testName} (${duration}ms)`);
|
|
13428
|
-
exports.networkMetrics.printSummary();
|
|
13429
|
-
}
|
|
13430
|
-
}
|
|
13431
|
-
});
|
|
13432
|
-
|
|
13433
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/error-classification.js
|
|
13434
|
-
var require_error_classification = __commonJS({
|
|
13435
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/error-classification.js"(exports) {
|
|
13436
|
-
"use strict";
|
|
13437
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13438
|
-
exports.litProtocolErrors = exports.RetryStrategy = exports.ErrorCategory = void 0;
|
|
13439
|
-
exports.classifyError = classifyError;
|
|
13440
|
-
exports.getRetryConfigFromClassification = getRetryConfigFromClassification;
|
|
13441
|
-
exports.analyzeError = analyzeError;
|
|
13442
|
-
exports.createErrorReport = createErrorReport;
|
|
13443
|
-
var ErrorCategory2;
|
|
13444
|
-
(function(ErrorCategory3) {
|
|
13445
|
-
ErrorCategory3["NETWORK"] = "network";
|
|
13446
|
-
ErrorCategory3["PROTOCOL"] = "protocol";
|
|
13447
|
-
ErrorCategory3["AUTHENTICATION"] = "authentication";
|
|
13448
|
-
ErrorCategory3["RESOURCE"] = "resource";
|
|
13449
|
-
ErrorCategory3["VALIDATION"] = "validation";
|
|
13450
|
-
ErrorCategory3["TIMEOUT"] = "timeout";
|
|
13451
|
-
ErrorCategory3["RATE_LIMIT"] = "rate_limit";
|
|
13452
|
-
ErrorCategory3["CONFIGURATION"] = "configuration";
|
|
13453
|
-
ErrorCategory3["UNKNOWN"] = "unknown";
|
|
13454
|
-
})(ErrorCategory2 || (exports.ErrorCategory = ErrorCategory2 = {}));
|
|
13455
|
-
var RetryStrategy;
|
|
13456
|
-
(function(RetryStrategy2) {
|
|
13587
|
+
init_debug_logger();
|
|
13588
|
+
var ErrorCategory2 = /* @__PURE__ */ ((ErrorCategory22) => {
|
|
13589
|
+
ErrorCategory22["NETWORK"] = "network";
|
|
13590
|
+
ErrorCategory22["PROTOCOL"] = "protocol";
|
|
13591
|
+
ErrorCategory22["AUTHENTICATION"] = "authentication";
|
|
13592
|
+
ErrorCategory22["RESOURCE"] = "resource";
|
|
13593
|
+
ErrorCategory22["VALIDATION"] = "validation";
|
|
13594
|
+
ErrorCategory22["TIMEOUT"] = "timeout";
|
|
13595
|
+
ErrorCategory22["RATE_LIMIT"] = "rate_limit";
|
|
13596
|
+
ErrorCategory22["CONFIGURATION"] = "configuration";
|
|
13597
|
+
ErrorCategory22["UNKNOWN"] = "unknown";
|
|
13598
|
+
return ErrorCategory22;
|
|
13599
|
+
})(ErrorCategory2 || {});
|
|
13600
|
+
var RetryStrategy = /* @__PURE__ */ ((RetryStrategy2) => {
|
|
13457
13601
|
RetryStrategy2["AGGRESSIVE"] = "aggressive";
|
|
13458
13602
|
RetryStrategy2["CONSERVATIVE"] = "conservative";
|
|
13459
13603
|
RetryStrategy2["EXPONENTIAL"] = "exponential";
|
|
13460
13604
|
RetryStrategy2["LINEAR"] = "linear";
|
|
13461
13605
|
RetryStrategy2["NONE"] = "none";
|
|
13462
|
-
|
|
13606
|
+
return RetryStrategy2;
|
|
13607
|
+
})(RetryStrategy || {});
|
|
13463
13608
|
var LIT_ERROR_PATTERNS = {
|
|
13464
13609
|
// Network and connection errors
|
|
13465
13610
|
network: [
|
|
@@ -13552,31 +13697,46 @@ var require_error_classification = __commonJS({
|
|
|
13552
13697
|
]
|
|
13553
13698
|
};
|
|
13554
13699
|
var RETRY_STRATEGIES = {
|
|
13555
|
-
[
|
|
13700
|
+
[
|
|
13701
|
+
"aggressive"
|
|
13702
|
+
/* AGGRESSIVE */
|
|
13703
|
+
]: {
|
|
13556
13704
|
maxAttempts: 5,
|
|
13557
13705
|
baseDelayMs: 500,
|
|
13558
13706
|
maxDelayMs: 5e3,
|
|
13559
13707
|
multiplier: 1.5
|
|
13560
13708
|
},
|
|
13561
|
-
[
|
|
13709
|
+
[
|
|
13710
|
+
"conservative"
|
|
13711
|
+
/* CONSERVATIVE */
|
|
13712
|
+
]: {
|
|
13562
13713
|
maxAttempts: 3,
|
|
13563
13714
|
baseDelayMs: 3e3,
|
|
13564
13715
|
maxDelayMs: 3e4,
|
|
13565
13716
|
multiplier: 2.5
|
|
13566
13717
|
},
|
|
13567
|
-
[
|
|
13718
|
+
[
|
|
13719
|
+
"exponential"
|
|
13720
|
+
/* EXPONENTIAL */
|
|
13721
|
+
]: {
|
|
13568
13722
|
maxAttempts: 4,
|
|
13569
13723
|
baseDelayMs: 1e3,
|
|
13570
13724
|
maxDelayMs: 15e3,
|
|
13571
13725
|
multiplier: 2
|
|
13572
13726
|
},
|
|
13573
|
-
[
|
|
13727
|
+
[
|
|
13728
|
+
"linear"
|
|
13729
|
+
/* LINEAR */
|
|
13730
|
+
]: {
|
|
13574
13731
|
maxAttempts: 3,
|
|
13575
13732
|
baseDelayMs: 2e3,
|
|
13576
13733
|
maxDelayMs: 1e4,
|
|
13577
13734
|
multiplier: 1
|
|
13578
13735
|
},
|
|
13579
|
-
[
|
|
13736
|
+
[
|
|
13737
|
+
"none"
|
|
13738
|
+
/* NONE */
|
|
13739
|
+
]: {
|
|
13580
13740
|
maxAttempts: 1,
|
|
13581
13741
|
baseDelayMs: 0,
|
|
13582
13742
|
maxDelayMs: 0,
|
|
@@ -13584,11 +13744,17 @@ var require_error_classification = __commonJS({
|
|
|
13584
13744
|
}
|
|
13585
13745
|
};
|
|
13586
13746
|
var CLASSIFICATION_RULES = {
|
|
13587
|
-
[
|
|
13588
|
-
|
|
13589
|
-
|
|
13747
|
+
[
|
|
13748
|
+
"network"
|
|
13749
|
+
/* NETWORK */
|
|
13750
|
+
]: {
|
|
13751
|
+
category: "network",
|
|
13752
|
+
retryStrategy: "aggressive",
|
|
13590
13753
|
isRetryable: true,
|
|
13591
|
-
...RETRY_STRATEGIES[
|
|
13754
|
+
...RETRY_STRATEGIES[
|
|
13755
|
+
"aggressive"
|
|
13756
|
+
/* AGGRESSIVE */
|
|
13757
|
+
],
|
|
13592
13758
|
description: "Network connectivity or communication error",
|
|
13593
13759
|
troubleshooting: [
|
|
13594
13760
|
"Check internet connection",
|
|
@@ -13597,11 +13763,17 @@ var require_error_classification = __commonJS({
|
|
|
13597
13763
|
"Try connecting to different node endpoints"
|
|
13598
13764
|
]
|
|
13599
13765
|
},
|
|
13600
|
-
[
|
|
13601
|
-
|
|
13602
|
-
|
|
13766
|
+
[
|
|
13767
|
+
"protocol"
|
|
13768
|
+
/* PROTOCOL */
|
|
13769
|
+
]: {
|
|
13770
|
+
category: "protocol",
|
|
13771
|
+
retryStrategy: "conservative",
|
|
13603
13772
|
isRetryable: true,
|
|
13604
|
-
...RETRY_STRATEGIES[
|
|
13773
|
+
...RETRY_STRATEGIES[
|
|
13774
|
+
"conservative"
|
|
13775
|
+
/* CONSERVATIVE */
|
|
13776
|
+
],
|
|
13605
13777
|
description: "LIT Protocol specific operational error",
|
|
13606
13778
|
troubleshooting: [
|
|
13607
13779
|
"Check LIT Protocol network status",
|
|
@@ -13610,11 +13782,17 @@ var require_error_classification = __commonJS({
|
|
|
13610
13782
|
"Wait for network consensus"
|
|
13611
13783
|
]
|
|
13612
13784
|
},
|
|
13613
|
-
[
|
|
13614
|
-
|
|
13615
|
-
|
|
13785
|
+
[
|
|
13786
|
+
"authentication"
|
|
13787
|
+
/* AUTHENTICATION */
|
|
13788
|
+
]: {
|
|
13789
|
+
category: "authentication",
|
|
13790
|
+
retryStrategy: "exponential",
|
|
13616
13791
|
isRetryable: true,
|
|
13617
|
-
...RETRY_STRATEGIES[
|
|
13792
|
+
...RETRY_STRATEGIES[
|
|
13793
|
+
"exponential"
|
|
13794
|
+
/* EXPONENTIAL */
|
|
13795
|
+
],
|
|
13618
13796
|
maxAttempts: 2,
|
|
13619
13797
|
// Override: limited retries for auth issues
|
|
13620
13798
|
description: "Authentication or authorization error",
|
|
@@ -13625,11 +13803,17 @@ var require_error_classification = __commonJS({
|
|
|
13625
13803
|
"Check PKP authorization status"
|
|
13626
13804
|
]
|
|
13627
13805
|
},
|
|
13628
|
-
[
|
|
13629
|
-
|
|
13630
|
-
|
|
13806
|
+
[
|
|
13807
|
+
"resource"
|
|
13808
|
+
/* RESOURCE */
|
|
13809
|
+
]: {
|
|
13810
|
+
category: "resource",
|
|
13811
|
+
retryStrategy: "linear",
|
|
13631
13812
|
isRetryable: true,
|
|
13632
|
-
...RETRY_STRATEGIES[
|
|
13813
|
+
...RETRY_STRATEGIES[
|
|
13814
|
+
"linear"
|
|
13815
|
+
/* LINEAR */
|
|
13816
|
+
],
|
|
13633
13817
|
maxAttempts: 2,
|
|
13634
13818
|
// Override: limited retries for resource issues
|
|
13635
13819
|
description: "Resource not found or validation error",
|
|
@@ -13640,11 +13824,17 @@ var require_error_classification = __commonJS({
|
|
|
13640
13824
|
"Wait for resource propagation"
|
|
13641
13825
|
]
|
|
13642
13826
|
},
|
|
13643
|
-
[
|
|
13644
|
-
|
|
13645
|
-
|
|
13827
|
+
[
|
|
13828
|
+
"validation"
|
|
13829
|
+
/* VALIDATION */
|
|
13830
|
+
]: {
|
|
13831
|
+
category: "validation",
|
|
13832
|
+
retryStrategy: "none",
|
|
13646
13833
|
isRetryable: false,
|
|
13647
|
-
...RETRY_STRATEGIES[
|
|
13834
|
+
...RETRY_STRATEGIES[
|
|
13835
|
+
"none"
|
|
13836
|
+
/* NONE */
|
|
13837
|
+
],
|
|
13648
13838
|
description: "Input validation or schema error",
|
|
13649
13839
|
troubleshooting: [
|
|
13650
13840
|
"Check input parameters format",
|
|
@@ -13653,11 +13843,17 @@ var require_error_classification = __commonJS({
|
|
|
13653
13843
|
"Review API documentation"
|
|
13654
13844
|
]
|
|
13655
13845
|
},
|
|
13656
|
-
[
|
|
13657
|
-
|
|
13658
|
-
|
|
13846
|
+
[
|
|
13847
|
+
"timeout"
|
|
13848
|
+
/* TIMEOUT */
|
|
13849
|
+
]: {
|
|
13850
|
+
category: "timeout",
|
|
13851
|
+
retryStrategy: "conservative",
|
|
13659
13852
|
isRetryable: true,
|
|
13660
|
-
...RETRY_STRATEGIES[
|
|
13853
|
+
...RETRY_STRATEGIES[
|
|
13854
|
+
"conservative"
|
|
13855
|
+
/* CONSERVATIVE */
|
|
13856
|
+
],
|
|
13661
13857
|
description: "Operation timeout error",
|
|
13662
13858
|
troubleshooting: [
|
|
13663
13859
|
"Increase timeout values",
|
|
@@ -13666,11 +13862,17 @@ var require_error_classification = __commonJS({
|
|
|
13666
13862
|
"Split operations into smaller chunks"
|
|
13667
13863
|
]
|
|
13668
13864
|
},
|
|
13669
|
-
[
|
|
13670
|
-
|
|
13671
|
-
|
|
13865
|
+
[
|
|
13866
|
+
"rate_limit"
|
|
13867
|
+
/* RATE_LIMIT */
|
|
13868
|
+
]: {
|
|
13869
|
+
category: "rate_limit",
|
|
13870
|
+
retryStrategy: "conservative",
|
|
13672
13871
|
isRetryable: true,
|
|
13673
|
-
...RETRY_STRATEGIES[
|
|
13872
|
+
...RETRY_STRATEGIES[
|
|
13873
|
+
"conservative"
|
|
13874
|
+
/* CONSERVATIVE */
|
|
13875
|
+
],
|
|
13674
13876
|
maxAttempts: 2,
|
|
13675
13877
|
// Override: limited retries to avoid further rate limiting
|
|
13676
13878
|
baseDelayMs: 5e3,
|
|
@@ -13683,11 +13885,17 @@ var require_error_classification = __commonJS({
|
|
|
13683
13885
|
"Wait for quota reset"
|
|
13684
13886
|
]
|
|
13685
13887
|
},
|
|
13686
|
-
[
|
|
13687
|
-
|
|
13688
|
-
|
|
13888
|
+
[
|
|
13889
|
+
"configuration"
|
|
13890
|
+
/* CONFIGURATION */
|
|
13891
|
+
]: {
|
|
13892
|
+
category: "configuration",
|
|
13893
|
+
retryStrategy: "none",
|
|
13689
13894
|
isRetryable: false,
|
|
13690
|
-
...RETRY_STRATEGIES[
|
|
13895
|
+
...RETRY_STRATEGIES[
|
|
13896
|
+
"none"
|
|
13897
|
+
/* NONE */
|
|
13898
|
+
],
|
|
13691
13899
|
description: "Configuration or setup error",
|
|
13692
13900
|
troubleshooting: [
|
|
13693
13901
|
"Check environment variables",
|
|
@@ -13696,11 +13904,17 @@ var require_error_classification = __commonJS({
|
|
|
13696
13904
|
"Check required dependencies"
|
|
13697
13905
|
]
|
|
13698
13906
|
},
|
|
13699
|
-
[
|
|
13700
|
-
|
|
13701
|
-
|
|
13907
|
+
[
|
|
13908
|
+
"unknown"
|
|
13909
|
+
/* UNKNOWN */
|
|
13910
|
+
]: {
|
|
13911
|
+
category: "unknown",
|
|
13912
|
+
retryStrategy: "exponential",
|
|
13702
13913
|
isRetryable: true,
|
|
13703
|
-
...RETRY_STRATEGIES[
|
|
13914
|
+
...RETRY_STRATEGIES[
|
|
13915
|
+
"exponential"
|
|
13916
|
+
/* EXPONENTIAL */
|
|
13917
|
+
],
|
|
13704
13918
|
maxAttempts: 2,
|
|
13705
13919
|
// Override: conservative retries for unknown errors
|
|
13706
13920
|
description: "Unknown or unclassified error",
|
|
@@ -13726,7 +13940,10 @@ var require_error_classification = __commonJS({
|
|
|
13726
13940
|
}
|
|
13727
13941
|
}
|
|
13728
13942
|
}
|
|
13729
|
-
const unknownClassification = CLASSIFICATION_RULES[
|
|
13943
|
+
const unknownClassification = CLASSIFICATION_RULES[
|
|
13944
|
+
"unknown"
|
|
13945
|
+
/* UNKNOWN */
|
|
13946
|
+
];
|
|
13730
13947
|
return {
|
|
13731
13948
|
...unknownClassification,
|
|
13732
13949
|
description: `${unknownClassification.description}: ${errorMessage.slice(0, 100)}`
|
|
@@ -13777,258 +13994,17 @@ var require_error_classification = __commonJS({
|
|
|
13777
13994
|
}
|
|
13778
13995
|
return report.join("\n");
|
|
13779
13996
|
}
|
|
13780
|
-
|
|
13781
|
-
isNetworkError: (error) => classifyError(error).category ===
|
|
13782
|
-
isProtocolError: (error) => classifyError(error).category ===
|
|
13783
|
-
isAuthenticationError: (error) => classifyError(error).category ===
|
|
13784
|
-
isResourceError: (error) => classifyError(error).category ===
|
|
13785
|
-
isTimeoutError: (error) => classifyError(error).category ===
|
|
13786
|
-
isRateLimitError: (error) => classifyError(error).category ===
|
|
13787
|
-
isConfigurationError: (error) => classifyError(error).category ===
|
|
13997
|
+
var litProtocolErrors = {
|
|
13998
|
+
isNetworkError: (error) => classifyError(error).category === "network",
|
|
13999
|
+
isProtocolError: (error) => classifyError(error).category === "protocol",
|
|
14000
|
+
isAuthenticationError: (error) => classifyError(error).category === "authentication",
|
|
14001
|
+
isResourceError: (error) => classifyError(error).category === "resource",
|
|
14002
|
+
isTimeoutError: (error) => classifyError(error).category === "timeout",
|
|
14003
|
+
isRateLimitError: (error) => classifyError(error).category === "rate_limit",
|
|
14004
|
+
isConfigurationError: (error) => classifyError(error).category === "configuration",
|
|
13788
14005
|
isRetryable: (error) => classifyError(error).isRetryable
|
|
13789
14006
|
};
|
|
13790
|
-
|
|
13791
|
-
});
|
|
13792
|
-
|
|
13793
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/session-signature-cache.js
|
|
13794
|
-
var require_session_signature_cache = __commonJS({
|
|
13795
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/session-signature-cache.js"(exports) {
|
|
13796
|
-
"use strict";
|
|
13797
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13798
|
-
exports.sessionSignatureCache = exports.DEFAULT_CACHE_CONFIG = void 0;
|
|
13799
|
-
exports.generateSessionSignaturesWithCache = generateSessionSignaturesWithCache;
|
|
13800
|
-
exports.configureSessionSignatureCache = configureSessionSignatureCache;
|
|
13801
|
-
exports.clearSessionSignatureCache = clearSessionSignatureCache;
|
|
13802
|
-
exports.getSessionSignatureCacheStats = getSessionSignatureCacheStats;
|
|
13803
|
-
var debug_logger_1 = require_debug_logger();
|
|
13804
|
-
exports.DEFAULT_CACHE_CONFIG = {
|
|
13805
|
-
maxEntries: 50,
|
|
13806
|
-
bufferTimeMs: 6e4,
|
|
13807
|
-
// 1 minute buffer before expiration
|
|
13808
|
-
enableLogging: true
|
|
13809
|
-
};
|
|
13810
|
-
var SessionSignatureCache = class {
|
|
13811
|
-
constructor(config = {}) {
|
|
13812
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
13813
|
-
this.config = { ...exports.DEFAULT_CACHE_CONFIG, ...config };
|
|
13814
|
-
}
|
|
13815
|
-
/**
|
|
13816
|
-
* Generate cache key from PKP and context
|
|
13817
|
-
*/
|
|
13818
|
-
generateCacheKey(pkpTokenId, litActionCid, signerAddress, network) {
|
|
13819
|
-
return `${signerAddress}-${network}-${pkpTokenId}-${litActionCid}`;
|
|
13820
|
-
}
|
|
13821
|
-
/**
|
|
13822
|
-
* Check if cache entry is still valid
|
|
13823
|
-
*/
|
|
13824
|
-
isEntryValid(entry) {
|
|
13825
|
-
const now2 = /* @__PURE__ */ new Date();
|
|
13826
|
-
const expirationWithBuffer = new Date(entry.expiration.getTime() - this.config.bufferTimeMs);
|
|
13827
|
-
return now2 < expirationWithBuffer;
|
|
13828
|
-
}
|
|
13829
|
-
/**
|
|
13830
|
-
* Clean expired entries from cache
|
|
13831
|
-
*/
|
|
13832
|
-
cleanExpiredEntries() {
|
|
13833
|
-
const now2 = /* @__PURE__ */ new Date();
|
|
13834
|
-
let cleanedCount = 0;
|
|
13835
|
-
for (const [key2, entry] of this.cache.entries()) {
|
|
13836
|
-
if (now2 >= entry.expiration) {
|
|
13837
|
-
this.cache.delete(key2);
|
|
13838
|
-
cleanedCount++;
|
|
13839
|
-
}
|
|
13840
|
-
}
|
|
13841
|
-
if (cleanedCount > 0 && this.config.enableLogging) {
|
|
13842
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u{1F9F9} Cleaned ${cleanedCount} expired session signature entries`);
|
|
13843
|
-
}
|
|
13844
|
-
}
|
|
13845
|
-
/**
|
|
13846
|
-
* Enforce cache size limits
|
|
13847
|
-
*/
|
|
13848
|
-
enforceCacheSize() {
|
|
13849
|
-
if (this.cache.size <= this.config.maxEntries) {
|
|
13850
|
-
return;
|
|
13851
|
-
}
|
|
13852
|
-
const entries = Array.from(this.cache.entries()).sort(([, a], [, b]) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
13853
|
-
const toRemove = entries.slice(0, this.cache.size - this.config.maxEntries);
|
|
13854
|
-
for (const [key2] of toRemove) {
|
|
13855
|
-
this.cache.delete(key2);
|
|
13856
|
-
}
|
|
13857
|
-
if (this.config.enableLogging) {
|
|
13858
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u{1F4E6} Removed ${toRemove.length} oldest cache entries to maintain size limit`);
|
|
13859
|
-
}
|
|
13860
|
-
}
|
|
13861
|
-
/**
|
|
13862
|
-
* Get cached session signatures if valid
|
|
13863
|
-
*/
|
|
13864
|
-
get(pkpTokenId, litActionCid, signerAddress, network) {
|
|
13865
|
-
this.cleanExpiredEntries();
|
|
13866
|
-
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13867
|
-
const entry = this.cache.get(cacheKey);
|
|
13868
|
-
if (!entry) {
|
|
13869
|
-
if (this.config.enableLogging) {
|
|
13870
|
-
(0, debug_logger_1.debugLog)("CACHE", `\u274C Session signatures cache miss: ${cacheKey}`);
|
|
13871
|
-
}
|
|
13872
|
-
return null;
|
|
13873
|
-
}
|
|
13874
|
-
if (!this.isEntryValid(entry)) {
|
|
13875
|
-
this.cache.delete(cacheKey);
|
|
13876
|
-
if (this.config.enableLogging) {
|
|
13877
|
-
(0, debug_logger_1.debugWarn)("CACHE", `\u23F0 Session signatures expired: ${cacheKey}`);
|
|
13878
|
-
}
|
|
13879
|
-
return null;
|
|
13880
|
-
}
|
|
13881
|
-
if (this.config.enableLogging) {
|
|
13882
|
-
const timeUntilExpiry = entry.expiration.getTime() - Date.now();
|
|
13883
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u2705 Session signatures cache hit: ${cacheKey} (expires in ${Math.round(timeUntilExpiry / 1e3)}s)`);
|
|
13884
|
-
}
|
|
13885
|
-
return entry.sessionSigs;
|
|
13886
|
-
}
|
|
13887
|
-
/**
|
|
13888
|
-
* Cache session signatures
|
|
13889
|
-
*/
|
|
13890
|
-
set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration) {
|
|
13891
|
-
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13892
|
-
const entry = {
|
|
13893
|
-
sessionSigs,
|
|
13894
|
-
expiration,
|
|
13895
|
-
pkpTokenId,
|
|
13896
|
-
litActionCid,
|
|
13897
|
-
signerAddress,
|
|
13898
|
-
network,
|
|
13899
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
13900
|
-
};
|
|
13901
|
-
this.cache.set(cacheKey, entry);
|
|
13902
|
-
if (this.config.enableLogging) {
|
|
13903
|
-
const timeUntilExpiry = expiration.getTime() - Date.now();
|
|
13904
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u{1F4BE} Cached session signatures: ${cacheKey} (expires in ${Math.round(timeUntilExpiry / 1e3)}s)`);
|
|
13905
|
-
}
|
|
13906
|
-
this.enforceCacheSize();
|
|
13907
|
-
}
|
|
13908
|
-
/**
|
|
13909
|
-
* Clear all cached session signatures
|
|
13910
|
-
*/
|
|
13911
|
-
clear() {
|
|
13912
|
-
const size = this.cache.size;
|
|
13913
|
-
this.cache.clear();
|
|
13914
|
-
if (this.config.enableLogging) {
|
|
13915
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u{1F5D1}\uFE0F Cleared ${size} cached session signature entries`);
|
|
13916
|
-
}
|
|
13917
|
-
}
|
|
13918
|
-
/**
|
|
13919
|
-
* Get cache statistics
|
|
13920
|
-
*/
|
|
13921
|
-
getStats() {
|
|
13922
|
-
this.cleanExpiredEntries();
|
|
13923
|
-
return {
|
|
13924
|
-
size: this.cache.size,
|
|
13925
|
-
maxEntries: this.config.maxEntries,
|
|
13926
|
-
utilizationPercent: Math.round(this.cache.size / this.config.maxEntries * 100)
|
|
13927
|
-
};
|
|
13928
|
-
}
|
|
13929
|
-
/**
|
|
13930
|
-
* Remove specific cache entry
|
|
13931
|
-
*/
|
|
13932
|
-
delete(pkpTokenId, litActionCid, signerAddress, network) {
|
|
13933
|
-
const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
|
|
13934
|
-
const deleted = this.cache.delete(cacheKey);
|
|
13935
|
-
if (deleted && this.config.enableLogging) {
|
|
13936
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u{1F5D1}\uFE0F Removed session signatures from cache: ${cacheKey}`);
|
|
13937
|
-
}
|
|
13938
|
-
return deleted;
|
|
13939
|
-
}
|
|
13940
|
-
};
|
|
13941
|
-
exports.sessionSignatureCache = new SessionSignatureCache();
|
|
13942
|
-
async function generateSessionSignaturesWithCache(litNodeClient, sessionConfig, pkpTokenId, litActionCid, signerAddress, network = "chipotle") {
|
|
13943
|
-
const cached = exports.sessionSignatureCache.get(pkpTokenId, litActionCid, signerAddress, network);
|
|
13944
|
-
if (cached) {
|
|
13945
|
-
return cached;
|
|
13946
|
-
}
|
|
13947
|
-
(0, debug_logger_1.debugInfo)("CACHE", "\u{1F510} Generating new session signatures (cache miss)...");
|
|
13948
|
-
const sessionSigs = await litNodeClient.getSessionSigs(sessionConfig);
|
|
13949
|
-
const expiration = new Date(sessionConfig.expiration);
|
|
13950
|
-
exports.sessionSignatureCache.set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration);
|
|
13951
|
-
const sigCount = Object.keys(sessionSigs).length;
|
|
13952
|
-
(0, debug_logger_1.debugInfo)("CACHE", `\u2705 Generated and cached ${sigCount} session signatures`);
|
|
13953
|
-
return sessionSigs;
|
|
13954
|
-
}
|
|
13955
|
-
function configureSessionSignatureCache(config) {
|
|
13956
|
-
Object.assign(exports.sessionSignatureCache["config"], config);
|
|
13957
|
-
}
|
|
13958
|
-
function clearSessionSignatureCache() {
|
|
13959
|
-
exports.sessionSignatureCache.clear();
|
|
13960
|
-
}
|
|
13961
|
-
function getSessionSignatureCacheStats() {
|
|
13962
|
-
return exports.sessionSignatureCache.getStats();
|
|
13963
|
-
}
|
|
13964
|
-
}
|
|
13965
|
-
});
|
|
13966
|
-
|
|
13967
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/connection-helpers.js
|
|
13968
|
-
var require_connection_helpers = __commonJS({
|
|
13969
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/connection-helpers.js"(exports) {
|
|
13970
|
-
"use strict";
|
|
13971
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
13972
|
-
if (k2 === void 0)
|
|
13973
|
-
k2 = k;
|
|
13974
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13975
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13976
|
-
desc = { enumerable: true, get: function() {
|
|
13977
|
-
return m[k];
|
|
13978
|
-
} };
|
|
13979
|
-
}
|
|
13980
|
-
Object.defineProperty(o, k2, desc);
|
|
13981
|
-
} : function(o, m, k, k2) {
|
|
13982
|
-
if (k2 === void 0)
|
|
13983
|
-
k2 = k;
|
|
13984
|
-
o[k2] = m[k];
|
|
13985
|
-
});
|
|
13986
|
-
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
13987
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
13988
|
-
} : function(o, v) {
|
|
13989
|
-
o["default"] = v;
|
|
13990
|
-
});
|
|
13991
|
-
var __importStar = exports && exports.__importStar || function() {
|
|
13992
|
-
var ownKeys = function(o) {
|
|
13993
|
-
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
13994
|
-
var ar = [];
|
|
13995
|
-
for (var k in o2)
|
|
13996
|
-
if (Object.prototype.hasOwnProperty.call(o2, k))
|
|
13997
|
-
ar[ar.length] = k;
|
|
13998
|
-
return ar;
|
|
13999
|
-
};
|
|
14000
|
-
return ownKeys(o);
|
|
14001
|
-
};
|
|
14002
|
-
return function(mod) {
|
|
14003
|
-
if (mod && mod.__esModule)
|
|
14004
|
-
return mod;
|
|
14005
|
-
var result = {};
|
|
14006
|
-
if (mod != null) {
|
|
14007
|
-
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
14008
|
-
if (k[i] !== "default")
|
|
14009
|
-
__createBinding(result, mod, k[i]);
|
|
14010
|
-
}
|
|
14011
|
-
__setModuleDefault(result, mod);
|
|
14012
|
-
return result;
|
|
14013
|
-
};
|
|
14014
|
-
}();
|
|
14015
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14016
|
-
exports.NETWORK_TIMEOUTS = exports.DEFAULT_RETRY_CONFIG = void 0;
|
|
14017
|
-
exports.sleep = sleep;
|
|
14018
|
-
exports.isRetryableError = isRetryableError;
|
|
14019
|
-
exports.calculateDelay = calculateDelay;
|
|
14020
|
-
exports.withRetry = withRetry;
|
|
14021
|
-
exports.connectLitNodeClient = connectLitNodeClient;
|
|
14022
|
-
exports.connectLitContracts = connectLitContracts;
|
|
14023
|
-
exports.validateLitNodeConnection = validateLitNodeConnection;
|
|
14024
|
-
exports.generateSessionSignatures = generateSessionSignatures;
|
|
14025
|
-
exports.validateLitNodeReadiness = validateLitNodeReadiness;
|
|
14026
|
-
exports.executeLitAction = executeLitAction;
|
|
14027
|
-
exports.executePkpOperation = executePkpOperation;
|
|
14028
|
-
exports.getNetworkTimeouts = getNetworkTimeouts;
|
|
14029
|
-
var debug_logger_1 = require_debug_logger();
|
|
14030
|
-
var error_classification_1 = require_error_classification();
|
|
14031
|
-
exports.DEFAULT_RETRY_CONFIG = {
|
|
14007
|
+
var DEFAULT_RETRY_CONFIG = {
|
|
14032
14008
|
maxAttempts: 5,
|
|
14033
14009
|
// Increased from 3 for PKP operations
|
|
14034
14010
|
initialDelayMs: 2e3,
|
|
@@ -14062,80 +14038,85 @@ var require_connection_helpers = __commonJS({
|
|
|
14062
14038
|
function sleep(ms) {
|
|
14063
14039
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
14064
14040
|
}
|
|
14065
|
-
function isRetryableError(error, retryableErrors =
|
|
14041
|
+
function isRetryableError(error, retryableErrors = DEFAULT_RETRY_CONFIG.retryableErrors) {
|
|
14066
14042
|
if (!error)
|
|
14067
14043
|
return false;
|
|
14068
|
-
const classification =
|
|
14044
|
+
const classification = classifyError(error);
|
|
14069
14045
|
if (classification.isRetryable !== void 0) {
|
|
14070
|
-
|
|
14046
|
+
debugInfo("ERROR_CLASSIFICATION", `Error classified as: ${classification.category} (retryable: ${classification.isRetryable})`);
|
|
14071
14047
|
return classification.isRetryable;
|
|
14072
14048
|
}
|
|
14073
14049
|
const errorMessage = error.message || error.toString() || "";
|
|
14074
14050
|
const errorLower = errorMessage.toLowerCase();
|
|
14075
|
-
return retryableErrors.some(
|
|
14051
|
+
return retryableErrors.some(
|
|
14052
|
+
(pattern) => errorLower.includes(pattern.toLowerCase())
|
|
14053
|
+
);
|
|
14076
14054
|
}
|
|
14077
14055
|
function calculateDelay(attempt, config) {
|
|
14078
|
-
const exponentialDelay = Math.min(
|
|
14056
|
+
const exponentialDelay = Math.min(
|
|
14057
|
+
config.initialDelayMs * Math.pow(config.backoffMultiplier, attempt - 1),
|
|
14058
|
+
config.maxDelayMs
|
|
14059
|
+
);
|
|
14079
14060
|
const jitter = exponentialDelay * 0.25 * (Math.random() - 0.5);
|
|
14080
14061
|
return Math.max(100, exponentialDelay + jitter);
|
|
14081
14062
|
}
|
|
14082
14063
|
async function withRetry(operation, config = {}, operationName = "operation") {
|
|
14083
|
-
let finalConfig = { ...
|
|
14084
|
-
const tracker = new
|
|
14064
|
+
let finalConfig = { ...DEFAULT_RETRY_CONFIG, ...config };
|
|
14065
|
+
const tracker = new PerformanceTracker(`Retry ${operationName}`);
|
|
14085
14066
|
let lastError;
|
|
14086
14067
|
let errorClassification = null;
|
|
14087
14068
|
for (let attempt = 1; attempt <= finalConfig.maxAttempts; attempt++) {
|
|
14088
14069
|
try {
|
|
14089
|
-
|
|
14070
|
+
debugInfo("RETRY", `\u{1F504} [${operationName}] Attempt ${attempt}/${finalConfig.maxAttempts}`);
|
|
14090
14071
|
const startTime = Date.now();
|
|
14091
14072
|
const result = await operation();
|
|
14092
14073
|
const duration = Date.now() - startTime;
|
|
14093
|
-
|
|
14094
|
-
|
|
14074
|
+
debugInfo("RETRY", `\u2705 [${operationName}] Success after ${duration}ms (attempt ${attempt})`);
|
|
14075
|
+
networkMetrics.recordRequest(operationName, true, duration);
|
|
14095
14076
|
tracker.end(true);
|
|
14096
14077
|
return result;
|
|
14097
14078
|
} catch (error) {
|
|
14098
14079
|
lastError = error;
|
|
14099
14080
|
const errorMessage = error?.message || error?.toString() || "Unknown error";
|
|
14100
|
-
errorClassification =
|
|
14081
|
+
errorClassification = classifyError(error);
|
|
14101
14082
|
if (attempt === 1 && errorClassification) {
|
|
14102
|
-
const intelligentConfig =
|
|
14083
|
+
const intelligentConfig = getRetryConfigFromClassification(errorClassification);
|
|
14103
14084
|
finalConfig = {
|
|
14104
14085
|
...finalConfig,
|
|
14105
14086
|
...intelligentConfig,
|
|
14106
14087
|
maxAttempts: Math.min(finalConfig.maxAttempts, intelligentConfig.maxAttempts)
|
|
14107
14088
|
};
|
|
14108
|
-
|
|
14109
|
-
|
|
14089
|
+
debugInfo("RETRY", `\u{1F9E0} Intelligent retry strategy applied: ${errorClassification.category} (${errorClassification.retryStrategy})`);
|
|
14090
|
+
debugInfo("RETRY", `\u{1F4CA} Adjusted config: max=${finalConfig.maxAttempts}, delay=${finalConfig.initialDelayMs}ms`);
|
|
14110
14091
|
}
|
|
14111
|
-
|
|
14092
|
+
debugWarn("RETRY", `\u26A0\uFE0F [${operationName}] Attempt ${attempt} failed:`, {
|
|
14112
14093
|
error: errorMessage,
|
|
14113
14094
|
attempt,
|
|
14114
14095
|
category: errorClassification.category,
|
|
14115
14096
|
retryable: errorClassification.isRetryable
|
|
14116
14097
|
});
|
|
14117
|
-
|
|
14098
|
+
networkMetrics.recordRequest(operationName, false, 0, errorMessage);
|
|
14118
14099
|
if (attempt >= finalConfig.maxAttempts) {
|
|
14119
|
-
|
|
14100
|
+
debugError("RETRY", `\u274C [${operationName}] All attempts failed. Last error:`, { error: errorMessage });
|
|
14120
14101
|
if (errorClassification) {
|
|
14121
|
-
const errorReport =
|
|
14122
|
-
|
|
14102
|
+
const errorReport = createErrorReport(error);
|
|
14103
|
+
debugError("RETRY", `\u{1F4CB} Error Analysis Report:
|
|
14123
14104
|
${errorReport}`);
|
|
14124
14105
|
}
|
|
14125
14106
|
tracker.end(false);
|
|
14126
14107
|
break;
|
|
14127
14108
|
}
|
|
14128
14109
|
if (!errorClassification.isRetryable) {
|
|
14129
|
-
|
|
14110
|
+
debugError("RETRY", `\u{1F6AB} [${operationName}] Non-retryable error (${errorClassification.category}):`, { error: errorMessage });
|
|
14130
14111
|
if (errorClassification.troubleshooting) {
|
|
14131
|
-
|
|
14112
|
+
debugInfo("RETRY", `\u{1F4A1} Troubleshooting suggestions:
|
|
14132
14113
|
${errorClassification.troubleshooting.join("\n ")}`);
|
|
14133
14114
|
}
|
|
14134
14115
|
tracker.end(false);
|
|
14135
14116
|
break;
|
|
14136
14117
|
}
|
|
14137
14118
|
const delayMs = calculateDelay(attempt, finalConfig);
|
|
14138
|
-
|
|
14119
|
+
debugInfo("RETRY", `\u23F3 [${operationName}] Waiting ${delayMs}ms before retry... (${errorClassification.retryStrategy} strategy)`);
|
|
14139
14120
|
await sleep(delayMs);
|
|
14140
14121
|
}
|
|
14141
14122
|
}
|
|
@@ -14143,36 +14124,44 @@ ${errorReport}`);
|
|
|
14143
14124
|
}
|
|
14144
14125
|
async function connectLitNodeClient(litNodeClient, config = {}) {
|
|
14145
14126
|
const network = litNodeClient?.config?.litNetwork || "unknown";
|
|
14146
|
-
return withRetry(
|
|
14147
|
-
|
|
14148
|
-
|
|
14149
|
-
|
|
14150
|
-
|
|
14151
|
-
|
|
14152
|
-
|
|
14153
|
-
|
|
14154
|
-
|
|
14155
|
-
|
|
14156
|
-
|
|
14157
|
-
|
|
14158
|
-
|
|
14159
|
-
|
|
14160
|
-
|
|
14161
|
-
|
|
14162
|
-
|
|
14163
|
-
|
|
14164
|
-
|
|
14165
|
-
|
|
14127
|
+
return withRetry(
|
|
14128
|
+
async () => {
|
|
14129
|
+
if (!litNodeClient) {
|
|
14130
|
+
throw new Error("LIT Node Client is null or undefined");
|
|
14131
|
+
}
|
|
14132
|
+
const startTime = Date.now();
|
|
14133
|
+
logConnectionAttempt(network, 1, config.maxAttempts || DEFAULT_RETRY_CONFIG.maxAttempts);
|
|
14134
|
+
await litNodeClient.connect();
|
|
14135
|
+
debugInfo("CONNECTION", `\u23F3 Waiting for LIT Node Client to be ready...`);
|
|
14136
|
+
const readyTimeout = 3e4;
|
|
14137
|
+
const readyStartTime = Date.now();
|
|
14138
|
+
while (!litNodeClient.ready && Date.now() - readyStartTime < readyTimeout) {
|
|
14139
|
+
await sleep(500);
|
|
14140
|
+
}
|
|
14141
|
+
if (!litNodeClient.ready) {
|
|
14142
|
+
throw new Error(`LIT Node Client failed to become ready within ${readyTimeout}ms`);
|
|
14143
|
+
}
|
|
14144
|
+
const latency = Date.now() - startTime;
|
|
14145
|
+
debugInfo("CONNECTION", `\u2705 LIT Node Client is ready (${litNodeClient.ready})`);
|
|
14146
|
+
logConnectionSuccess(network, latency);
|
|
14147
|
+
},
|
|
14148
|
+
config,
|
|
14149
|
+
"LIT Node Client Connection"
|
|
14150
|
+
);
|
|
14166
14151
|
}
|
|
14167
14152
|
async function connectLitContracts(litContracts, config = {}) {
|
|
14168
|
-
return withRetry(
|
|
14169
|
-
|
|
14170
|
-
|
|
14171
|
-
|
|
14172
|
-
|
|
14173
|
-
|
|
14174
|
-
|
|
14175
|
-
|
|
14153
|
+
return withRetry(
|
|
14154
|
+
async () => {
|
|
14155
|
+
if (!litContracts) {
|
|
14156
|
+
throw new Error("LIT Contracts is null or undefined");
|
|
14157
|
+
}
|
|
14158
|
+
console.log(`\u{1F517} Connecting to LIT Contracts: ${litContracts.network || "unknown"}`);
|
|
14159
|
+
await litContracts.connect();
|
|
14160
|
+
console.log("\u2705 LIT Contracts connected successfully");
|
|
14161
|
+
},
|
|
14162
|
+
config,
|
|
14163
|
+
"LIT Contracts Connection"
|
|
14164
|
+
);
|
|
14176
14165
|
}
|
|
14177
14166
|
async function validateLitNodeConnection(litNodeClient) {
|
|
14178
14167
|
try {
|
|
@@ -14192,33 +14181,37 @@ ${errorReport}`);
|
|
|
14192
14181
|
}
|
|
14193
14182
|
async function generateSessionSignatures(litNodeClient, sessionConfig, config = {}, pkpTokenId, litActionCid, signerAddress, network = "chipotle") {
|
|
14194
14183
|
if (pkpTokenId && litActionCid && signerAddress) {
|
|
14195
|
-
const { sessionSignatureCache } = await Promise.resolve().then(() =>
|
|
14196
|
-
const cached =
|
|
14184
|
+
const { sessionSignatureCache: sessionSignatureCache2 } = await Promise.resolve().then(() => (init_session_signature_cache(), session_signature_cache_exports));
|
|
14185
|
+
const cached = sessionSignatureCache2.get(pkpTokenId, litActionCid, signerAddress, network);
|
|
14197
14186
|
if (cached) {
|
|
14198
14187
|
const sigCount = Object.keys(cached).length;
|
|
14199
|
-
|
|
14188
|
+
debugInfo("SESSION", `\u{1F504} Using cached session signatures (${sigCount} sigs)`);
|
|
14200
14189
|
return cached;
|
|
14201
14190
|
}
|
|
14202
14191
|
}
|
|
14203
|
-
return withRetry(
|
|
14204
|
-
(
|
|
14205
|
-
|
|
14206
|
-
|
|
14207
|
-
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
|
|
14192
|
+
return withRetry(
|
|
14193
|
+
async () => {
|
|
14194
|
+
debugInfo("SESSION", "\u{1F510} Generating new session signatures...");
|
|
14195
|
+
const sessionSigs = await litNodeClient.getSessionSigs(sessionConfig);
|
|
14196
|
+
const sigCount = Object.keys(sessionSigs).length;
|
|
14197
|
+
if (pkpTokenId && litActionCid && signerAddress) {
|
|
14198
|
+
const { sessionSignatureCache: sessionSignatureCache2 } = await Promise.resolve().then(() => (init_session_signature_cache(), session_signature_cache_exports));
|
|
14199
|
+
const expiration = new Date(sessionConfig.expiration);
|
|
14200
|
+
sessionSignatureCache2.set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration);
|
|
14201
|
+
}
|
|
14202
|
+
debugInfo("SESSION", `\u2705 Generated ${sigCount} session signatures`);
|
|
14203
|
+
return sessionSigs;
|
|
14204
|
+
},
|
|
14205
|
+
config,
|
|
14206
|
+
"Session Signature Generation"
|
|
14207
|
+
);
|
|
14215
14208
|
}
|
|
14216
14209
|
async function validateLitNodeReadiness(litNodeClient) {
|
|
14217
14210
|
if (!litNodeClient) {
|
|
14218
14211
|
throw new Error("LIT Node Client is null or undefined");
|
|
14219
14212
|
}
|
|
14220
14213
|
if (!litNodeClient.ready) {
|
|
14221
|
-
|
|
14214
|
+
debugWarn("CONNECTION", "\u26A0\uFE0F LIT Node Client not ready, attempting to reconnect...");
|
|
14222
14215
|
await litNodeClient.connect();
|
|
14223
14216
|
const readyTimeout = 15e3;
|
|
14224
14217
|
const startTime = Date.now();
|
|
@@ -14229,32 +14222,36 @@ ${errorReport}`);
|
|
|
14229
14222
|
throw new Error("LIT Node Client is not ready for operations");
|
|
14230
14223
|
}
|
|
14231
14224
|
}
|
|
14232
|
-
|
|
14225
|
+
debugInfo("CONNECTION", "\u2705 LIT Node Client readiness validated");
|
|
14233
14226
|
}
|
|
14234
14227
|
async function executeLitAction(litNodeClient, executionConfig, config = {}) {
|
|
14235
14228
|
const cid = executionConfig.ipfsId;
|
|
14236
|
-
return withRetry(
|
|
14237
|
-
|
|
14238
|
-
|
|
14239
|
-
|
|
14240
|
-
|
|
14241
|
-
|
|
14242
|
-
|
|
14243
|
-
|
|
14244
|
-
(
|
|
14245
|
-
|
|
14246
|
-
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14229
|
+
return withRetry(
|
|
14230
|
+
async () => {
|
|
14231
|
+
const startTime = Date.now();
|
|
14232
|
+
await validateLitNodeReadiness(litNodeClient);
|
|
14233
|
+
logLitActionExecution(cid, executionConfig.jsParams);
|
|
14234
|
+
logRequest("LIT_ACTION", "executeJs", executionConfig);
|
|
14235
|
+
const result = await litNodeClient.executeJs(executionConfig);
|
|
14236
|
+
const duration = Date.now() - startTime;
|
|
14237
|
+
if (!result.response) {
|
|
14238
|
+
logError("LIT_ACTION", "executeJs", new Error("No response from LIT Action"), duration);
|
|
14239
|
+
throw new Error("No response from LIT Action");
|
|
14240
|
+
}
|
|
14241
|
+
logResponse("LIT_ACTION", "executeJs", result, duration);
|
|
14242
|
+
logLitActionResult(cid, true, duration, result);
|
|
14243
|
+
return result;
|
|
14244
|
+
},
|
|
14245
|
+
config,
|
|
14246
|
+
"LIT Action Execution"
|
|
14247
|
+
);
|
|
14251
14248
|
}
|
|
14252
14249
|
async function executePkpOperation(operation, operationName, config = {}) {
|
|
14253
14250
|
const pkpConfig = {
|
|
14254
|
-
...
|
|
14251
|
+
...DEFAULT_RETRY_CONFIG,
|
|
14255
14252
|
...config,
|
|
14256
14253
|
retryableErrors: [
|
|
14257
|
-
...
|
|
14254
|
+
...DEFAULT_RETRY_CONFIG.retryableErrors,
|
|
14258
14255
|
"pkp validation",
|
|
14259
14256
|
"signing shares",
|
|
14260
14257
|
"resource validation",
|
|
@@ -14263,7 +14260,7 @@ ${errorReport}`);
|
|
|
14263
14260
|
};
|
|
14264
14261
|
return withRetry(operation, pkpConfig, `PKP ${operationName}`);
|
|
14265
14262
|
}
|
|
14266
|
-
|
|
14263
|
+
var NETWORK_TIMEOUTS = {
|
|
14267
14264
|
chipotle: {
|
|
14268
14265
|
connection: 6e4,
|
|
14269
14266
|
operation: 12e4,
|
|
@@ -14271,82 +14268,10 @@ ${errorReport}`);
|
|
|
14271
14268
|
}
|
|
14272
14269
|
};
|
|
14273
14270
|
function getNetworkTimeouts(network) {
|
|
14274
|
-
return
|
|
14271
|
+
return NETWORK_TIMEOUTS[network] || NETWORK_TIMEOUTS["chipotle"];
|
|
14275
14272
|
}
|
|
14276
|
-
|
|
14277
|
-
|
|
14278
|
-
|
|
14279
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/index.js
|
|
14280
|
-
var require_utils4 = __commonJS({
|
|
14281
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/index.js"(exports) {
|
|
14282
|
-
"use strict";
|
|
14283
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
14284
|
-
if (k2 === void 0)
|
|
14285
|
-
k2 = k;
|
|
14286
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14287
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14288
|
-
desc = { enumerable: true, get: function() {
|
|
14289
|
-
return m[k];
|
|
14290
|
-
} };
|
|
14291
|
-
}
|
|
14292
|
-
Object.defineProperty(o, k2, desc);
|
|
14293
|
-
} : function(o, m, k, k2) {
|
|
14294
|
-
if (k2 === void 0)
|
|
14295
|
-
k2 = k;
|
|
14296
|
-
o[k2] = m[k];
|
|
14297
|
-
});
|
|
14298
|
-
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
14299
|
-
for (var p in m)
|
|
14300
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
14301
|
-
__createBinding(exports2, m, p);
|
|
14302
|
-
};
|
|
14303
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14304
|
-
__exportStar(require_lit_action_helpers(), exports);
|
|
14305
|
-
__exportStar(require_pkp_setup(), exports);
|
|
14306
|
-
__exportStar(require_cid_utils(), exports);
|
|
14307
|
-
__exportStar(require_connection_helpers(), exports);
|
|
14308
|
-
__exportStar(require_debug_logger(), exports);
|
|
14309
|
-
__exportStar(require_error_classification(), exports);
|
|
14310
|
-
__exportStar(require_session_signature_cache(), exports);
|
|
14311
|
-
}
|
|
14312
|
-
});
|
|
14313
|
-
|
|
14314
|
-
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js
|
|
14315
|
-
var require_pkg_src = __commonJS({
|
|
14316
|
-
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js"(exports) {
|
|
14317
|
-
"use strict";
|
|
14318
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
14319
|
-
if (k2 === void 0)
|
|
14320
|
-
k2 = k;
|
|
14321
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14322
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14323
|
-
desc = { enumerable: true, get: function() {
|
|
14324
|
-
return m[k];
|
|
14325
|
-
} };
|
|
14326
|
-
}
|
|
14327
|
-
Object.defineProperty(o, k2, desc);
|
|
14328
|
-
} : function(o, m, k, k2) {
|
|
14329
|
-
if (k2 === void 0)
|
|
14330
|
-
k2 = k;
|
|
14331
|
-
o[k2] = m[k];
|
|
14332
|
-
});
|
|
14333
|
-
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
14334
|
-
for (var p in m)
|
|
14335
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
14336
|
-
__createBinding(exports2, m, p);
|
|
14337
|
-
};
|
|
14338
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14339
|
-
exports.CHIPOTLE_DEPLOYMENTS = exports.DH_LIT_ACTIONS_CHIPOTLE = void 0;
|
|
14340
|
-
__exportStar(require_interfaces(), exports);
|
|
14341
|
-
__exportStar(require_lit_actions_registry(), exports);
|
|
14342
|
-
__exportStar(require_utils4(), exports);
|
|
14343
|
-
var lit_actions_registry_1 = require_lit_actions_registry();
|
|
14344
|
-
Object.defineProperty(exports, "DH_LIT_ACTIONS_CHIPOTLE", { enumerable: true, get: function() {
|
|
14345
|
-
return lit_actions_registry_1.DH_LIT_ACTIONS_CHIPOTLE;
|
|
14346
|
-
} });
|
|
14347
|
-
Object.defineProperty(exports, "CHIPOTLE_DEPLOYMENTS", { enumerable: true, get: function() {
|
|
14348
|
-
return lit_actions_registry_1.CHIPOTLE_DEPLOYMENTS;
|
|
14349
|
-
} });
|
|
14273
|
+
init_debug_logger();
|
|
14274
|
+
init_session_signature_cache();
|
|
14350
14275
|
}
|
|
14351
14276
|
});
|
|
14352
14277
|
|
|
@@ -14400,53 +14325,53 @@ var init_deployment_addresses = __esm({
|
|
|
14400
14325
|
},
|
|
14401
14326
|
upgraded: {
|
|
14402
14327
|
PositionManager: {
|
|
14403
|
-
previousImplementation: "
|
|
14404
|
-
newImplementation: "
|
|
14405
|
-
upgradedAt: "2026-04-
|
|
14328
|
+
previousImplementation: "0x1b854fE920AC409b5f407b3ABCd556C998F889E5",
|
|
14329
|
+
newImplementation: "0xd163965Ea2e33d58635bf24B7539f0df3D384933",
|
|
14330
|
+
upgradedAt: "2026-04-30T08:33:24.883Z",
|
|
14406
14331
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14407
14332
|
reason: "Shared upgrade script: PositionManager implementation update"
|
|
14408
14333
|
},
|
|
14409
14334
|
LoanOperationsManagerModule: {
|
|
14410
|
-
previousImplementation: "
|
|
14411
|
-
newImplementation: "
|
|
14412
|
-
upgradedAt: "2026-04-
|
|
14335
|
+
previousImplementation: "0x448Fb59Cad99FFe3d0766F6943E4B579A824d46b",
|
|
14336
|
+
newImplementation: "0x8880D85Da2F8e60D4e91AE2457C34d76659dfa71",
|
|
14337
|
+
upgradedAt: "2026-04-30T08:34:13.649Z",
|
|
14413
14338
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14414
14339
|
reason: "Shared upgrade script: LoanOperationsManagerModule implementation update"
|
|
14415
14340
|
},
|
|
14416
14341
|
UCDController: {
|
|
14417
|
-
previousImplementation: "
|
|
14418
|
-
newImplementation: "
|
|
14419
|
-
upgradedAt: "2026-04-
|
|
14342
|
+
previousImplementation: "0xB5322F0D4a07d4342FA38137ebD95ac41D1c6036",
|
|
14343
|
+
newImplementation: "0x2d4d689A70B56b6E0B9F70BffA6265A55173A4A1",
|
|
14344
|
+
upgradedAt: "2026-04-30T08:24:24.765Z",
|
|
14420
14345
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14421
14346
|
reason: "Shared upgrade script: UCDController implementation update"
|
|
14422
14347
|
},
|
|
14423
14348
|
TermManagerModule: {
|
|
14424
|
-
previousImplementation: "
|
|
14425
|
-
newImplementation: "
|
|
14426
|
-
upgradedAt: "2026-04-
|
|
14349
|
+
previousImplementation: "0x1D5E5A93215E49aA7260dA8d3B3de9faA686C087",
|
|
14350
|
+
newImplementation: "0x2EaF1052706120CAa6B6F75354F70f77ef2261eB",
|
|
14351
|
+
upgradedAt: "2026-04-30T08:26:37.176Z",
|
|
14427
14352
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14428
14353
|
reason: "Shared upgrade script: TermManagerModule implementation update"
|
|
14429
14354
|
},
|
|
14430
14355
|
CircuitBreakerModule: {
|
|
14431
|
-
previousImplementation: "
|
|
14432
|
-
newImplementation: "
|
|
14433
|
-
upgradedAt: "2026-04-
|
|
14356
|
+
previousImplementation: "0xa4940082a7b58c45C3885C4B59714C0dD048cDdC",
|
|
14357
|
+
newImplementation: "0x8e9e10B14E6a91ec271FBEb4FD3fB1FE06b545dD",
|
|
14358
|
+
upgradedAt: "2026-04-30T08:29:37.131Z",
|
|
14434
14359
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14435
14360
|
reason: "Shared upgrade script: CircuitBreakerModule implementation update"
|
|
14436
14361
|
},
|
|
14437
14362
|
AdminModule: {
|
|
14438
|
-
previousImplementation: "
|
|
14439
|
-
newImplementation: "
|
|
14440
|
-
upgradedAt: "2026-04-
|
|
14363
|
+
previousImplementation: "0x8bDe850573a947b816D1EC5C5Ca177853bDfD049",
|
|
14364
|
+
newImplementation: "0x67AE2F872c37f33db9bC631e135432B2845d308b",
|
|
14365
|
+
upgradedAt: "2026-04-30T08:31:13.444Z",
|
|
14441
14366
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14442
|
-
reason: "
|
|
14367
|
+
reason: "Shared upgrade script: AdminModule implementation update"
|
|
14443
14368
|
},
|
|
14444
14369
|
PositionManagerViews: {
|
|
14445
|
-
previousImplementation: "
|
|
14446
|
-
newImplementation: "
|
|
14447
|
-
upgradedAt: "2026-04-
|
|
14370
|
+
previousImplementation: "0xE8b4D4b6E3163EdfF8958da4cF8267ACa369D486",
|
|
14371
|
+
newImplementation: "0xadF8e0F34082a8fC23e727276e0aEf3af183C8Fd",
|
|
14372
|
+
upgradedAt: "2026-04-30T08:32:48.463Z",
|
|
14448
14373
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14449
|
-
reason: "
|
|
14374
|
+
reason: "Shared upgrade script: PositionManagerViews implementation update"
|
|
14450
14375
|
},
|
|
14451
14376
|
TestPositionManager: {
|
|
14452
14377
|
previousImplementation: "0x0B46Ee1a9C6b42559758B7FF78294Cd867BB08f8",
|
|
@@ -14456,51 +14381,51 @@ var init_deployment_addresses = __esm({
|
|
|
14456
14381
|
reason: "Add setPositionExpiry() for expiry-liquidation E2E testing"
|
|
14457
14382
|
},
|
|
14458
14383
|
UCDToken: {
|
|
14459
|
-
previousImplementation: "
|
|
14460
|
-
newImplementation: "
|
|
14461
|
-
upgradedAt: "2026-04-
|
|
14384
|
+
previousImplementation: "0xEFFF6f32Fc33C4Cb58a4d6858Bf90B8feA7D1D33",
|
|
14385
|
+
newImplementation: "0x155Da00Ee0beb1d9D5BA34Aeb62c9ad4E8227d5D",
|
|
14386
|
+
upgradedAt: "2026-04-30T08:25:01.929Z",
|
|
14462
14387
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14463
14388
|
reason: "Shared upgrade script: UCDToken implementation update"
|
|
14464
14389
|
},
|
|
14465
14390
|
PositionManagerCoreModule: {
|
|
14466
|
-
previousImplementation: "
|
|
14467
|
-
newImplementation: "
|
|
14468
|
-
upgradedAt: "2026-04-
|
|
14391
|
+
previousImplementation: "0xeA5234c8E3a5F61c660db529d9d6f91fd989B56E",
|
|
14392
|
+
newImplementation: "0x41168d9BF8e696eBAB05ea539321ac212859d80b",
|
|
14393
|
+
upgradedAt: "2026-04-30T09:32:01.570Z",
|
|
14469
14394
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14470
14395
|
reason: "Shared upgrade script: PositionManagerCoreModule implementation update"
|
|
14471
14396
|
},
|
|
14472
14397
|
CollateralManagerModule: {
|
|
14473
|
-
previousImplementation: "
|
|
14474
|
-
newImplementation: "
|
|
14475
|
-
upgradedAt: "2026-04-
|
|
14398
|
+
previousImplementation: "0x84C5B89f60415F8df3Fee46Ef1a10a6484aa8e0A",
|
|
14399
|
+
newImplementation: "0xd021ca6Dc2377F361E3c64f60C93E0e4075c2840",
|
|
14400
|
+
upgradedAt: "2026-04-30T08:27:24.702Z",
|
|
14476
14401
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14477
14402
|
reason: "Shared upgrade script: CollateralManagerModule implementation update"
|
|
14478
14403
|
},
|
|
14479
14404
|
LiquidationManagerModule: {
|
|
14480
|
-
previousImplementation: "
|
|
14481
|
-
newImplementation: "
|
|
14482
|
-
upgradedAt: "2026-04-
|
|
14405
|
+
previousImplementation: "0xBb625E44d72f3F1acDCbB08F73AFdAc38fCE3F64",
|
|
14406
|
+
newImplementation: "0xf74d5437691df92087170861213e26064358A7fb",
|
|
14407
|
+
upgradedAt: "2026-04-30T08:29:01.327Z",
|
|
14483
14408
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14484
14409
|
reason: "Shared upgrade script: LiquidationManagerModule implementation update"
|
|
14485
14410
|
},
|
|
14486
14411
|
BTCSpendAuthorizer: {
|
|
14487
|
-
previousImplementation: "
|
|
14488
|
-
newImplementation: "
|
|
14489
|
-
upgradedAt: "2026-04-
|
|
14412
|
+
previousImplementation: "0x0B46DCdB63CB9928789ef1979C367da6ef04beAf",
|
|
14413
|
+
newImplementation: "0x4CD021181bD2583d10aB37D27FE2994b75c41b77",
|
|
14414
|
+
upgradedAt: "2026-04-30T08:32:02.761Z",
|
|
14490
14415
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14491
14416
|
reason: "Shared upgrade script: BTCSpendAuthorizer implementation update"
|
|
14492
14417
|
},
|
|
14493
14418
|
SimplePSMV2: {
|
|
14494
|
-
previousImplementation: "
|
|
14495
|
-
newImplementation: "
|
|
14496
|
-
upgradedAt: "2026-04-
|
|
14419
|
+
previousImplementation: "0xBdEFa375db7F9A498B81bcfdDd14FD16D02ca0BF",
|
|
14420
|
+
newImplementation: "0x4107104fDF61AACC674f1F168c275f034c8112BF",
|
|
14421
|
+
upgradedAt: "2026-04-30T08:35:01.138Z",
|
|
14497
14422
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14498
14423
|
reason: "Shared upgrade script: SimplePSMV2 implementation update"
|
|
14499
14424
|
},
|
|
14500
14425
|
UpgradeValidator: {
|
|
14501
|
-
previousImplementation: "
|
|
14502
|
-
newImplementation: "
|
|
14503
|
-
upgradedAt: "2026-04-
|
|
14426
|
+
previousImplementation: "0xE410d1028Cdf2D94E3F5049F2D04B573703A2804",
|
|
14427
|
+
newImplementation: "0x974C6F4e0F67Fa9d7Ab1aee8C10Bd85B201ec5D7",
|
|
14428
|
+
upgradedAt: "2026-04-30T09:32:25.094Z",
|
|
14504
14429
|
upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
|
|
14505
14430
|
reason: "Shared upgrade script: UpgradeValidator implementation update"
|
|
14506
14431
|
},
|
|
@@ -14577,26 +14502,26 @@ var init_deployment_addresses = __esm({
|
|
|
14577
14502
|
POSITION_MANAGER_VIEWS: "0x3b970E41a0668508B4B2ACb83653b2A402F745AE",
|
|
14578
14503
|
CIRCUIT_BREAKER_MODULE: "0x3D0B2cAE481821E57BA9CC3807bCC0d0D7F18bd8",
|
|
14579
14504
|
ADMIN_MODULE: "0xAcd1f07915b17CA3727e7fE89BdF618A1545a1ed",
|
|
14580
|
-
UCD_CONTROLLER_IMPL: "
|
|
14581
|
-
LOAN_OPERATIONS_MANAGER_MODULE_IMPL: "
|
|
14582
|
-
TERM_MANAGER_MODULE_IMPL: "
|
|
14583
|
-
CIRCUIT_BREAKER_MODULE_IMPL: "
|
|
14584
|
-
ADMIN_MODULE_IMPL: "
|
|
14585
|
-
POSITION_MANAGER_VIEWS_IMPL: "
|
|
14586
|
-
POSITION_MANAGER_IMPL: "
|
|
14505
|
+
UCD_CONTROLLER_IMPL: "0x2d4d689A70B56b6E0B9F70BffA6265A55173A4A1",
|
|
14506
|
+
LOAN_OPERATIONS_MANAGER_MODULE_IMPL: "0x8880D85Da2F8e60D4e91AE2457C34d76659dfa71",
|
|
14507
|
+
TERM_MANAGER_MODULE_IMPL: "0x2EaF1052706120CAa6B6F75354F70f77ef2261eB",
|
|
14508
|
+
CIRCUIT_BREAKER_MODULE_IMPL: "0x8e9e10B14E6a91ec271FBEb4FD3fB1FE06b545dD",
|
|
14509
|
+
ADMIN_MODULE_IMPL: "0x67AE2F872c37f33db9bC631e135432B2845d308b",
|
|
14510
|
+
POSITION_MANAGER_VIEWS_IMPL: "0xadF8e0F34082a8fC23e727276e0aEf3af183C8Fd",
|
|
14511
|
+
POSITION_MANAGER_IMPL: "0xd163965Ea2e33d58635bf24B7539f0df3D384933",
|
|
14587
14512
|
SIMPLE_PSM_V2: "0x19EcF7BA26e054fd4Ff06009A03070103dbBB058",
|
|
14588
|
-
SIMPLE_PSM_V2_IMPL: "
|
|
14589
|
-
UCD_TOKEN_IMPL: "
|
|
14513
|
+
SIMPLE_PSM_V2_IMPL: "0x4107104fDF61AACC674f1F168c275f034c8112BF",
|
|
14514
|
+
UCD_TOKEN_IMPL: "0x155Da00Ee0beb1d9D5BA34Aeb62c9ad4E8227d5D",
|
|
14590
14515
|
POSITION_MANAGER_CORE_MODULE: "0xfFAA39a08887FeFB697eBC8691A8630CbCC33391",
|
|
14591
|
-
POSITION_MANAGER_CORE_MODULE_IMPL: "
|
|
14516
|
+
POSITION_MANAGER_CORE_MODULE_IMPL: "0x41168d9BF8e696eBAB05ea539321ac212859d80b",
|
|
14592
14517
|
COLLATERAL_MANAGER_MODULE: "0x967E92c976Fc0fa8268D37D4d6B7245d912aA7dB",
|
|
14593
|
-
COLLATERAL_MANAGER_MODULE_IMPL: "
|
|
14518
|
+
COLLATERAL_MANAGER_MODULE_IMPL: "0xd021ca6Dc2377F361E3c64f60C93E0e4075c2840",
|
|
14594
14519
|
LIQUIDATION_MANAGER_MODULE: "0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76",
|
|
14595
|
-
LIQUIDATION_MANAGER_MODULE_IMPL: "
|
|
14520
|
+
LIQUIDATION_MANAGER_MODULE_IMPL: "0xf74d5437691df92087170861213e26064358A7fb",
|
|
14596
14521
|
BTC_SPEND_AUTHORIZER: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
|
|
14597
|
-
BTC_SPEND_AUTHORIZER_IMPL: "
|
|
14522
|
+
BTC_SPEND_AUTHORIZER_IMPL: "0x4CD021181bD2583d10aB37D27FE2994b75c41b77",
|
|
14598
14523
|
UPGRADE_VALIDATOR: "0x592e650edD9bA26ecc407989fdd6F9cdcDeC27A6",
|
|
14599
|
-
UPGRADE_VALIDATOR_IMPL: "
|
|
14524
|
+
UPGRADE_VALIDATOR_IMPL: "0x974C6F4e0F67Fa9d7Ab1aee8C10Bd85B201ec5D7",
|
|
14600
14525
|
BITCOIN_PROVIDER_REGISTRY: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
|
|
14601
14526
|
BITCOIN_PROVIDER_REGISTRY_IMPL: "0x225309A4ae6D146ba93A3278A7b40224FfC81448",
|
|
14602
14527
|
LIT_ACTION_VALIDATOR: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
|
|
@@ -14627,68 +14552,66 @@ var init_deployment_addresses = __esm({
|
|
|
14627
14552
|
LOCALHOST_DEPLOYMENT = {
|
|
14628
14553
|
network: "localhost",
|
|
14629
14554
|
chainId: 31337,
|
|
14630
|
-
timestamp: "2026-
|
|
14555
|
+
timestamp: "2026-03-23T15:33:34.068Z",
|
|
14631
14556
|
deployer: "",
|
|
14632
14557
|
contracts: {
|
|
14633
|
-
MessageHashBuilder: "
|
|
14634
|
-
UpgradeValidator: "
|
|
14558
|
+
MessageHashBuilder: "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
|
|
14559
|
+
UpgradeValidator: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
|
|
14635
14560
|
UCDToken: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
14636
14561
|
UCDController: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
14637
|
-
PositionManagerCoreModule: "
|
|
14638
|
-
TermManagerModule: "
|
|
14639
|
-
LoanOperationsManagerModule: "
|
|
14562
|
+
PositionManagerCoreModule: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
14563
|
+
TermManagerModule: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
|
|
14564
|
+
LoanOperationsManagerModule: "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
|
|
14640
14565
|
BTCSpendAuthorizer: "0x59b670e9fA9D0A427751Af201D676719a970857b",
|
|
14641
14566
|
CollateralManagerModule: "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
|
|
14642
14567
|
LiquidationManagerModule: "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
|
|
14643
|
-
CircuitBreakerModule: "
|
|
14568
|
+
CircuitBreakerModule: "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
|
|
14644
14569
|
AdminModule: "0xc5a5C42992dECbae36851359345FE25997F5C42d",
|
|
14645
|
-
PositionManagerViews: "
|
|
14646
|
-
PositionManager: "
|
|
14647
|
-
OperationAuthorizationRegistry: "
|
|
14648
|
-
PKPValidation: "
|
|
14570
|
+
PositionManagerViews: "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
|
|
14571
|
+
PositionManager: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
|
|
14572
|
+
OperationAuthorizationRegistry: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
|
|
14573
|
+
PKPValidation: "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc"
|
|
14649
14574
|
},
|
|
14650
14575
|
latestEnv: {
|
|
14651
14576
|
UCD_TOKEN: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
14652
14577
|
UCD_CONTROLLER: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
14653
|
-
POSITION_MANAGER: "
|
|
14654
|
-
PKP_VALIDATION_REGISTRY: "
|
|
14655
|
-
PKP_VALIDATION_CID_V1: "
|
|
14656
|
-
|
|
14657
|
-
|
|
14658
|
-
|
|
14659
|
-
UCD_MINT_VALIDATOR_ADDRESS: "0x4D9299055093938d0CD2F26C42A87260CB50adD8",
|
|
14578
|
+
POSITION_MANAGER: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
|
|
14579
|
+
PKP_VALIDATION_REGISTRY: "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc",
|
|
14580
|
+
PKP_VALIDATION_CID_V1: "QmfHJKA4RnW7RepsdLmrDwKjVTzPXB2K3qMTco3JNPDexm",
|
|
14581
|
+
PKP_ETH_ADDRESS: "0x9624C46073E1d1F5AB975c67Fc899536d599bb57",
|
|
14582
|
+
OPERATION_AUTHORIZATION_REGISTRY: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
|
|
14583
|
+
UCD_MINT_VALIDATOR_ADDRESS: "0x80f81afb9e6dF27afCD752ad46cD286e705e42be",
|
|
14660
14584
|
UCD_MINT_VALIDATOR_VERSION: 1,
|
|
14661
|
-
BTC_WITHDRAWAL_VALIDATOR_ADDRESS: "
|
|
14585
|
+
BTC_WITHDRAWAL_VALIDATOR_ADDRESS: "0xa751ad81E1CAe61d6cF5Cf64839Fe8D28A1372Df",
|
|
14662
14586
|
BTC_WITHDRAWAL_VALIDATOR_VERSION: 1,
|
|
14663
|
-
UPDATE_BALANCE_VALIDATOR_ADDRESS: "
|
|
14587
|
+
UPDATE_BALANCE_VALIDATOR_ADDRESS: "0x8A40C22B03348bc10df9ae0dc54346b4AE8e909c",
|
|
14664
14588
|
UPDATE_BALANCE_VALIDATOR_VERSION: 1,
|
|
14665
|
-
PROCESS_PAYMENT_VALIDATOR_ADDRESS: "
|
|
14589
|
+
PROCESS_PAYMENT_VALIDATOR_ADDRESS: "0x28f50E07532d3aF677b8E0bcF220422d159b0dd6",
|
|
14666
14590
|
PROCESS_PAYMENT_VALIDATOR_VERSION: 1,
|
|
14667
|
-
EXTEND_POSITION_VALIDATOR_ADDRESS: "
|
|
14591
|
+
EXTEND_POSITION_VALIDATOR_ADDRESS: "0xc7aC43F2F907123465449575e853f5D0229898e1",
|
|
14668
14592
|
EXTEND_POSITION_VALIDATOR_VERSION: 1,
|
|
14669
|
-
POSITION_MANAGER_CORE_MODULE: "
|
|
14670
|
-
LOAN_OPERATIONS_MANAGER_MODULE: "
|
|
14671
|
-
TERM_MANAGER_MODULE: "
|
|
14672
|
-
COMMUNITY_MANAGER_MODULE: ""
|
|
14593
|
+
POSITION_MANAGER_CORE_MODULE: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
14594
|
+
LOAN_OPERATIONS_MANAGER_MODULE: "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
|
|
14595
|
+
TERM_MANAGER_MODULE: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82"
|
|
14673
14596
|
}
|
|
14674
14597
|
};
|
|
14675
14598
|
LOCALHOST_CONTRACTS = {
|
|
14676
|
-
MessageHashBuilder: "
|
|
14677
|
-
UpgradeValidator: "
|
|
14599
|
+
MessageHashBuilder: "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
|
|
14600
|
+
UpgradeValidator: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
|
|
14678
14601
|
UCDToken: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
14679
14602
|
UCDController: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
14680
|
-
PositionManagerCoreModule: "
|
|
14681
|
-
TermManagerModule: "
|
|
14682
|
-
LoanOperationsManagerModule: "
|
|
14603
|
+
PositionManagerCoreModule: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
14604
|
+
TermManagerModule: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
|
|
14605
|
+
LoanOperationsManagerModule: "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
|
|
14683
14606
|
BTCSpendAuthorizer: "0x59b670e9fA9D0A427751Af201D676719a970857b",
|
|
14684
14607
|
CollateralManagerModule: "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
|
|
14685
14608
|
LiquidationManagerModule: "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
|
|
14686
|
-
CircuitBreakerModule: "
|
|
14609
|
+
CircuitBreakerModule: "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
|
|
14687
14610
|
AdminModule: "0xc5a5C42992dECbae36851359345FE25997F5C42d",
|
|
14688
|
-
PositionManagerViews: "
|
|
14689
|
-
PositionManager: "
|
|
14690
|
-
OperationAuthorizationRegistry: "
|
|
14691
|
-
PKPValidation: "
|
|
14611
|
+
PositionManagerViews: "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
|
|
14612
|
+
PositionManager: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
|
|
14613
|
+
OperationAuthorizationRegistry: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
|
|
14614
|
+
PKPValidation: "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc"
|
|
14692
14615
|
};
|
|
14693
14616
|
ALL_DEPLOYMENTS = {
|
|
14694
14617
|
sepolia: SEPOLIA_DEPLOYMENT,
|
|
@@ -15014,7 +14937,7 @@ __export(src_exports, {
|
|
|
15014
14937
|
ErrorSeverity: () => ErrorSeverity,
|
|
15015
14938
|
EventHelpers: () => EventHelpers,
|
|
15016
14939
|
LOCALHOST_CONTRACTS: () => LOCALHOST_CONTRACTS,
|
|
15017
|
-
LRUCache: () =>
|
|
14940
|
+
LRUCache: () => LRUCache,
|
|
15018
14941
|
LoanCreator: () => LoanCreator,
|
|
15019
14942
|
LoanQuery: () => LoanQuery,
|
|
15020
14943
|
LoanStatus: () => LoanStatus,
|
|
@@ -31261,11 +31184,62 @@ async function generatePaymentAuthorization(positionId, amount, chainId, signer)
|
|
|
31261
31184
|
signature: signature2
|
|
31262
31185
|
};
|
|
31263
31186
|
}
|
|
31264
|
-
|
|
31187
|
+
function isChipotlePkpId(pkpTokenId) {
|
|
31265
31188
|
const rawHex = pkpTokenId.startsWith("0x") ? pkpTokenId.slice(2) : pkpTokenId;
|
|
31266
|
-
|
|
31189
|
+
return rawHex.length === 64 && rawHex.startsWith("000000000000000000000000") && rawHex !== "0".repeat(64);
|
|
31190
|
+
}
|
|
31191
|
+
async function deriveChipotlePublicKeyViaService(pkpTokenId, fallback) {
|
|
31192
|
+
const url = `${fallback.serviceEndpoint}/api/lit/pkp/derive-public-key`;
|
|
31193
|
+
const controller = new AbortController();
|
|
31194
|
+
const timeout = setTimeout(
|
|
31195
|
+
() => controller.abort(),
|
|
31196
|
+
fallback.timeoutMs ?? 6e4
|
|
31197
|
+
);
|
|
31198
|
+
try {
|
|
31199
|
+
const headers = {
|
|
31200
|
+
"Content-Type": "application/json"
|
|
31201
|
+
};
|
|
31202
|
+
if (fallback.serviceAuthToken) {
|
|
31203
|
+
headers["Authorization"] = `Bearer ${fallback.serviceAuthToken}`;
|
|
31204
|
+
}
|
|
31205
|
+
const response = await fetch(url, {
|
|
31206
|
+
method: "POST",
|
|
31207
|
+
headers,
|
|
31208
|
+
body: JSON.stringify({
|
|
31209
|
+
pkpId: pkpTokenId,
|
|
31210
|
+
...fallback.borrowerAddress && {
|
|
31211
|
+
borrowerAddress: fallback.borrowerAddress
|
|
31212
|
+
}
|
|
31213
|
+
}),
|
|
31214
|
+
signal: controller.signal
|
|
31215
|
+
});
|
|
31216
|
+
if (!response.ok) {
|
|
31217
|
+
const errorText = await response.text();
|
|
31218
|
+
throw new Error(
|
|
31219
|
+
`derive-public-key service error (${response.status}): ${errorText}`
|
|
31220
|
+
);
|
|
31221
|
+
}
|
|
31222
|
+
const envelope = await response.json();
|
|
31223
|
+
const publicKey = envelope?.data?.publicKey;
|
|
31224
|
+
if (!envelope?.success || !publicKey) {
|
|
31225
|
+
throw new Error(
|
|
31226
|
+
`derive-public-key returned no publicKey (envelope keys: ${Object.keys(
|
|
31227
|
+
envelope ?? {}
|
|
31228
|
+
).join(", ")})`
|
|
31229
|
+
);
|
|
31230
|
+
}
|
|
31231
|
+
return publicKey.startsWith("0x") ? publicKey : `0x${publicKey}`;
|
|
31232
|
+
} finally {
|
|
31233
|
+
clearTimeout(timeout);
|
|
31234
|
+
}
|
|
31235
|
+
}
|
|
31236
|
+
async function getPKPPublicKeyFromTokenId(pkpTokenId, provider, pkpNftContractAddress, chipotleFallback) {
|
|
31237
|
+
if (isChipotlePkpId(pkpTokenId)) {
|
|
31238
|
+
if (chipotleFallback?.serviceEndpoint) {
|
|
31239
|
+
return deriveChipotlePublicKeyViaService(pkpTokenId, chipotleFallback);
|
|
31240
|
+
}
|
|
31267
31241
|
throw new Error(
|
|
31268
|
-
`pkpId ${pkpTokenId} is a Chipotle wallet address (ABI-encoded ETH address). Chipotle PKPs are not NFTs and have no on-chain public key lookup.
|
|
31242
|
+
`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.`
|
|
31269
31243
|
);
|
|
31270
31244
|
}
|
|
31271
31245
|
if (!provider) {
|
|
@@ -31560,7 +31534,7 @@ function extractOptionalLitSignature(raw) {
|
|
|
31560
31534
|
|
|
31561
31535
|
// src/modules/contract/contract-manager.module.ts
|
|
31562
31536
|
var POSITION_MANAGER_ABI = [
|
|
31563
|
-
"function createPosition(bytes32 pkpId, bytes calldata validatorSignature, string mainnetVaultAddress, string regtestVaultAddress, uint256 selectedTermMonths, uint256 validatorVersion) external returns (bytes32 positionId)",
|
|
31537
|
+
"function createPosition(bytes32 pkpId, bytes calldata validatorSignature, string mainnetVaultAddress, string regtestVaultAddress, uint256 selectedTermMonths, uint256 validatorVersion, bytes calldata pkpPublicKey) external returns (bytes32 positionId)",
|
|
31564
31538
|
"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)",
|
|
31565
31539
|
"function makePayment(bytes32 positionId, uint256 paymentAmount, uint256 quantumTimestamp, uint256 btcPrice, bytes calldata paymentValidatorSignature) external returns (bool)",
|
|
31566
31540
|
"function extendPosition(bytes32 positionId, uint256 selectedTerm, uint256 quantumTimestamp, uint256 btcPrice, uint256 availableBTCBalance, uint256 proRataRenewalFee, bytes calldata extensionValidatorSignature) external returns (bool)",
|
|
@@ -31884,106 +31858,333 @@ function createContractManager(config) {
|
|
|
31884
31858
|
}
|
|
31885
31859
|
|
|
31886
31860
|
// src/modules/cache/cache-manager.module.ts
|
|
31887
|
-
var
|
|
31888
|
-
cache
|
|
31861
|
+
var LRUCache = class {
|
|
31862
|
+
cache;
|
|
31889
31863
|
maxSize;
|
|
31890
31864
|
ttlMs;
|
|
31891
|
-
|
|
31892
|
-
|
|
31893
|
-
|
|
31865
|
+
debug;
|
|
31866
|
+
name;
|
|
31867
|
+
// Statistics
|
|
31868
|
+
stats = {
|
|
31869
|
+
hits: 0,
|
|
31870
|
+
misses: 0,
|
|
31871
|
+
evictions: 0
|
|
31872
|
+
};
|
|
31873
|
+
constructor(config = {}) {
|
|
31874
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
31875
|
+
this.maxSize = config.maxSize || 1e3;
|
|
31876
|
+
this.ttlMs = config.ttlMs || 6e4;
|
|
31877
|
+
this.debug = config.debug || false;
|
|
31878
|
+
this.name = config.name || "Cache";
|
|
31879
|
+
if (this.debug) {
|
|
31880
|
+
console.log(
|
|
31881
|
+
`\u{1F4BE} [${this.name}] Initialized: maxSize=${this.maxSize}, ttl=${this.ttlMs}ms`
|
|
31882
|
+
);
|
|
31883
|
+
}
|
|
31894
31884
|
}
|
|
31895
31885
|
/**
|
|
31896
31886
|
* Get value from cache
|
|
31887
|
+
*
|
|
31888
|
+
* Returns null if:
|
|
31889
|
+
* - Key not found
|
|
31890
|
+
* - Entry has expired
|
|
31891
|
+
*
|
|
31892
|
+
* @param key - Cache key
|
|
31893
|
+
* @returns Cached value or null
|
|
31897
31894
|
*/
|
|
31898
31895
|
get(key2) {
|
|
31899
31896
|
const entry = this.cache.get(key2);
|
|
31900
31897
|
if (!entry) {
|
|
31901
|
-
|
|
31898
|
+
this.stats.misses++;
|
|
31899
|
+
if (this.debug) {
|
|
31900
|
+
console.log(`\u274C [${this.name}] Cache MISS: ${String(key2)}`);
|
|
31901
|
+
}
|
|
31902
|
+
return null;
|
|
31902
31903
|
}
|
|
31903
|
-
|
|
31904
|
-
if (now2 - entry.timestamp > entry.ttl) {
|
|
31904
|
+
if (this.isExpired(entry)) {
|
|
31905
31905
|
this.cache.delete(key2);
|
|
31906
|
-
|
|
31906
|
+
this.stats.misses++;
|
|
31907
|
+
if (this.debug) {
|
|
31908
|
+
const age = Date.now() - entry.timestamp;
|
|
31909
|
+
console.log(`\u23F0 [${this.name}] Cache EXPIRED: ${String(key2)} (age: ${age}ms)`);
|
|
31910
|
+
}
|
|
31911
|
+
return null;
|
|
31912
|
+
}
|
|
31913
|
+
entry.hits++;
|
|
31914
|
+
entry.lastAccessed = Date.now();
|
|
31915
|
+
this.cache.set(key2, entry);
|
|
31916
|
+
this.stats.hits++;
|
|
31917
|
+
if (this.debug) {
|
|
31918
|
+
const age = Date.now() - entry.timestamp;
|
|
31919
|
+
console.log(
|
|
31920
|
+
`\u2705 [${this.name}] Cache HIT: ${String(key2)} (age: ${age}ms, hits: ${entry.hits})`
|
|
31921
|
+
);
|
|
31907
31922
|
}
|
|
31908
31923
|
return entry.value;
|
|
31909
31924
|
}
|
|
31925
|
+
/**
|
|
31926
|
+
* Get value from cache with Result wrapper
|
|
31927
|
+
*
|
|
31928
|
+
* Useful when you want to distinguish between "not found" and "expired"
|
|
31929
|
+
*/
|
|
31930
|
+
getResult(key2) {
|
|
31931
|
+
const value = this.get(key2);
|
|
31932
|
+
if (value === null) {
|
|
31933
|
+
return failure(
|
|
31934
|
+
new SDKError({
|
|
31935
|
+
message: `Cache miss for key: ${String(key2)}`,
|
|
31936
|
+
category: "CACHE" /* CACHE */,
|
|
31937
|
+
severity: "LOW" /* LOW */,
|
|
31938
|
+
originalError: new Error("Cache miss")
|
|
31939
|
+
})
|
|
31940
|
+
);
|
|
31941
|
+
}
|
|
31942
|
+
return success(value);
|
|
31943
|
+
}
|
|
31910
31944
|
/**
|
|
31911
31945
|
* Set value in cache
|
|
31946
|
+
*
|
|
31947
|
+
* If cache is full, evicts the least recently used entry
|
|
31948
|
+
*
|
|
31949
|
+
* @param key - Cache key
|
|
31950
|
+
* @param value - Value to cache
|
|
31951
|
+
* @param ttl - Optional custom TTL for this entry (ms)
|
|
31912
31952
|
*/
|
|
31913
31953
|
set(key2, value, ttl) {
|
|
31914
31954
|
if (this.cache.size >= this.maxSize && !this.cache.has(key2)) {
|
|
31915
|
-
|
|
31916
|
-
if (firstKey) {
|
|
31917
|
-
this.cache.delete(firstKey);
|
|
31918
|
-
}
|
|
31955
|
+
this.evictLRU();
|
|
31919
31956
|
}
|
|
31920
|
-
|
|
31957
|
+
const entry = {
|
|
31921
31958
|
value,
|
|
31922
31959
|
timestamp: Date.now(),
|
|
31923
|
-
|
|
31924
|
-
|
|
31960
|
+
hits: 0,
|
|
31961
|
+
lastAccessed: Date.now()
|
|
31962
|
+
};
|
|
31963
|
+
this.cache.set(key2, entry);
|
|
31964
|
+
if (this.debug) {
|
|
31965
|
+
const effectiveTtl = ttl || this.ttlMs;
|
|
31966
|
+
console.log(
|
|
31967
|
+
`\u{1F4BE} [${this.name}] Cache SET: ${String(key2)} (ttl: ${effectiveTtl}ms, size: ${this.cache.size}/${this.maxSize})`
|
|
31968
|
+
);
|
|
31969
|
+
}
|
|
31970
|
+
}
|
|
31971
|
+
/**
|
|
31972
|
+
* Set value in cache with Result wrapper
|
|
31973
|
+
*/
|
|
31974
|
+
setResult(key2, value, ttl) {
|
|
31975
|
+
try {
|
|
31976
|
+
this.set(key2, value, ttl);
|
|
31977
|
+
return success(void 0);
|
|
31978
|
+
} catch (error) {
|
|
31979
|
+
return failure(
|
|
31980
|
+
new SDKError({
|
|
31981
|
+
message: `Failed to set cache value for key: ${String(key2)}`,
|
|
31982
|
+
category: "CACHE" /* CACHE */,
|
|
31983
|
+
severity: "MEDIUM" /* MEDIUM */,
|
|
31984
|
+
originalError: error instanceof Error ? error : new Error(String(error))
|
|
31985
|
+
})
|
|
31986
|
+
);
|
|
31987
|
+
}
|
|
31925
31988
|
}
|
|
31926
31989
|
/**
|
|
31927
|
-
* Check if key exists in cache
|
|
31990
|
+
* Check if key exists in cache (without affecting stats)
|
|
31928
31991
|
*/
|
|
31929
31992
|
has(key2) {
|
|
31930
|
-
|
|
31993
|
+
const entry = this.cache.get(key2);
|
|
31994
|
+
return entry !== void 0 && !this.isExpired(entry);
|
|
31931
31995
|
}
|
|
31932
31996
|
/**
|
|
31933
|
-
* Delete key from cache
|
|
31997
|
+
* Delete specific key from cache
|
|
31934
31998
|
*/
|
|
31935
31999
|
delete(key2) {
|
|
31936
|
-
|
|
32000
|
+
const deleted = this.cache.delete(key2);
|
|
32001
|
+
if (deleted && this.debug) {
|
|
32002
|
+
console.log(`\u{1F5D1}\uFE0F [${this.name}] Cache DELETE: ${String(key2)}`);
|
|
32003
|
+
}
|
|
32004
|
+
return deleted;
|
|
31937
32005
|
}
|
|
31938
32006
|
/**
|
|
31939
|
-
* Clear
|
|
32007
|
+
* Clear entire cache
|
|
31940
32008
|
*/
|
|
31941
32009
|
clear() {
|
|
32010
|
+
const previousSize = this.cache.size;
|
|
31942
32011
|
this.cache.clear();
|
|
32012
|
+
this.stats = {
|
|
32013
|
+
hits: 0,
|
|
32014
|
+
misses: 0,
|
|
32015
|
+
evictions: 0
|
|
32016
|
+
};
|
|
32017
|
+
if (this.debug) {
|
|
32018
|
+
console.log(`\u{1F9F9} [${this.name}] Cache CLEARED: removed ${previousSize} entries`);
|
|
32019
|
+
}
|
|
32020
|
+
}
|
|
32021
|
+
/**
|
|
32022
|
+
* Get current cache size
|
|
32023
|
+
*/
|
|
32024
|
+
size() {
|
|
32025
|
+
return this.cache.size;
|
|
31943
32026
|
}
|
|
31944
32027
|
/**
|
|
31945
|
-
*
|
|
32028
|
+
* Get cache statistics
|
|
32029
|
+
*/
|
|
32030
|
+
getStats() {
|
|
32031
|
+
const entries = Array.from(this.cache.values());
|
|
32032
|
+
const timestamps = entries.map((e) => e.timestamp);
|
|
32033
|
+
const total = this.stats.hits + this.stats.misses;
|
|
32034
|
+
const hitRate = total === 0 ? 0 : this.stats.hits / total * 100;
|
|
32035
|
+
return {
|
|
32036
|
+
size: this.cache.size,
|
|
32037
|
+
hits: this.stats.hits,
|
|
32038
|
+
misses: this.stats.misses,
|
|
32039
|
+
evictions: this.stats.evictions,
|
|
32040
|
+
oldestEntry: timestamps.length > 0 ? Math.min(...timestamps) : 0,
|
|
32041
|
+
newestEntry: timestamps.length > 0 ? Math.max(...timestamps) : 0,
|
|
32042
|
+
hitRate
|
|
32043
|
+
};
|
|
32044
|
+
}
|
|
32045
|
+
/**
|
|
32046
|
+
* Get hit rate percentage
|
|
32047
|
+
*/
|
|
32048
|
+
getHitRate() {
|
|
32049
|
+
const total = this.stats.hits + this.stats.misses;
|
|
32050
|
+
return total === 0 ? 0 : this.stats.hits / total * 100;
|
|
32051
|
+
}
|
|
32052
|
+
/**
|
|
32053
|
+
* Get all cached keys (for debugging)
|
|
32054
|
+
*/
|
|
32055
|
+
getKeys() {
|
|
32056
|
+
return Array.from(this.cache.keys());
|
|
32057
|
+
}
|
|
32058
|
+
/**
|
|
32059
|
+
* Get all cached values (for debugging)
|
|
32060
|
+
*/
|
|
32061
|
+
getValues() {
|
|
32062
|
+
return Array.from(this.cache.values()).map((entry) => entry.value);
|
|
32063
|
+
}
|
|
32064
|
+
/**
|
|
32065
|
+
* Get all cache entries with metadata (for debugging)
|
|
32066
|
+
*/
|
|
32067
|
+
getEntries() {
|
|
32068
|
+
return Array.from(this.cache.entries()).map(([key2, entry]) => ({
|
|
32069
|
+
key: key2,
|
|
32070
|
+
value: entry.value,
|
|
32071
|
+
metadata: {
|
|
32072
|
+
timestamp: entry.timestamp,
|
|
32073
|
+
hits: entry.hits,
|
|
32074
|
+
lastAccessed: entry.lastAccessed
|
|
32075
|
+
}
|
|
32076
|
+
}));
|
|
32077
|
+
}
|
|
32078
|
+
/**
|
|
32079
|
+
* Clean up expired entries
|
|
32080
|
+
*
|
|
32081
|
+
* Useful for periodic maintenance
|
|
32082
|
+
*
|
|
32083
|
+
* @returns Number of entries cleaned
|
|
31946
32084
|
*/
|
|
31947
32085
|
cleanExpired() {
|
|
31948
32086
|
const now2 = Date.now();
|
|
31949
|
-
let
|
|
32087
|
+
let cleanedCount = 0;
|
|
31950
32088
|
for (const [key2, entry] of this.cache.entries()) {
|
|
31951
|
-
if (now2 - entry.timestamp >
|
|
32089
|
+
if (now2 - entry.timestamp > this.ttlMs) {
|
|
31952
32090
|
this.cache.delete(key2);
|
|
31953
|
-
|
|
32091
|
+
cleanedCount++;
|
|
31954
32092
|
}
|
|
31955
32093
|
}
|
|
31956
|
-
|
|
32094
|
+
if (cleanedCount > 0 && this.debug) {
|
|
32095
|
+
console.log(`\u{1F9F9} [${this.name}] Cleaned ${cleanedCount} expired entries`);
|
|
32096
|
+
}
|
|
32097
|
+
return cleanedCount;
|
|
31957
32098
|
}
|
|
31958
32099
|
/**
|
|
31959
|
-
*
|
|
32100
|
+
* Check if cache entry is expired
|
|
31960
32101
|
*/
|
|
31961
|
-
|
|
31962
|
-
return
|
|
31963
|
-
|
|
31964
|
-
|
|
31965
|
-
|
|
31966
|
-
|
|
32102
|
+
isExpired(entry) {
|
|
32103
|
+
return Date.now() - entry.timestamp > this.ttlMs;
|
|
32104
|
+
}
|
|
32105
|
+
/**
|
|
32106
|
+
* Evict least recently used entry
|
|
32107
|
+
*/
|
|
32108
|
+
evictLRU() {
|
|
32109
|
+
let oldestKey = null;
|
|
32110
|
+
let oldestAccess = Infinity;
|
|
32111
|
+
for (const [key2, entry] of this.cache.entries()) {
|
|
32112
|
+
if (entry.lastAccessed < oldestAccess) {
|
|
32113
|
+
oldestAccess = entry.lastAccessed;
|
|
32114
|
+
oldestKey = key2;
|
|
32115
|
+
}
|
|
32116
|
+
}
|
|
32117
|
+
if (oldestKey !== null) {
|
|
32118
|
+
this.cache.delete(oldestKey);
|
|
32119
|
+
this.stats.evictions++;
|
|
32120
|
+
if (this.debug) {
|
|
32121
|
+
const timeSinceAccess = Date.now() - oldestAccess;
|
|
32122
|
+
console.log(
|
|
32123
|
+
`\u267B\uFE0F [${this.name}] Cache EVICT (LRU): ${String(oldestKey)} (last accessed: ${timeSinceAccess}ms ago)`
|
|
32124
|
+
);
|
|
32125
|
+
}
|
|
32126
|
+
}
|
|
32127
|
+
}
|
|
32128
|
+
/**
|
|
32129
|
+
* Get or compute value
|
|
32130
|
+
*
|
|
32131
|
+
* If key exists in cache, returns cached value.
|
|
32132
|
+
* Otherwise, computes value using provided function and caches it.
|
|
32133
|
+
*
|
|
32134
|
+
* @param key - Cache key
|
|
32135
|
+
* @param compute - Function to compute value if not in cache
|
|
32136
|
+
* @param ttl - Optional custom TTL for this entry
|
|
32137
|
+
* @returns Cached or computed value
|
|
32138
|
+
*/
|
|
32139
|
+
async getOrCompute(key2, compute, ttl) {
|
|
32140
|
+
const cached = this.get(key2);
|
|
32141
|
+
if (cached !== null) {
|
|
32142
|
+
return cached;
|
|
32143
|
+
}
|
|
32144
|
+
const value = await compute();
|
|
32145
|
+
this.set(key2, value, ttl);
|
|
32146
|
+
return value;
|
|
32147
|
+
}
|
|
32148
|
+
/**
|
|
32149
|
+
* Get or compute value with Result wrapper
|
|
32150
|
+
*/
|
|
32151
|
+
async getOrComputeResult(key2, compute, ttl) {
|
|
32152
|
+
const cached = this.get(key2);
|
|
32153
|
+
if (cached !== null) {
|
|
32154
|
+
return success(cached);
|
|
32155
|
+
}
|
|
32156
|
+
const result = await compute();
|
|
32157
|
+
if (result.success) {
|
|
32158
|
+
this.set(key2, result.value, ttl);
|
|
32159
|
+
}
|
|
32160
|
+
return result;
|
|
31967
32161
|
}
|
|
31968
32162
|
};
|
|
31969
32163
|
var CacheManager = class {
|
|
31970
32164
|
caches = /* @__PURE__ */ new Map();
|
|
31971
|
-
|
|
31972
|
-
constructor(
|
|
31973
|
-
this.
|
|
32165
|
+
globalConfig;
|
|
32166
|
+
constructor(globalConfig = {}) {
|
|
32167
|
+
this.globalConfig = globalConfig;
|
|
31974
32168
|
}
|
|
31975
32169
|
/**
|
|
31976
|
-
*
|
|
32170
|
+
* Create or get a named cache
|
|
32171
|
+
*
|
|
32172
|
+
* @param name - Unique cache name
|
|
32173
|
+
* @param config - Optional cache-specific configuration
|
|
32174
|
+
* @returns LRU cache instance
|
|
31977
32175
|
*/
|
|
31978
32176
|
getCache(name, config) {
|
|
31979
|
-
|
|
31980
|
-
|
|
32177
|
+
const existingCache = this.caches.get(name);
|
|
32178
|
+
if (existingCache) {
|
|
32179
|
+
return existingCache;
|
|
31981
32180
|
}
|
|
31982
|
-
const
|
|
32181
|
+
const mergedConfig = {
|
|
32182
|
+
...this.globalConfig,
|
|
32183
|
+
...config,
|
|
32184
|
+
name
|
|
32185
|
+
};
|
|
32186
|
+
const cache = new LRUCache(mergedConfig);
|
|
31983
32187
|
this.caches.set(name, cache);
|
|
31984
|
-
if (this.debug) {
|
|
31985
|
-
console.log(`[CacheManager] Created cache: ${name}`, config);
|
|
31986
|
-
}
|
|
31987
32188
|
return cache;
|
|
31988
32189
|
}
|
|
31989
32190
|
/**
|
|
@@ -31998,11 +32199,11 @@ var CacheManager = class {
|
|
|
31998
32199
|
* Clean expired entries from all caches
|
|
31999
32200
|
*/
|
|
32000
32201
|
cleanAllExpired() {
|
|
32001
|
-
let
|
|
32202
|
+
let totalCleaned = 0;
|
|
32002
32203
|
for (const cache of this.caches.values()) {
|
|
32003
|
-
|
|
32204
|
+
totalCleaned += cache.cleanExpired();
|
|
32004
32205
|
}
|
|
32005
|
-
return
|
|
32206
|
+
return totalCleaned;
|
|
32006
32207
|
}
|
|
32007
32208
|
/**
|
|
32008
32209
|
* Get statistics for all caches
|
|
@@ -32015,11 +32216,16 @@ var CacheManager = class {
|
|
|
32015
32216
|
return stats;
|
|
32016
32217
|
}
|
|
32017
32218
|
/**
|
|
32018
|
-
*
|
|
32219
|
+
* Get list of all cache names
|
|
32019
32220
|
*/
|
|
32020
|
-
|
|
32021
|
-
this.
|
|
32022
|
-
|
|
32221
|
+
getCacheNames() {
|
|
32222
|
+
return Array.from(this.caches.keys());
|
|
32223
|
+
}
|
|
32224
|
+
/**
|
|
32225
|
+
* Delete a named cache
|
|
32226
|
+
*/
|
|
32227
|
+
deleteCache(name) {
|
|
32228
|
+
return this.caches.delete(name);
|
|
32023
32229
|
}
|
|
32024
32230
|
};
|
|
32025
32231
|
function createCacheManager(config) {
|
|
@@ -32977,6 +33183,10 @@ var LoanCreator = class {
|
|
|
32977
33183
|
ethers_exports.utils.hexlify(BigInt(pkpData.tokenId)),
|
|
32978
33184
|
32
|
|
32979
33185
|
);
|
|
33186
|
+
const pkpPublicKeyUncompressed = ethers_exports.utils.computePublicKey(
|
|
33187
|
+
pkpData.publicKey,
|
|
33188
|
+
false
|
|
33189
|
+
);
|
|
32980
33190
|
console.log("\n\u{1F50D} PKP TOKEN ID CONVERSION TRACE (SDK):");
|
|
32981
33191
|
console.log("==========================================");
|
|
32982
33192
|
console.log(
|
|
@@ -33027,7 +33237,8 @@ var LoanCreator = class {
|
|
|
33027
33237
|
mainnetVaultAddress,
|
|
33028
33238
|
regtestVaultAddress,
|
|
33029
33239
|
request.selectedTerm,
|
|
33030
|
-
validatorVersion
|
|
33240
|
+
validatorVersion,
|
|
33241
|
+
pkpPublicKeyUncompressed
|
|
33031
33242
|
]);
|
|
33032
33243
|
console.log("\u{1F50D} ENCODED CALLDATA (first 256 chars):", encoded.substring(0, 256));
|
|
33033
33244
|
console.log("\u{1F50D} ENCODED CALLDATA full length:", encoded.length);
|
|
@@ -33040,7 +33251,8 @@ var LoanCreator = class {
|
|
|
33040
33251
|
mainnetVaultAddress,
|
|
33041
33252
|
regtestVaultAddress,
|
|
33042
33253
|
request.selectedTerm,
|
|
33043
|
-
validatorVersion
|
|
33254
|
+
validatorVersion,
|
|
33255
|
+
pkpPublicKeyUncompressed
|
|
33044
33256
|
);
|
|
33045
33257
|
if (!tx) {
|
|
33046
33258
|
return failure(
|
|
@@ -33592,8 +33804,8 @@ var LoanQuery = class {
|
|
|
33592
33804
|
batch.map(async (loan) => {
|
|
33593
33805
|
try {
|
|
33594
33806
|
const rawId = loan.pkpId?.startsWith("0x") ? loan.pkpId.slice(2) : loan.pkpId;
|
|
33595
|
-
const
|
|
33596
|
-
if (
|
|
33807
|
+
const isChipotlePkpId2 = typeof rawId === "string" && rawId.length === 40 && !rawId.toLowerCase().startsWith("04");
|
|
33808
|
+
if (isChipotlePkpId2) {
|
|
33597
33809
|
if (this.config.positionManagerCoreAddress && this.config.provider) {
|
|
33598
33810
|
const pmContract = new ethers_exports.Contract(
|
|
33599
33811
|
this.config.positionManagerCoreAddress,
|
|
@@ -36210,7 +36422,7 @@ var DiamondHandsGraph = class {
|
|
|
36210
36422
|
}
|
|
36211
36423
|
|
|
36212
36424
|
${shouldQuery.mint ? `
|
|
36213
|
-
|
|
36425
|
+
ucdmintEvents(
|
|
36214
36426
|
${buildPositionWhereClause()}
|
|
36215
36427
|
first: $limit,
|
|
36216
36428
|
orderBy: timestamp,
|
|
@@ -36399,7 +36611,7 @@ var DiamondHandsGraph = class {
|
|
|
36399
36611
|
commitTimestamp: result.position.liquidation.commitTimestamp,
|
|
36400
36612
|
revealDelay: result.position.liquidation.revealDelay
|
|
36401
36613
|
} : void 0;
|
|
36402
|
-
const mints = (result.
|
|
36614
|
+
const mints = (result.ucdmintEvents || []).map((m) => ({
|
|
36403
36615
|
id: m.id,
|
|
36404
36616
|
positionId,
|
|
36405
36617
|
amount: m.amount,
|
|
@@ -36743,7 +36955,7 @@ function formatLoanCreationMessage(positionId, pkpId, vaultAddress) {
|
|
|
36743
36955
|
}
|
|
36744
36956
|
function formatBTCWithdrawalFailureMessage(withdrawalAmount, btcVault, btcDestinationAddress, loanId) {
|
|
36745
36957
|
const formattedAmount = formatBTCAmount(withdrawalAmount);
|
|
36746
|
-
return
|
|
36958
|
+
return `\u274C BTC withdrawal FAILED: ${formattedAmount} from ${btcVault} to ${btcDestinationAddress} for loan id: ${loanId}`;
|
|
36747
36959
|
}
|
|
36748
36960
|
function formatLoanRenewalMessage(positionId, txHash) {
|
|
36749
36961
|
return `Loan id ${positionId} was successfully renewed. Tx: https://sepolia.etherscan.io/tx/${txHash}`;
|
|
@@ -36757,9 +36969,10 @@ function formatBalanceConfirmationMessage(loanId) {
|
|
|
36757
36969
|
function formatBalanceConfirmationFailureMessage(loanId) {
|
|
36758
36970
|
return `FAILED to update to PENDING_MINT for loan id ${loanId}`;
|
|
36759
36971
|
}
|
|
36760
|
-
function formatBTCWithdrawalSuccessMessage(withdrawalAmount, btcVault, btcDestinationAddress, loanId) {
|
|
36972
|
+
function formatBTCWithdrawalSuccessMessage(withdrawalAmount, btcVault, btcDestinationAddress, loanId, btcTxId) {
|
|
36761
36973
|
const formattedAmount = formatBTCAmount(withdrawalAmount);
|
|
36762
|
-
|
|
36974
|
+
const txSuffix = btcTxId ? ` (tx: ${btcTxId})` : "";
|
|
36975
|
+
return `\u2705 BTC withdrawal SUCCEEDED: ${formattedAmount} sent from ${btcVault} to ${btcDestinationAddress} for loan id: ${loanId}${txSuffix}`;
|
|
36763
36976
|
}
|
|
36764
36977
|
function formatLiquidationSkippedMessage(loanId, ratio, threshold, btcVault, btcVaultBalance, ucdDebt, btcPrice) {
|
|
36765
36978
|
const formattedPrice = formatBTCPrice(btcPrice);
|
|
@@ -37003,12 +37216,6 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37003
37216
|
* @param config - SDK configuration
|
|
37004
37217
|
*/
|
|
37005
37218
|
constructor(config) {
|
|
37006
|
-
console.log(
|
|
37007
|
-
"[DEBUG] Constructor START - config keys:",
|
|
37008
|
-
Object.keys(config),
|
|
37009
|
-
"serviceEndpoint:",
|
|
37010
|
-
config["serviceEndpoint"]
|
|
37011
|
-
);
|
|
37012
37219
|
if (!config.provider && config.ethRpcUrl) {
|
|
37013
37220
|
config.provider = new ethers_exports.providers.JsonRpcProvider(config.ethRpcUrl);
|
|
37014
37221
|
}
|
|
@@ -37019,12 +37226,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37019
37226
|
network: config.litNetwork
|
|
37020
37227
|
});
|
|
37021
37228
|
}
|
|
37022
|
-
console.log("[DEBUG] Before CacheManager init");
|
|
37023
37229
|
this.cacheManager = new CacheManager({
|
|
37024
37230
|
debug: config.debug
|
|
37025
37231
|
});
|
|
37026
|
-
console.log("[DEBUG] After CacheManager init");
|
|
37027
|
-
console.log("[DEBUG] Before ContractManager init");
|
|
37028
37232
|
const contractManagerResult = createContractManager({
|
|
37029
37233
|
provider: config.provider,
|
|
37030
37234
|
signer: config.contractSigner,
|
|
@@ -37204,17 +37408,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37204
37408
|
*/
|
|
37205
37409
|
static async create(config) {
|
|
37206
37410
|
const userProvidedServiceEndpoint = config.serviceEndpoint;
|
|
37207
|
-
console.log(
|
|
37208
|
-
"[DEBUG] DiamondHandsSDK.create - userProvidedServiceEndpoint:",
|
|
37209
|
-
userProvidedServiceEndpoint
|
|
37210
|
-
);
|
|
37211
37411
|
const enrichedConfig = await _DiamondHandsSDK.enrichConfigWithNetworkDefaults(config);
|
|
37212
37412
|
if (userProvidedServiceEndpoint) {
|
|
37213
37413
|
enrichedConfig.serviceEndpoint = userProvidedServiceEndpoint;
|
|
37214
|
-
console.log(
|
|
37215
|
-
"[DEBUG] DiamondHandsSDK.create - restored userProvidedServiceEndpoint:",
|
|
37216
|
-
userProvidedServiceEndpoint
|
|
37217
|
-
);
|
|
37218
37414
|
}
|
|
37219
37415
|
const configError = validateSDKConfig(enrichedConfig);
|
|
37220
37416
|
if (configError) {
|
|
@@ -37254,10 +37450,6 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37254
37450
|
*/
|
|
37255
37451
|
static async enrichConfigWithNetworkDefaults(config) {
|
|
37256
37452
|
const { getNetworkConfig: getNetworkConfig2, getNetworkConfigByName: getNetworkConfigByName2 } = await Promise.resolve().then(() => (init_network_configs(), network_configs_exports));
|
|
37257
|
-
console.log(
|
|
37258
|
-
"[DEBUG] enrichConfigWithNetworkDefaults - input config.serviceEndpoint:",
|
|
37259
|
-
config.serviceEndpoint
|
|
37260
|
-
);
|
|
37261
37453
|
let chainId = config.chainId;
|
|
37262
37454
|
if (!chainId) {
|
|
37263
37455
|
try {
|
|
@@ -37342,9 +37534,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37342
37534
|
...config.contractAddresses || {}
|
|
37343
37535
|
// User-provided individual overrides (only specified fields)
|
|
37344
37536
|
};
|
|
37345
|
-
|
|
37346
|
-
"[SDK] enrichConfigWithNetworkDefaults - contractAddresses after merge",
|
|
37347
|
-
{
|
|
37537
|
+
if (config.debug) {
|
|
37538
|
+
log.info("[SDK] enrichConfigWithNetworkDefaults - contractAddresses after merge", {
|
|
37348
37539
|
keys: Object.keys(enrichedConfig.contractAddresses || {}),
|
|
37349
37540
|
hasPositionManager: !!enrichedConfig.contractAddresses?.positionManager,
|
|
37350
37541
|
hasLoanOperationsManager: !!enrichedConfig.contractAddresses?.loanOperationsManager,
|
|
@@ -37354,8 +37545,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37354
37545
|
loanOperationsManager: enrichedConfig.contractAddresses?.loanOperationsManager || "MISSING",
|
|
37355
37546
|
termManager: enrichedConfig.contractAddresses?.termManager || "MISSING",
|
|
37356
37547
|
ucdController: enrichedConfig.contractAddresses?.ucdController || "MISSING"
|
|
37357
|
-
}
|
|
37358
|
-
|
|
37548
|
+
});
|
|
37549
|
+
}
|
|
37359
37550
|
if (config.debug) {
|
|
37360
37551
|
log.info("\u2705 Contract addresses loaded from network config", {
|
|
37361
37552
|
overridden: Object.keys(config.contractAddresses || {}).length,
|
|
@@ -37374,10 +37565,6 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37374
37565
|
});
|
|
37375
37566
|
}
|
|
37376
37567
|
}
|
|
37377
|
-
console.log(
|
|
37378
|
-
"[DEBUG] enrichConfigWithNetworkDefaults - output config.serviceEndpoint:",
|
|
37379
|
-
enrichedConfig.serviceEndpoint
|
|
37380
|
-
);
|
|
37381
37568
|
if (!enrichedConfig.validators) {
|
|
37382
37569
|
enrichedConfig.validators = {
|
|
37383
37570
|
loanCreation: 1,
|
|
@@ -37825,7 +38012,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37825
38012
|
pkpPublicKey = await getPKPPublicKeyFromTokenId(
|
|
37826
38013
|
position2.pkpId,
|
|
37827
38014
|
this.getProviderOrThrow(),
|
|
37828
|
-
nagaPkpNftAddress
|
|
38015
|
+
nagaPkpNftAddress,
|
|
38016
|
+
this.getChipotlePublicKeyFallback()
|
|
37829
38017
|
);
|
|
37830
38018
|
pkpEthAddress = ethers_exports.utils.computeAddress(pkpPublicKey);
|
|
37831
38019
|
pkpCache.set(request.positionId, {
|
|
@@ -38928,7 +39116,8 @@ Error data: ${errorData || "none"}`
|
|
|
38928
39116
|
const pkpPublicKey = await getPKPPublicKeyFromTokenId(
|
|
38929
39117
|
position.pkpId,
|
|
38930
39118
|
this.getProviderOrThrow(),
|
|
38931
|
-
nagaPkpNftAddressLiq
|
|
39119
|
+
nagaPkpNftAddressLiq,
|
|
39120
|
+
this.getChipotlePublicKeyFallback()
|
|
38932
39121
|
);
|
|
38933
39122
|
const pkpEthAddress = ethers_exports.utils.computeAddress(pkpPublicKey);
|
|
38934
39123
|
pkpData = {
|
|
@@ -40869,11 +41058,13 @@ Error data: ${errorData || "none"}`
|
|
|
40869
41058
|
transactionHash: transactionHash || "none"
|
|
40870
41059
|
});
|
|
40871
41060
|
}
|
|
40872
|
-
|
|
40873
|
-
error:
|
|
40874
|
-
|
|
40875
|
-
|
|
40876
|
-
|
|
41061
|
+
if (this.config.debug) {
|
|
41062
|
+
log.error("\u274C PAYMENT ERROR:", {
|
|
41063
|
+
error: errorMsg,
|
|
41064
|
+
errorType: typeof error,
|
|
41065
|
+
transactionHash: transactionHash || "none"
|
|
41066
|
+
});
|
|
41067
|
+
}
|
|
40877
41068
|
if (this.config.debug) {
|
|
40878
41069
|
log.error("\u274C Payment failed", {
|
|
40879
41070
|
transactionHash: transactionHash || "not available",
|
|
@@ -41009,7 +41200,8 @@ Error data: ${errorData || "none"}`
|
|
|
41009
41200
|
pkpPublicKey = await getPKPPublicKeyFromTokenId(
|
|
41010
41201
|
position.pkpId,
|
|
41011
41202
|
this.getProviderOrThrow(),
|
|
41012
|
-
nagaPkpNftAddress
|
|
41203
|
+
nagaPkpNftAddress,
|
|
41204
|
+
this.getChipotlePublicKeyFallback()
|
|
41013
41205
|
);
|
|
41014
41206
|
pkpEthAddress = ethers_exports.utils.computeAddress(pkpPublicKey);
|
|
41015
41207
|
pkpCache.set(positionId, {
|
|
@@ -41479,22 +41671,6 @@ Error data: ${errorData || "none"}`
|
|
|
41479
41671
|
gasUsed: receipt.gasUsed?.toString() || "unknown"
|
|
41480
41672
|
});
|
|
41481
41673
|
}
|
|
41482
|
-
try {
|
|
41483
|
-
const position = await this.getPosition(positionId);
|
|
41484
|
-
const btcAmount = (Number(withdrawalAmount) / 1e8).toFixed(8);
|
|
41485
|
-
const message = formatBTCWithdrawalSuccessMessage(
|
|
41486
|
-
btcAmount,
|
|
41487
|
-
position?.vaultAddress || "unknown",
|
|
41488
|
-
validationResponse.destinationAddress,
|
|
41489
|
-
positionId
|
|
41490
|
-
);
|
|
41491
|
-
await this._relayNotification(message);
|
|
41492
|
-
} catch (telegramError) {
|
|
41493
|
-
console.error(
|
|
41494
|
-
"Telegram notification failed:",
|
|
41495
|
-
telegramError instanceof Error ? telegramError.message : String(telegramError)
|
|
41496
|
-
);
|
|
41497
|
-
}
|
|
41498
41674
|
return {
|
|
41499
41675
|
success: true,
|
|
41500
41676
|
positionId,
|
|
@@ -41667,7 +41843,8 @@ Error data: ${errorData || "none"}`
|
|
|
41667
41843
|
pkpPublicKey = await getPKPPublicKeyFromTokenId(
|
|
41668
41844
|
pkpId,
|
|
41669
41845
|
this.getProviderOrThrow(),
|
|
41670
|
-
nagaPkpNftAddress
|
|
41846
|
+
nagaPkpNftAddress,
|
|
41847
|
+
this.getChipotlePublicKeyFallback()
|
|
41671
41848
|
);
|
|
41672
41849
|
pkpCache.set(request.positionId, {
|
|
41673
41850
|
publicKey: pkpPublicKey,
|
|
@@ -42383,6 +42560,27 @@ Error data: ${errorData || "none"}`
|
|
|
42383
42560
|
txid: executionResult.txid
|
|
42384
42561
|
});
|
|
42385
42562
|
}
|
|
42563
|
+
try {
|
|
42564
|
+
const btcAmount = (Number(withdrawalAmount) / 1e8).toFixed(8);
|
|
42565
|
+
const message = executionResult.success ? formatBTCWithdrawalSuccessMessage(
|
|
42566
|
+
btcAmount,
|
|
42567
|
+
vaultAddress,
|
|
42568
|
+
withdrawalAddress,
|
|
42569
|
+
positionId,
|
|
42570
|
+
executionResult.txid
|
|
42571
|
+
) : formatBTCWithdrawalFailureMessage(
|
|
42572
|
+
btcAmount,
|
|
42573
|
+
vaultAddress,
|
|
42574
|
+
withdrawalAddress,
|
|
42575
|
+
positionId
|
|
42576
|
+
);
|
|
42577
|
+
await this._relayNotification(message);
|
|
42578
|
+
} catch (telegramError) {
|
|
42579
|
+
console.error(
|
|
42580
|
+
"Telegram notification failed:",
|
|
42581
|
+
telegramError instanceof Error ? telegramError.message : String(telegramError)
|
|
42582
|
+
);
|
|
42583
|
+
}
|
|
42386
42584
|
const transfers = [
|
|
42387
42585
|
{
|
|
42388
42586
|
success: executionResult.success,
|
|
@@ -42790,6 +42988,19 @@ Error data: ${errorData || "none"}`
|
|
|
42790
42988
|
// ============================================================================
|
|
42791
42989
|
// PRIVATE HELPER METHODS
|
|
42792
42990
|
// ============================================================================
|
|
42991
|
+
/**
|
|
42992
|
+
* Build the Chipotle service-mode fallback config for getPKPPublicKeyFromTokenId.
|
|
42993
|
+
* Returns undefined in standalone mode so the helper falls back to throwing.
|
|
42994
|
+
*/
|
|
42995
|
+
getChipotlePublicKeyFallback() {
|
|
42996
|
+
if (!this.config.serviceEndpoint)
|
|
42997
|
+
return void 0;
|
|
42998
|
+
return {
|
|
42999
|
+
serviceEndpoint: this.config.serviceEndpoint,
|
|
43000
|
+
serviceAuthToken: this.config.serviceAuthToken,
|
|
43001
|
+
debug: this.config.debug
|
|
43002
|
+
};
|
|
43003
|
+
}
|
|
42793
43004
|
/**
|
|
42794
43005
|
* Get provider or throw error
|
|
42795
43006
|
*/
|