@gvnrdao/dh-sdk 0.0.161 → 0.0.162
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/browser.js +5 -5
- package/dist/index.js +86 -316
- package/dist/index.mjs +86 -316
- package/package.json +5 -5
- package/browser/dist/browser/index.d.ts +0 -8
- package/browser/dist/browser/index.d.ts.map +0 -1
- package/browser/dist/browser/index.js +0 -24
- package/browser/dist/dist/index.d.ts +0 -3
- package/browser/dist/dist/index.d.ts.map +0 -1
- package/browser/dist/dist/index.js +0 -40174
package/dist/index.mjs
CHANGED
|
@@ -12751,45 +12751,47 @@ var init_deployment_addresses = __esm({
|
|
|
12751
12751
|
};
|
|
12752
12752
|
LOCALHOST_DEPLOYMENT = {
|
|
12753
12753
|
network: "localhost",
|
|
12754
|
-
chainId:
|
|
12755
|
-
timestamp: "2026-02-
|
|
12756
|
-
deployer: "
|
|
12754
|
+
chainId: 31337,
|
|
12755
|
+
timestamp: "2026-02-16T15:23:50.854Z",
|
|
12756
|
+
deployer: "",
|
|
12757
12757
|
contracts: {
|
|
12758
|
-
UpgradeValidator: "
|
|
12758
|
+
UpgradeValidator: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
|
|
12759
12759
|
UCDToken: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
12760
12760
|
UCDController: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
12761
|
-
PriceFeedConsumer: "
|
|
12762
|
-
UCDMintingRewards: "
|
|
12763
|
-
PositionManagerCoreModule: "
|
|
12764
|
-
TermManagerModule: "
|
|
12765
|
-
LoanOperationsManagerModule: "
|
|
12766
|
-
CollateralManagerModule: "
|
|
12767
|
-
LiquidationManagerModule: "
|
|
12768
|
-
CircuitBreakerModule: "
|
|
12769
|
-
CommunityManagerModule: "
|
|
12770
|
-
AdminModule: "
|
|
12771
|
-
PositionManagerViews: "
|
|
12772
|
-
PositionManager: "
|
|
12773
|
-
OperationAuthorizationRegistry: "
|
|
12761
|
+
PriceFeedConsumer: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
12762
|
+
UCDMintingRewards: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
|
|
12763
|
+
PositionManagerCoreModule: "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
|
|
12764
|
+
TermManagerModule: "0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE",
|
|
12765
|
+
LoanOperationsManagerModule: "0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1",
|
|
12766
|
+
CollateralManagerModule: "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
|
|
12767
|
+
LiquidationManagerModule: "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
|
|
12768
|
+
CircuitBreakerModule: "0x3Aa5ebB10DC797CAC828524e59A333d0A371443c",
|
|
12769
|
+
CommunityManagerModule: "0xc5a5C42992dECbae36851359345FE25997F5C42d",
|
|
12770
|
+
AdminModule: "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
|
|
12771
|
+
PositionManagerViews: "0xc6e7DF5E7b4f2A278906862b61205850344D4e7d",
|
|
12772
|
+
PositionManager: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
|
|
12773
|
+
OperationAuthorizationRegistry: "0x9d4454B023096f34B160D6B654540c56A1F81688",
|
|
12774
|
+
PKPValidation: "0x4c5859f0F772848b2D91F1D83E2Fe57935348029"
|
|
12774
12775
|
}
|
|
12775
12776
|
};
|
|
12776
12777
|
LOCALHOST_CONTRACTS = {
|
|
12777
|
-
UpgradeValidator: "
|
|
12778
|
+
UpgradeValidator: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
|
|
12778
12779
|
UCDToken: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
12779
12780
|
UCDController: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
12780
|
-
PriceFeedConsumer: "
|
|
12781
|
-
UCDMintingRewards: "
|
|
12782
|
-
PositionManagerCoreModule: "
|
|
12783
|
-
TermManagerModule: "
|
|
12784
|
-
LoanOperationsManagerModule: "
|
|
12785
|
-
CollateralManagerModule: "
|
|
12786
|
-
LiquidationManagerModule: "
|
|
12787
|
-
CircuitBreakerModule: "
|
|
12788
|
-
CommunityManagerModule: "
|
|
12789
|
-
AdminModule: "
|
|
12790
|
-
PositionManagerViews: "
|
|
12791
|
-
PositionManager: "
|
|
12792
|
-
OperationAuthorizationRegistry: "
|
|
12781
|
+
PriceFeedConsumer: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
12782
|
+
UCDMintingRewards: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
|
|
12783
|
+
PositionManagerCoreModule: "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
|
|
12784
|
+
TermManagerModule: "0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE",
|
|
12785
|
+
LoanOperationsManagerModule: "0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1",
|
|
12786
|
+
CollateralManagerModule: "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
|
|
12787
|
+
LiquidationManagerModule: "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
|
|
12788
|
+
CircuitBreakerModule: "0x3Aa5ebB10DC797CAC828524e59A333d0A371443c",
|
|
12789
|
+
CommunityManagerModule: "0xc5a5C42992dECbae36851359345FE25997F5C42d",
|
|
12790
|
+
AdminModule: "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
|
|
12791
|
+
PositionManagerViews: "0xc6e7DF5E7b4f2A278906862b61205850344D4e7d",
|
|
12792
|
+
PositionManager: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
|
|
12793
|
+
OperationAuthorizationRegistry: "0x9d4454B023096f34B160D6B654540c56A1F81688",
|
|
12794
|
+
PKPValidation: "0x4c5859f0F772848b2D91F1D83E2Fe57935348029"
|
|
12793
12795
|
};
|
|
12794
12796
|
ALL_DEPLOYMENTS = {
|
|
12795
12797
|
sepolia: SEPOLIA_DEPLOYMENT,
|
|
@@ -12935,7 +12937,7 @@ function getSepoliaConfig() {
|
|
|
12935
12937
|
operationAuthorizationRegistry: SEPOLIA_CONTRACTS.OperationAuthorizationRegistry || ""
|
|
12936
12938
|
},
|
|
12937
12939
|
subgraphs: {
|
|
12938
|
-
diamondHandsUrl: "https://api.studio.thegraph.com/query/65258/diamond-hands/v0.6.
|
|
12940
|
+
diamondHandsUrl: "https://api.studio.thegraph.com/query/65258/diamond-hands/v0.6.19"
|
|
12939
12941
|
},
|
|
12940
12942
|
// litNetwork: "datil-test",
|
|
12941
12943
|
debug: true
|
|
@@ -13045,7 +13047,7 @@ function getLocalhostConfig() {
|
|
|
13045
13047
|
)
|
|
13046
13048
|
},
|
|
13047
13049
|
subgraphs: {
|
|
13048
|
-
diamondHandsUrl: "https://api.studio.thegraph.com/query/65258/diamond-hands/v0.6.
|
|
13050
|
+
diamondHandsUrl: "https://api.studio.thegraph.com/query/65258/diamond-hands/v0.6.19"
|
|
13049
13051
|
},
|
|
13050
13052
|
litNetwork: "datil",
|
|
13051
13053
|
debug: true
|
|
@@ -29848,333 +29850,106 @@ function createContractManager(config) {
|
|
|
29848
29850
|
}
|
|
29849
29851
|
|
|
29850
29852
|
// src/modules/cache/cache-manager.module.ts
|
|
29851
|
-
var
|
|
29852
|
-
cache;
|
|
29853
|
+
var Cache = class {
|
|
29854
|
+
cache = /* @__PURE__ */ new Map();
|
|
29853
29855
|
maxSize;
|
|
29854
29856
|
ttlMs;
|
|
29855
|
-
|
|
29856
|
-
|
|
29857
|
-
|
|
29858
|
-
stats = {
|
|
29859
|
-
hits: 0,
|
|
29860
|
-
misses: 0,
|
|
29861
|
-
evictions: 0
|
|
29862
|
-
};
|
|
29863
|
-
constructor(config = {}) {
|
|
29864
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
29865
|
-
this.maxSize = config.maxSize || 1e3;
|
|
29866
|
-
this.ttlMs = config.ttlMs || 6e4;
|
|
29867
|
-
this.debug = config.debug || false;
|
|
29868
|
-
this.name = config.name || "Cache";
|
|
29869
|
-
if (this.debug) {
|
|
29870
|
-
console.log(
|
|
29871
|
-
`\u{1F4BE} [${this.name}] Initialized: maxSize=${this.maxSize}, ttl=${this.ttlMs}ms`
|
|
29872
|
-
);
|
|
29873
|
-
}
|
|
29857
|
+
constructor(config) {
|
|
29858
|
+
this.maxSize = config.maxSize;
|
|
29859
|
+
this.ttlMs = config.ttlMs;
|
|
29874
29860
|
}
|
|
29875
29861
|
/**
|
|
29876
29862
|
* Get value from cache
|
|
29877
|
-
*
|
|
29878
|
-
* Returns null if:
|
|
29879
|
-
* - Key not found
|
|
29880
|
-
* - Entry has expired
|
|
29881
|
-
*
|
|
29882
|
-
* @param key - Cache key
|
|
29883
|
-
* @returns Cached value or null
|
|
29884
29863
|
*/
|
|
29885
29864
|
get(key2) {
|
|
29886
29865
|
const entry = this.cache.get(key2);
|
|
29887
29866
|
if (!entry) {
|
|
29888
|
-
|
|
29889
|
-
if (this.debug) {
|
|
29890
|
-
console.log(`\u274C [${this.name}] Cache MISS: ${String(key2)}`);
|
|
29891
|
-
}
|
|
29892
|
-
return null;
|
|
29867
|
+
return void 0;
|
|
29893
29868
|
}
|
|
29894
|
-
|
|
29869
|
+
const now2 = Date.now();
|
|
29870
|
+
if (now2 - entry.timestamp > entry.ttl) {
|
|
29895
29871
|
this.cache.delete(key2);
|
|
29896
|
-
|
|
29897
|
-
if (this.debug) {
|
|
29898
|
-
const age = Date.now() - entry.timestamp;
|
|
29899
|
-
console.log(`\u23F0 [${this.name}] Cache EXPIRED: ${String(key2)} (age: ${age}ms)`);
|
|
29900
|
-
}
|
|
29901
|
-
return null;
|
|
29902
|
-
}
|
|
29903
|
-
entry.hits++;
|
|
29904
|
-
entry.lastAccessed = Date.now();
|
|
29905
|
-
this.cache.set(key2, entry);
|
|
29906
|
-
this.stats.hits++;
|
|
29907
|
-
if (this.debug) {
|
|
29908
|
-
const age = Date.now() - entry.timestamp;
|
|
29909
|
-
console.log(
|
|
29910
|
-
`\u2705 [${this.name}] Cache HIT: ${String(key2)} (age: ${age}ms, hits: ${entry.hits})`
|
|
29911
|
-
);
|
|
29872
|
+
return void 0;
|
|
29912
29873
|
}
|
|
29913
29874
|
return entry.value;
|
|
29914
29875
|
}
|
|
29915
|
-
/**
|
|
29916
|
-
* Get value from cache with Result wrapper
|
|
29917
|
-
*
|
|
29918
|
-
* Useful when you want to distinguish between "not found" and "expired"
|
|
29919
|
-
*/
|
|
29920
|
-
getResult(key2) {
|
|
29921
|
-
const value = this.get(key2);
|
|
29922
|
-
if (value === null) {
|
|
29923
|
-
return failure(
|
|
29924
|
-
new SDKError({
|
|
29925
|
-
message: `Cache miss for key: ${String(key2)}`,
|
|
29926
|
-
category: "CACHE" /* CACHE */,
|
|
29927
|
-
severity: "LOW" /* LOW */,
|
|
29928
|
-
originalError: new Error("Cache miss")
|
|
29929
|
-
})
|
|
29930
|
-
);
|
|
29931
|
-
}
|
|
29932
|
-
return success(value);
|
|
29933
|
-
}
|
|
29934
29876
|
/**
|
|
29935
29877
|
* Set value in cache
|
|
29936
|
-
*
|
|
29937
|
-
* If cache is full, evicts the least recently used entry
|
|
29938
|
-
*
|
|
29939
|
-
* @param key - Cache key
|
|
29940
|
-
* @param value - Value to cache
|
|
29941
|
-
* @param ttl - Optional custom TTL for this entry (ms)
|
|
29942
29878
|
*/
|
|
29943
29879
|
set(key2, value, ttl) {
|
|
29944
29880
|
if (this.cache.size >= this.maxSize && !this.cache.has(key2)) {
|
|
29945
|
-
this.
|
|
29881
|
+
const firstKey = this.cache.keys().next().value;
|
|
29882
|
+
if (firstKey) {
|
|
29883
|
+
this.cache.delete(firstKey);
|
|
29884
|
+
}
|
|
29946
29885
|
}
|
|
29947
|
-
|
|
29886
|
+
this.cache.set(key2, {
|
|
29948
29887
|
value,
|
|
29949
29888
|
timestamp: Date.now(),
|
|
29950
|
-
|
|
29951
|
-
|
|
29952
|
-
};
|
|
29953
|
-
this.cache.set(key2, entry);
|
|
29954
|
-
if (this.debug) {
|
|
29955
|
-
const effectiveTtl = ttl || this.ttlMs;
|
|
29956
|
-
console.log(
|
|
29957
|
-
`\u{1F4BE} [${this.name}] Cache SET: ${String(key2)} (ttl: ${effectiveTtl}ms, size: ${this.cache.size}/${this.maxSize})`
|
|
29958
|
-
);
|
|
29959
|
-
}
|
|
29960
|
-
}
|
|
29961
|
-
/**
|
|
29962
|
-
* Set value in cache with Result wrapper
|
|
29963
|
-
*/
|
|
29964
|
-
setResult(key2, value, ttl) {
|
|
29965
|
-
try {
|
|
29966
|
-
this.set(key2, value, ttl);
|
|
29967
|
-
return success(void 0);
|
|
29968
|
-
} catch (error) {
|
|
29969
|
-
return failure(
|
|
29970
|
-
new SDKError({
|
|
29971
|
-
message: `Failed to set cache value for key: ${String(key2)}`,
|
|
29972
|
-
category: "CACHE" /* CACHE */,
|
|
29973
|
-
severity: "MEDIUM" /* MEDIUM */,
|
|
29974
|
-
originalError: error instanceof Error ? error : new Error(String(error))
|
|
29975
|
-
})
|
|
29976
|
-
);
|
|
29977
|
-
}
|
|
29889
|
+
ttl: ttl || this.ttlMs
|
|
29890
|
+
});
|
|
29978
29891
|
}
|
|
29979
29892
|
/**
|
|
29980
|
-
* Check if key exists in cache
|
|
29893
|
+
* Check if key exists in cache
|
|
29981
29894
|
*/
|
|
29982
29895
|
has(key2) {
|
|
29983
|
-
|
|
29984
|
-
return entry !== void 0 && !this.isExpired(entry);
|
|
29896
|
+
return this.get(key2) !== void 0;
|
|
29985
29897
|
}
|
|
29986
29898
|
/**
|
|
29987
|
-
* Delete
|
|
29899
|
+
* Delete key from cache
|
|
29988
29900
|
*/
|
|
29989
29901
|
delete(key2) {
|
|
29990
|
-
|
|
29991
|
-
if (deleted && this.debug) {
|
|
29992
|
-
console.log(`\u{1F5D1}\uFE0F [${this.name}] Cache DELETE: ${String(key2)}`);
|
|
29993
|
-
}
|
|
29994
|
-
return deleted;
|
|
29902
|
+
return this.cache.delete(key2);
|
|
29995
29903
|
}
|
|
29996
29904
|
/**
|
|
29997
|
-
* Clear
|
|
29905
|
+
* Clear all cache entries
|
|
29998
29906
|
*/
|
|
29999
29907
|
clear() {
|
|
30000
|
-
const previousSize = this.cache.size;
|
|
30001
29908
|
this.cache.clear();
|
|
30002
|
-
this.stats = {
|
|
30003
|
-
hits: 0,
|
|
30004
|
-
misses: 0,
|
|
30005
|
-
evictions: 0
|
|
30006
|
-
};
|
|
30007
|
-
if (this.debug) {
|
|
30008
|
-
console.log(`\u{1F9F9} [${this.name}] Cache CLEARED: removed ${previousSize} entries`);
|
|
30009
|
-
}
|
|
30010
|
-
}
|
|
30011
|
-
/**
|
|
30012
|
-
* Get current cache size
|
|
30013
|
-
*/
|
|
30014
|
-
size() {
|
|
30015
|
-
return this.cache.size;
|
|
30016
29909
|
}
|
|
30017
29910
|
/**
|
|
30018
|
-
*
|
|
30019
|
-
*/
|
|
30020
|
-
getStats() {
|
|
30021
|
-
const entries = Array.from(this.cache.values());
|
|
30022
|
-
const timestamps = entries.map((e) => e.timestamp);
|
|
30023
|
-
const total = this.stats.hits + this.stats.misses;
|
|
30024
|
-
const hitRate = total === 0 ? 0 : this.stats.hits / total * 100;
|
|
30025
|
-
return {
|
|
30026
|
-
size: this.cache.size,
|
|
30027
|
-
hits: this.stats.hits,
|
|
30028
|
-
misses: this.stats.misses,
|
|
30029
|
-
evictions: this.stats.evictions,
|
|
30030
|
-
oldestEntry: timestamps.length > 0 ? Math.min(...timestamps) : 0,
|
|
30031
|
-
newestEntry: timestamps.length > 0 ? Math.max(...timestamps) : 0,
|
|
30032
|
-
hitRate
|
|
30033
|
-
};
|
|
30034
|
-
}
|
|
30035
|
-
/**
|
|
30036
|
-
* Get hit rate percentage
|
|
30037
|
-
*/
|
|
30038
|
-
getHitRate() {
|
|
30039
|
-
const total = this.stats.hits + this.stats.misses;
|
|
30040
|
-
return total === 0 ? 0 : this.stats.hits / total * 100;
|
|
30041
|
-
}
|
|
30042
|
-
/**
|
|
30043
|
-
* Get all cached keys (for debugging)
|
|
30044
|
-
*/
|
|
30045
|
-
getKeys() {
|
|
30046
|
-
return Array.from(this.cache.keys());
|
|
30047
|
-
}
|
|
30048
|
-
/**
|
|
30049
|
-
* Get all cached values (for debugging)
|
|
30050
|
-
*/
|
|
30051
|
-
getValues() {
|
|
30052
|
-
return Array.from(this.cache.values()).map((entry) => entry.value);
|
|
30053
|
-
}
|
|
30054
|
-
/**
|
|
30055
|
-
* Get all cache entries with metadata (for debugging)
|
|
30056
|
-
*/
|
|
30057
|
-
getEntries() {
|
|
30058
|
-
return Array.from(this.cache.entries()).map(([key2, entry]) => ({
|
|
30059
|
-
key: key2,
|
|
30060
|
-
value: entry.value,
|
|
30061
|
-
metadata: {
|
|
30062
|
-
timestamp: entry.timestamp,
|
|
30063
|
-
hits: entry.hits,
|
|
30064
|
-
lastAccessed: entry.lastAccessed
|
|
30065
|
-
}
|
|
30066
|
-
}));
|
|
30067
|
-
}
|
|
30068
|
-
/**
|
|
30069
|
-
* Clean up expired entries
|
|
30070
|
-
*
|
|
30071
|
-
* Useful for periodic maintenance
|
|
30072
|
-
*
|
|
30073
|
-
* @returns Number of entries cleaned
|
|
29911
|
+
* Clean expired entries
|
|
30074
29912
|
*/
|
|
30075
29913
|
cleanExpired() {
|
|
30076
29914
|
const now2 = Date.now();
|
|
30077
|
-
let
|
|
29915
|
+
let cleaned = 0;
|
|
30078
29916
|
for (const [key2, entry] of this.cache.entries()) {
|
|
30079
|
-
if (now2 - entry.timestamp >
|
|
29917
|
+
if (now2 - entry.timestamp > entry.ttl) {
|
|
30080
29918
|
this.cache.delete(key2);
|
|
30081
|
-
|
|
29919
|
+
cleaned++;
|
|
30082
29920
|
}
|
|
30083
29921
|
}
|
|
30084
|
-
|
|
30085
|
-
console.log(`\u{1F9F9} [${this.name}] Cleaned ${cleanedCount} expired entries`);
|
|
30086
|
-
}
|
|
30087
|
-
return cleanedCount;
|
|
30088
|
-
}
|
|
30089
|
-
/**
|
|
30090
|
-
* Check if cache entry is expired
|
|
30091
|
-
*/
|
|
30092
|
-
isExpired(entry) {
|
|
30093
|
-
return Date.now() - entry.timestamp > this.ttlMs;
|
|
29922
|
+
return cleaned;
|
|
30094
29923
|
}
|
|
30095
29924
|
/**
|
|
30096
|
-
*
|
|
30097
|
-
*/
|
|
30098
|
-
evictLRU() {
|
|
30099
|
-
let oldestKey = null;
|
|
30100
|
-
let oldestAccess = Infinity;
|
|
30101
|
-
for (const [key2, entry] of this.cache.entries()) {
|
|
30102
|
-
if (entry.lastAccessed < oldestAccess) {
|
|
30103
|
-
oldestAccess = entry.lastAccessed;
|
|
30104
|
-
oldestKey = key2;
|
|
30105
|
-
}
|
|
30106
|
-
}
|
|
30107
|
-
if (oldestKey !== null) {
|
|
30108
|
-
this.cache.delete(oldestKey);
|
|
30109
|
-
this.stats.evictions++;
|
|
30110
|
-
if (this.debug) {
|
|
30111
|
-
const timeSinceAccess = Date.now() - oldestAccess;
|
|
30112
|
-
console.log(
|
|
30113
|
-
`\u267B\uFE0F [${this.name}] Cache EVICT (LRU): ${String(oldestKey)} (last accessed: ${timeSinceAccess}ms ago)`
|
|
30114
|
-
);
|
|
30115
|
-
}
|
|
30116
|
-
}
|
|
30117
|
-
}
|
|
30118
|
-
/**
|
|
30119
|
-
* Get or compute value
|
|
30120
|
-
*
|
|
30121
|
-
* If key exists in cache, returns cached value.
|
|
30122
|
-
* Otherwise, computes value using provided function and caches it.
|
|
30123
|
-
*
|
|
30124
|
-
* @param key - Cache key
|
|
30125
|
-
* @param compute - Function to compute value if not in cache
|
|
30126
|
-
* @param ttl - Optional custom TTL for this entry
|
|
30127
|
-
* @returns Cached or computed value
|
|
30128
|
-
*/
|
|
30129
|
-
async getOrCompute(key2, compute, ttl) {
|
|
30130
|
-
const cached = this.get(key2);
|
|
30131
|
-
if (cached !== null) {
|
|
30132
|
-
return cached;
|
|
30133
|
-
}
|
|
30134
|
-
const value = await compute();
|
|
30135
|
-
this.set(key2, value, ttl);
|
|
30136
|
-
return value;
|
|
30137
|
-
}
|
|
30138
|
-
/**
|
|
30139
|
-
* Get or compute value with Result wrapper
|
|
29925
|
+
* Get cache statistics
|
|
30140
29926
|
*/
|
|
30141
|
-
|
|
30142
|
-
|
|
30143
|
-
|
|
30144
|
-
|
|
30145
|
-
|
|
30146
|
-
|
|
30147
|
-
if (result.success) {
|
|
30148
|
-
this.set(key2, result.value, ttl);
|
|
30149
|
-
}
|
|
30150
|
-
return result;
|
|
29927
|
+
getStats() {
|
|
29928
|
+
return {
|
|
29929
|
+
size: this.cache.size,
|
|
29930
|
+
maxSize: this.maxSize,
|
|
29931
|
+
ttlMs: this.ttlMs
|
|
29932
|
+
};
|
|
30151
29933
|
}
|
|
30152
29934
|
};
|
|
30153
29935
|
var CacheManager = class {
|
|
30154
29936
|
caches = /* @__PURE__ */ new Map();
|
|
30155
|
-
|
|
30156
|
-
constructor(
|
|
30157
|
-
this.
|
|
29937
|
+
debug;
|
|
29938
|
+
constructor(config = {}) {
|
|
29939
|
+
this.debug = config.debug || false;
|
|
30158
29940
|
}
|
|
30159
29941
|
/**
|
|
30160
|
-
*
|
|
30161
|
-
*
|
|
30162
|
-
* @param name - Unique cache name
|
|
30163
|
-
* @param config - Optional cache-specific configuration
|
|
30164
|
-
* @returns LRU cache instance
|
|
29942
|
+
* Get or create a cache instance
|
|
30165
29943
|
*/
|
|
30166
29944
|
getCache(name, config) {
|
|
30167
|
-
|
|
30168
|
-
|
|
30169
|
-
return existingCache;
|
|
29945
|
+
if (this.caches.has(name)) {
|
|
29946
|
+
return this.caches.get(name);
|
|
30170
29947
|
}
|
|
30171
|
-
const
|
|
30172
|
-
...this.globalConfig,
|
|
30173
|
-
...config,
|
|
30174
|
-
name
|
|
30175
|
-
};
|
|
30176
|
-
const cache = new LRUCache(mergedConfig);
|
|
29948
|
+
const cache = new Cache(config);
|
|
30177
29949
|
this.caches.set(name, cache);
|
|
29950
|
+
if (this.debug) {
|
|
29951
|
+
console.log(`[CacheManager] Created cache: ${name}`, config);
|
|
29952
|
+
}
|
|
30178
29953
|
return cache;
|
|
30179
29954
|
}
|
|
30180
29955
|
/**
|
|
@@ -30189,11 +29964,11 @@ var CacheManager = class {
|
|
|
30189
29964
|
* Clean expired entries from all caches
|
|
30190
29965
|
*/
|
|
30191
29966
|
cleanAllExpired() {
|
|
30192
|
-
let
|
|
29967
|
+
let total = 0;
|
|
30193
29968
|
for (const cache of this.caches.values()) {
|
|
30194
|
-
|
|
29969
|
+
total += cache.cleanExpired();
|
|
30195
29970
|
}
|
|
30196
|
-
return
|
|
29971
|
+
return total;
|
|
30197
29972
|
}
|
|
30198
29973
|
/**
|
|
30199
29974
|
* Get statistics for all caches
|
|
@@ -30206,16 +29981,11 @@ var CacheManager = class {
|
|
|
30206
29981
|
return stats;
|
|
30207
29982
|
}
|
|
30208
29983
|
/**
|
|
30209
|
-
*
|
|
29984
|
+
* Destroy cache manager
|
|
30210
29985
|
*/
|
|
30211
|
-
|
|
30212
|
-
|
|
30213
|
-
|
|
30214
|
-
/**
|
|
30215
|
-
* Delete a named cache
|
|
30216
|
-
*/
|
|
30217
|
-
deleteCache(name) {
|
|
30218
|
-
return this.caches.delete(name);
|
|
29986
|
+
destroy() {
|
|
29987
|
+
this.clearAll();
|
|
29988
|
+
this.caches.clear();
|
|
30219
29989
|
}
|
|
30220
29990
|
};
|
|
30221
29991
|
function createCacheManager(config) {
|
|
@@ -40881,7 +40651,7 @@ export {
|
|
|
40881
40651
|
ErrorCategory,
|
|
40882
40652
|
ErrorSeverity,
|
|
40883
40653
|
EventHelpers,
|
|
40884
|
-
LRUCache,
|
|
40654
|
+
Cache as LRUCache,
|
|
40885
40655
|
LoanCreator,
|
|
40886
40656
|
LoanQuery,
|
|
40887
40657
|
LoanStatus,
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gvnrdao/dh-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.162",
|
|
4
4
|
"description": "TypeScript SDK for Diamond Hands Protocol - Bitcoin-backed lending with LIT Protocol PKPs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"module": "dist/index.mjs",
|
|
8
|
-
|
|
8
|
+
"browser": "browser/dist/index.js",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"author": "Diamond Hands Protocol",
|
|
51
51
|
"license": "MIT",
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@gvnrdao/dh-lit-actions": "
|
|
54
|
-
"@gvnrdao/dh-lit-ops": "
|
|
53
|
+
"@gvnrdao/dh-lit-actions": "0.0.226",
|
|
54
|
+
"@gvnrdao/dh-lit-ops": "0.0.203",
|
|
55
55
|
"@lit-protocol/lit-node-client": "^7.3.1",
|
|
56
56
|
"@noble/hashes": "^1.5.0",
|
|
57
57
|
"axios": "^1.5.0",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
},
|
|
87
87
|
"repository": {
|
|
88
88
|
"type": "git",
|
|
89
|
-
"url": "https://github.com/gvnrdao/diamond-hands.git",
|
|
89
|
+
"url": "git+https://github.com/gvnrdao/diamond-hands.git",
|
|
90
90
|
"directory": "sdk"
|
|
91
91
|
},
|
|
92
92
|
"bugs": {
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const DiamondHandsSDK: any;
|
|
2
|
-
export type CreateLoanRequest = any;
|
|
3
|
-
export type CreateLoanResult = any;
|
|
4
|
-
export type DiamondHandsSDKConfig = any;
|
|
5
|
-
export * from "../dist/index.js";
|
|
6
|
-
declare const _default: any;
|
|
7
|
-
export default _default;
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,eAAe,KAA4B,CAAC;AAoCzD,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACpC,MAAM,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACnC,MAAM,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAOxC,cAAc,kBAAkB,CAAC;;AAOjC,wBAAyC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// Browser ESM entry point for Diamond Hands SDK
|
|
2
|
-
// Converts CommonJS exports to ES module imports for browser compatibility
|
|
3
|
-
// Uses the proven wrapper pattern from test-app/src/lib/lit-ops-wrapper.ts
|
|
4
|
-
// Import from the original built SDK
|
|
5
|
-
import * as SDKModule from "../dist/index.js";
|
|
6
|
-
// Import lit-ops and lit-actions (using the wrapper pattern)
|
|
7
|
-
// TODO: Re-enable when these modules have proper ES module builds
|
|
8
|
-
// import * as LitOpsModule from "../../lit-ops/dist/index.js";
|
|
9
|
-
// import * as LitActionsModule from "../../lit-actions/dist/index.js";
|
|
10
|
-
// ========================================
|
|
11
|
-
// MAIN SDK EXPORTS
|
|
12
|
-
// ========================================
|
|
13
|
-
// Export main SDK classes (based on actual SDK exports)
|
|
14
|
-
export const DiamondHandsSDK = SDKModule.DiamondHandsSDK;
|
|
15
|
-
// ========================================
|
|
16
|
-
// RE-EXPORT CORE SDK ONLY
|
|
17
|
-
// ========================================
|
|
18
|
-
// Re-export core SDK exports only to avoid conflicts
|
|
19
|
-
export * from "../dist/index.js";
|
|
20
|
-
// ========================================
|
|
21
|
-
// DEFAULT EXPORT
|
|
22
|
-
// ========================================
|
|
23
|
-
// Default export (main SDK class)
|
|
24
|
-
export default SDKModule.DiamondHandsSDK;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../dist/index.js"],"names":[],"mappings":""}
|