@gvnrdao/dh-sdk 0.0.272 → 0.0.274
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.
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
/*! Axios v1.
|
|
8
|
+
/*! Axios v1.17.0 Copyright (c) 2026 Matt Zabriskie and contributors */
|
|
9
9
|
|
|
10
10
|
/*! MIT License. Copyright 2015-2022 Richard Moore <me@ricmoo.com>. See LICENSE.txt. */
|
|
11
11
|
|
package/dist/index.js
CHANGED
|
@@ -31391,17 +31391,17 @@ var require_pkg_src = __commonJS({
|
|
|
31391
31391
|
hash: "b7e4abec403555d85e2b0eaabed0fdd95640b5f0d068c67bba63afaa2cd200d0"
|
|
31392
31392
|
},
|
|
31393
31393
|
ucdMintValidator: {
|
|
31394
|
-
cid: "
|
|
31394
|
+
cid: "QmUtDgwYFqbLhhBkhRfHRTN51SyHm1CHcCQU2qUvpCzpfc",
|
|
31395
31395
|
authorizedCidHex: cidToHex(
|
|
31396
|
-
"
|
|
31396
|
+
"QmUtDgwYFqbLhhBkhRfHRTN51SyHm1CHcCQU2qUvpCzpfc"
|
|
31397
31397
|
),
|
|
31398
31398
|
name: "Ucd Mint Validator",
|
|
31399
31399
|
description: "Production Ucd Mint Validator",
|
|
31400
31400
|
version: "1.0.0",
|
|
31401
31401
|
deployed: true,
|
|
31402
|
-
deployedAt:
|
|
31403
|
-
size:
|
|
31404
|
-
hash: "
|
|
31402
|
+
deployedAt: 1780485728736,
|
|
31403
|
+
size: 67380,
|
|
31404
|
+
hash: "901f0ec80a04cb9daad84c35c69bcf0dc8892a05ae9431a23c1855e1ab9aed9d",
|
|
31405
31405
|
validatorWalletAddress: "0x36f3dd61c4c08a56d29ed2fd6d5f111b67b6a7a1",
|
|
31406
31406
|
pkp: {
|
|
31407
31407
|
publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
|
|
@@ -31523,17 +31523,17 @@ var require_pkg_src = __commonJS({
|
|
|
31523
31523
|
// Requires BitcoinProviderRegistry.addAllowedCid(chainId, keccak256(utf8(cid)))
|
|
31524
31524
|
// on each target chain (the action decrypts registry slots). No OAR entry.
|
|
31525
31525
|
btcAddressBalance: {
|
|
31526
|
-
cid: "
|
|
31526
|
+
cid: "QmdBMy7Niz4Vsgbmh1Pm3aXK8PL3uJwS7GDeoCKd8Yuua6",
|
|
31527
31527
|
authorizedCidHex: cidToHex(
|
|
31528
|
-
"
|
|
31528
|
+
"QmdBMy7Niz4Vsgbmh1Pm3aXK8PL3uJwS7GDeoCKd8Yuua6"
|
|
31529
31529
|
),
|
|
31530
31530
|
name: "Btc Address Balance",
|
|
31531
31531
|
description: "Address-only signed total BTC balance via registry consensus (no positionId, no price)",
|
|
31532
31532
|
version: "0.1.0",
|
|
31533
31533
|
deployed: true,
|
|
31534
|
-
deployedAt:
|
|
31535
|
-
size:
|
|
31536
|
-
hash: "
|
|
31534
|
+
deployedAt: 1780485650442,
|
|
31535
|
+
size: 21864,
|
|
31536
|
+
hash: "8369701c40e742ec54d34fec373f21cfd75f5dfd3ece4bc5358c7566032e7605",
|
|
31537
31537
|
validatorWalletAddress: "0xf0bf5e3f864b87283a05d1e4a85ee0fa40493fb5",
|
|
31538
31538
|
pkp: {
|
|
31539
31539
|
publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
|
|
@@ -34716,7 +34716,19 @@ function getSepoliaConfig() {
|
|
|
34716
34716
|
});
|
|
34717
34717
|
return {
|
|
34718
34718
|
mode: "service",
|
|
34719
|
-
|
|
34719
|
+
// No production default — fail closed if unset. A missing LIT_OPS_ENDPOINT must
|
|
34720
|
+
// NOT silently route signed/authenticated requests to the production service:
|
|
34721
|
+
// that masks misconfiguration in local/dev/test. Returns "" when unset (Node:
|
|
34722
|
+
// env missing; browser: always), so downstream validateServiceModeConfig throws.
|
|
34723
|
+
// Node consumers must set LIT_OPS_ENDPOINT; browser apps pass serviceEndpoint
|
|
34724
|
+
// explicitly from decrypted /v1/init (user config still wins over this).
|
|
34725
|
+
// Lazy getter — resolved at access time, NOT captured at module-init.
|
|
34726
|
+
// Reading the env var once at module load would freeze it empty when
|
|
34727
|
+
// LIT_OPS_ENDPOINT is set after import (late-loaded dotenv, test setup),
|
|
34728
|
+
// leaving Sepolia serviceEndpoint permanently "".
|
|
34729
|
+
get serviceEndpoint() {
|
|
34730
|
+
return readInitBackedEnv("LIT_OPS_ENDPOINT");
|
|
34731
|
+
},
|
|
34720
34732
|
chainId: 11155111,
|
|
34721
34733
|
name: "sepolia",
|
|
34722
34734
|
rpcUrls: [],
|
|
@@ -34744,7 +34756,10 @@ function getSepoliaConfig() {
|
|
|
34744
34756
|
positionDelegateRegistry: SEPOLIA_CONTRACTS.PositionDelegateRegistry || ""
|
|
34745
34757
|
},
|
|
34746
34758
|
subgraphs: {
|
|
34747
|
-
|
|
34759
|
+
// Lazy getter for the same module-init snapshot reason as serviceEndpoint.
|
|
34760
|
+
get diamondHandsUrl() {
|
|
34761
|
+
return readInitBackedEnv("SUBGRAPH_URL");
|
|
34762
|
+
}
|
|
34748
34763
|
},
|
|
34749
34764
|
debug: true
|
|
34750
34765
|
};
|
|
@@ -34877,13 +34892,13 @@ function getAllNetworkConfigs() {
|
|
|
34877
34892
|
function isNetworkSupported(chainId) {
|
|
34878
34893
|
return chainId in NETWORK_CONFIGS;
|
|
34879
34894
|
}
|
|
34880
|
-
var
|
|
34895
|
+
var isNode2, isBrowser, fs, path, CONTRACTS_PATH, DEPLOYMENTS_PATH, NETWORK_CONFIGS, DEFAULT_NETWORK_CONFIG;
|
|
34881
34896
|
var init_network_configs = __esm({
|
|
34882
34897
|
"src/constants/chunks/network-configs.ts"() {
|
|
34883
34898
|
"use strict";
|
|
34884
34899
|
init_deployment_addresses();
|
|
34885
|
-
|
|
34886
|
-
|
|
34900
|
+
isNode2 = !!(typeof process !== "undefined" && process.versions && process.versions.node);
|
|
34901
|
+
isBrowser = !isNode2 && (typeof window !== "undefined" || typeof global === "undefined" && typeof process === "undefined" || typeof navigator !== "undefined" && !!navigator.userAgent);
|
|
34887
34902
|
fs = void 0;
|
|
34888
34903
|
path = void 0;
|
|
34889
34904
|
if (isNode2 && !isBrowser) {
|
|
@@ -107694,7 +107709,8 @@ function assertSafeServiceEndpoint(endpoint) {
|
|
|
107694
107709
|
if (url.protocol === "http:") {
|
|
107695
107710
|
const host = url.hostname.replace(/^\[|\]$/g, "");
|
|
107696
107711
|
const isLoopback = host === "localhost" || host === "127.0.0.1" || host === "::1" || // IPv4 loopback range 127.0.0.0/8 (numeric — not resolvable/hijackable).
|
|
107697
|
-
|
|
107712
|
+
// Each of the trailing three octets must be a valid 0–255 value.
|
|
107713
|
+
/^127\.(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){2}(?:25[0-5]|2[0-4]\d|1?\d?\d)$/.test(host);
|
|
107698
107714
|
if (isLoopback)
|
|
107699
107715
|
return;
|
|
107700
107716
|
throw new Error(
|
|
@@ -110748,6 +110764,19 @@ function createLoanCreator(config) {
|
|
|
110748
110764
|
}
|
|
110749
110765
|
}
|
|
110750
110766
|
|
|
110767
|
+
// src/types/loanStatus.ts
|
|
110768
|
+
var LoanStatus = /* @__PURE__ */ ((LoanStatus2) => {
|
|
110769
|
+
LoanStatus2[LoanStatus2["PENDING_DEPOSIT"] = 0] = "PENDING_DEPOSIT";
|
|
110770
|
+
LoanStatus2[LoanStatus2["PENDING_MINT"] = 1] = "PENDING_MINT";
|
|
110771
|
+
LoanStatus2[LoanStatus2["ACTIVE"] = 2] = "ACTIVE";
|
|
110772
|
+
LoanStatus2[LoanStatus2["EXPIRED"] = 3] = "EXPIRED";
|
|
110773
|
+
LoanStatus2[LoanStatus2["LIQUIDATABLE"] = 4] = "LIQUIDATABLE";
|
|
110774
|
+
LoanStatus2[LoanStatus2["LIQUIDATED"] = 5] = "LIQUIDATED";
|
|
110775
|
+
LoanStatus2[LoanStatus2["REPAID"] = 6] = "REPAID";
|
|
110776
|
+
LoanStatus2[LoanStatus2["CLOSED"] = 7] = "CLOSED";
|
|
110777
|
+
return LoanStatus2;
|
|
110778
|
+
})(LoanStatus || {});
|
|
110779
|
+
|
|
110751
110780
|
// src/modules/loan/loan-query.module.ts
|
|
110752
110781
|
var POSITION_CORE_ABI = [
|
|
110753
110782
|
"function getPositionDetails(bytes32) view returns (tuple(bytes32 positionId, bytes32 pkpId, uint256 ucdDebt, string vaultAddress, address borrower, uint40 createdAt, uint40 lastUpdated, uint16 selectedTerm, uint40 expiryAt, uint8 status, uint40 previousExpiryAt, uint16 totalTerm))"
|
|
@@ -111110,44 +111139,22 @@ var LoanQuery = class {
|
|
|
111110
111139
|
* Map numeric status to string for subgraph queries
|
|
111111
111140
|
*/
|
|
111112
111141
|
mapStatusToString(status) {
|
|
111113
|
-
|
|
111114
|
-
0: "PENDING_DEPOSIT",
|
|
111115
|
-
1: "ACTIVE",
|
|
111116
|
-
2: "EXPIRED",
|
|
111117
|
-
3: "REPAID",
|
|
111118
|
-
4: "LIQUIDATED",
|
|
111119
|
-
5: "EXTENDED"
|
|
111120
|
-
};
|
|
111121
|
-
return statusMap[status] || "ACTIVE";
|
|
111142
|
+
return LoanStatus[status] ?? "ACTIVE";
|
|
111122
111143
|
}
|
|
111123
111144
|
/**
|
|
111124
111145
|
* Map string status to numeric for filtering
|
|
111125
111146
|
*/
|
|
111126
111147
|
mapStringToStatus(statusString) {
|
|
111127
|
-
const
|
|
111128
|
-
|
|
111129
|
-
|
|
111130
|
-
EXPIRED: 2,
|
|
111131
|
-
REPAID: 3,
|
|
111132
|
-
LIQUIDATED: 4,
|
|
111133
|
-
EXTENDED: 5
|
|
111134
|
-
};
|
|
111135
|
-
return statusMap[statusString.toUpperCase()] ?? null;
|
|
111148
|
+
const key = statusString.toUpperCase();
|
|
111149
|
+
const value = LoanStatus[key];
|
|
111150
|
+
return typeof value === "number" ? value : null;
|
|
111136
111151
|
}
|
|
111137
111152
|
/**
|
|
111138
111153
|
* Validate if a string is a valid loan status
|
|
111139
111154
|
*/
|
|
111140
111155
|
isValidStatus(statusString) {
|
|
111141
|
-
const
|
|
111142
|
-
|
|
111143
|
-
"ACTIVE",
|
|
111144
|
-
"EXPIRED",
|
|
111145
|
-
"REPAID",
|
|
111146
|
-
"LIQUIDATED",
|
|
111147
|
-
"EXTENDED",
|
|
111148
|
-
"CLOSED"
|
|
111149
|
-
];
|
|
111150
|
-
return validStatuses.includes(statusString.toUpperCase());
|
|
111156
|
+
const key = statusString.toUpperCase();
|
|
111157
|
+
return typeof LoanStatus[key] === "number";
|
|
111151
111158
|
}
|
|
111152
111159
|
/**
|
|
111153
111160
|
* Get loans for a borrower
|
|
@@ -111160,18 +111167,18 @@ var LoanQuery = class {
|
|
|
111160
111167
|
return this.getLoans({ borrower, orderBy, orderDirection }, pagination);
|
|
111161
111168
|
}
|
|
111162
111169
|
/**
|
|
111163
|
-
* Get active loans (status =
|
|
111170
|
+
* Get active loans (status = ACTIVE)
|
|
111164
111171
|
*
|
|
111165
111172
|
* @param pagination - Pagination parameters
|
|
111166
111173
|
* @returns Paginated active loans
|
|
111167
111174
|
*/
|
|
111168
111175
|
async getActiveLoans(pagination) {
|
|
111169
|
-
return this.getLoans({ status:
|
|
111176
|
+
return this.getLoans({ status: 2 /* ACTIVE */ }, pagination);
|
|
111170
111177
|
}
|
|
111171
111178
|
/**
|
|
111172
111179
|
* Get loans by state/status
|
|
111173
111180
|
*
|
|
111174
|
-
* @param state - Loan state (PENDING_DEPOSIT, ACTIVE, EXPIRED,
|
|
111181
|
+
* @param state - Loan state (PENDING_DEPOSIT, PENDING_MINT, ACTIVE, EXPIRED, LIQUIDATABLE, LIQUIDATED, REPAID, CLOSED)
|
|
111175
111182
|
* @param pagination - Pagination parameters
|
|
111176
111183
|
* @returns Paginated loans matching the specified state
|
|
111177
111184
|
*/
|
|
@@ -111179,7 +111186,7 @@ var LoanQuery = class {
|
|
|
111179
111186
|
if (!this.isValidStatus(state)) {
|
|
111180
111187
|
return failure(
|
|
111181
111188
|
new SDKError({
|
|
111182
|
-
message: `Invalid loan state: ${state}. Valid states are: PENDING_DEPOSIT, ACTIVE, EXPIRED,
|
|
111189
|
+
message: `Invalid loan state: ${state}. Valid states are: PENDING_DEPOSIT, PENDING_MINT, ACTIVE, EXPIRED, LIQUIDATABLE, LIQUIDATED, REPAID, CLOSED`,
|
|
111183
111190
|
category: "VALIDATION" /* VALIDATION */,
|
|
111184
111191
|
severity: "LOW" /* LOW */,
|
|
111185
111192
|
context: { state }
|
|
@@ -117162,19 +117169,6 @@ async function safeWaitForTransaction(tx, confirmations = 1, timeout = 6e4) {
|
|
|
117162
117169
|
throw new Error(`Transaction ${txHash} confirmation timed out after ${timeout}ms`);
|
|
117163
117170
|
}
|
|
117164
117171
|
|
|
117165
|
-
// src/types/loanStatus.ts
|
|
117166
|
-
var LoanStatus = /* @__PURE__ */ ((LoanStatus2) => {
|
|
117167
|
-
LoanStatus2[LoanStatus2["PENDING_DEPOSIT"] = 0] = "PENDING_DEPOSIT";
|
|
117168
|
-
LoanStatus2[LoanStatus2["PENDING_MINT"] = 1] = "PENDING_MINT";
|
|
117169
|
-
LoanStatus2[LoanStatus2["ACTIVE"] = 2] = "ACTIVE";
|
|
117170
|
-
LoanStatus2[LoanStatus2["EXPIRED"] = 3] = "EXPIRED";
|
|
117171
|
-
LoanStatus2[LoanStatus2["LIQUIDATABLE"] = 4] = "LIQUIDATABLE";
|
|
117172
|
-
LoanStatus2[LoanStatus2["LIQUIDATED"] = 5] = "LIQUIDATED";
|
|
117173
|
-
LoanStatus2[LoanStatus2["REPAID"] = 6] = "REPAID";
|
|
117174
|
-
LoanStatus2[LoanStatus2["CLOSED"] = 7] = "CLOSED";
|
|
117175
|
-
return LoanStatus2;
|
|
117176
|
-
})(LoanStatus || {});
|
|
117177
|
-
|
|
117178
117172
|
// src/modules/diamond-hands-sdk.ts
|
|
117179
117173
|
var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
117180
117174
|
config;
|
|
@@ -123004,11 +122998,15 @@ Error data: ${errorData || "none"}`
|
|
|
123004
122998
|
async getAddressBalance(vaultAddress) {
|
|
123005
122999
|
this.ensureInitialized();
|
|
123006
123000
|
try {
|
|
123007
|
-
if (this.config
|
|
123001
|
+
if (!isServiceModeConfig(this.config)) {
|
|
123008
123002
|
throw new Error("getAddressBalance requires service mode \u2014 standalone mode is not supported");
|
|
123009
123003
|
}
|
|
123004
|
+
const trimmedAddress = vaultAddress?.trim();
|
|
123005
|
+
if (!trimmedAddress) {
|
|
123006
|
+
throw new Error("vaultAddress is required");
|
|
123007
|
+
}
|
|
123010
123008
|
const serviceEndpoint = this.config.serviceEndpoint;
|
|
123011
|
-
const url = `${serviceEndpoint}/api/lit/address-balance?vaultAddress=${encodeURIComponent(
|
|
123009
|
+
const url = `${serviceEndpoint}/api/lit/address-balance?vaultAddress=${encodeURIComponent(trimmedAddress)}`;
|
|
123012
123010
|
const response = await fetch(url, {
|
|
123013
123011
|
headers: await this.getAuthHeader()
|
|
123014
123012
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -31397,17 +31397,17 @@ var require_pkg_src = __commonJS({
|
|
|
31397
31397
|
hash: "b7e4abec403555d85e2b0eaabed0fdd95640b5f0d068c67bba63afaa2cd200d0"
|
|
31398
31398
|
},
|
|
31399
31399
|
ucdMintValidator: {
|
|
31400
|
-
cid: "
|
|
31400
|
+
cid: "QmUtDgwYFqbLhhBkhRfHRTN51SyHm1CHcCQU2qUvpCzpfc",
|
|
31401
31401
|
authorizedCidHex: cidToHex(
|
|
31402
|
-
"
|
|
31402
|
+
"QmUtDgwYFqbLhhBkhRfHRTN51SyHm1CHcCQU2qUvpCzpfc"
|
|
31403
31403
|
),
|
|
31404
31404
|
name: "Ucd Mint Validator",
|
|
31405
31405
|
description: "Production Ucd Mint Validator",
|
|
31406
31406
|
version: "1.0.0",
|
|
31407
31407
|
deployed: true,
|
|
31408
|
-
deployedAt:
|
|
31409
|
-
size:
|
|
31410
|
-
hash: "
|
|
31408
|
+
deployedAt: 1780485728736,
|
|
31409
|
+
size: 67380,
|
|
31410
|
+
hash: "901f0ec80a04cb9daad84c35c69bcf0dc8892a05ae9431a23c1855e1ab9aed9d",
|
|
31411
31411
|
validatorWalletAddress: "0x36f3dd61c4c08a56d29ed2fd6d5f111b67b6a7a1",
|
|
31412
31412
|
pkp: {
|
|
31413
31413
|
publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
|
|
@@ -31529,17 +31529,17 @@ var require_pkg_src = __commonJS({
|
|
|
31529
31529
|
// Requires BitcoinProviderRegistry.addAllowedCid(chainId, keccak256(utf8(cid)))
|
|
31530
31530
|
// on each target chain (the action decrypts registry slots). No OAR entry.
|
|
31531
31531
|
btcAddressBalance: {
|
|
31532
|
-
cid: "
|
|
31532
|
+
cid: "QmdBMy7Niz4Vsgbmh1Pm3aXK8PL3uJwS7GDeoCKd8Yuua6",
|
|
31533
31533
|
authorizedCidHex: cidToHex(
|
|
31534
|
-
"
|
|
31534
|
+
"QmdBMy7Niz4Vsgbmh1Pm3aXK8PL3uJwS7GDeoCKd8Yuua6"
|
|
31535
31535
|
),
|
|
31536
31536
|
name: "Btc Address Balance",
|
|
31537
31537
|
description: "Address-only signed total BTC balance via registry consensus (no positionId, no price)",
|
|
31538
31538
|
version: "0.1.0",
|
|
31539
31539
|
deployed: true,
|
|
31540
|
-
deployedAt:
|
|
31541
|
-
size:
|
|
31542
|
-
hash: "
|
|
31540
|
+
deployedAt: 1780485650442,
|
|
31541
|
+
size: 21864,
|
|
31542
|
+
hash: "8369701c40e742ec54d34fec373f21cfd75f5dfd3ece4bc5358c7566032e7605",
|
|
31543
31543
|
validatorWalletAddress: "0xf0bf5e3f864b87283a05d1e4a85ee0fa40493fb5",
|
|
31544
31544
|
pkp: {
|
|
31545
31545
|
publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
|
|
@@ -34722,7 +34722,19 @@ function getSepoliaConfig() {
|
|
|
34722
34722
|
});
|
|
34723
34723
|
return {
|
|
34724
34724
|
mode: "service",
|
|
34725
|
-
|
|
34725
|
+
// No production default — fail closed if unset. A missing LIT_OPS_ENDPOINT must
|
|
34726
|
+
// NOT silently route signed/authenticated requests to the production service:
|
|
34727
|
+
// that masks misconfiguration in local/dev/test. Returns "" when unset (Node:
|
|
34728
|
+
// env missing; browser: always), so downstream validateServiceModeConfig throws.
|
|
34729
|
+
// Node consumers must set LIT_OPS_ENDPOINT; browser apps pass serviceEndpoint
|
|
34730
|
+
// explicitly from decrypted /v1/init (user config still wins over this).
|
|
34731
|
+
// Lazy getter — resolved at access time, NOT captured at module-init.
|
|
34732
|
+
// Reading the env var once at module load would freeze it empty when
|
|
34733
|
+
// LIT_OPS_ENDPOINT is set after import (late-loaded dotenv, test setup),
|
|
34734
|
+
// leaving Sepolia serviceEndpoint permanently "".
|
|
34735
|
+
get serviceEndpoint() {
|
|
34736
|
+
return readInitBackedEnv("LIT_OPS_ENDPOINT");
|
|
34737
|
+
},
|
|
34726
34738
|
chainId: 11155111,
|
|
34727
34739
|
name: "sepolia",
|
|
34728
34740
|
rpcUrls: [],
|
|
@@ -34750,7 +34762,10 @@ function getSepoliaConfig() {
|
|
|
34750
34762
|
positionDelegateRegistry: SEPOLIA_CONTRACTS.PositionDelegateRegistry || ""
|
|
34751
34763
|
},
|
|
34752
34764
|
subgraphs: {
|
|
34753
|
-
|
|
34765
|
+
// Lazy getter for the same module-init snapshot reason as serviceEndpoint.
|
|
34766
|
+
get diamondHandsUrl() {
|
|
34767
|
+
return readInitBackedEnv("SUBGRAPH_URL");
|
|
34768
|
+
}
|
|
34754
34769
|
},
|
|
34755
34770
|
debug: true
|
|
34756
34771
|
};
|
|
@@ -34883,13 +34898,13 @@ function getAllNetworkConfigs() {
|
|
|
34883
34898
|
function isNetworkSupported(chainId) {
|
|
34884
34899
|
return chainId in NETWORK_CONFIGS;
|
|
34885
34900
|
}
|
|
34886
|
-
var
|
|
34901
|
+
var isNode2, isBrowser, fs, path, CONTRACTS_PATH, DEPLOYMENTS_PATH, NETWORK_CONFIGS, DEFAULT_NETWORK_CONFIG;
|
|
34887
34902
|
var init_network_configs = __esm({
|
|
34888
34903
|
"src/constants/chunks/network-configs.ts"() {
|
|
34889
34904
|
"use strict";
|
|
34890
34905
|
init_deployment_addresses();
|
|
34891
|
-
|
|
34892
|
-
|
|
34906
|
+
isNode2 = !!(typeof process !== "undefined" && process.versions && process.versions.node);
|
|
34907
|
+
isBrowser = !isNode2 && (typeof window !== "undefined" || typeof global === "undefined" && typeof process === "undefined" || typeof navigator !== "undefined" && !!navigator.userAgent);
|
|
34893
34908
|
fs = void 0;
|
|
34894
34909
|
path = void 0;
|
|
34895
34910
|
if (isNode2 && !isBrowser) {
|
|
@@ -107618,7 +107633,8 @@ function assertSafeServiceEndpoint(endpoint) {
|
|
|
107618
107633
|
if (url.protocol === "http:") {
|
|
107619
107634
|
const host = url.hostname.replace(/^\[|\]$/g, "");
|
|
107620
107635
|
const isLoopback = host === "localhost" || host === "127.0.0.1" || host === "::1" || // IPv4 loopback range 127.0.0.0/8 (numeric — not resolvable/hijackable).
|
|
107621
|
-
|
|
107636
|
+
// Each of the trailing three octets must be a valid 0–255 value.
|
|
107637
|
+
/^127\.(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){2}(?:25[0-5]|2[0-4]\d|1?\d?\d)$/.test(host);
|
|
107622
107638
|
if (isLoopback)
|
|
107623
107639
|
return;
|
|
107624
107640
|
throw new Error(
|
|
@@ -110672,6 +110688,19 @@ function createLoanCreator(config) {
|
|
|
110672
110688
|
}
|
|
110673
110689
|
}
|
|
110674
110690
|
|
|
110691
|
+
// src/types/loanStatus.ts
|
|
110692
|
+
var LoanStatus = /* @__PURE__ */ ((LoanStatus2) => {
|
|
110693
|
+
LoanStatus2[LoanStatus2["PENDING_DEPOSIT"] = 0] = "PENDING_DEPOSIT";
|
|
110694
|
+
LoanStatus2[LoanStatus2["PENDING_MINT"] = 1] = "PENDING_MINT";
|
|
110695
|
+
LoanStatus2[LoanStatus2["ACTIVE"] = 2] = "ACTIVE";
|
|
110696
|
+
LoanStatus2[LoanStatus2["EXPIRED"] = 3] = "EXPIRED";
|
|
110697
|
+
LoanStatus2[LoanStatus2["LIQUIDATABLE"] = 4] = "LIQUIDATABLE";
|
|
110698
|
+
LoanStatus2[LoanStatus2["LIQUIDATED"] = 5] = "LIQUIDATED";
|
|
110699
|
+
LoanStatus2[LoanStatus2["REPAID"] = 6] = "REPAID";
|
|
110700
|
+
LoanStatus2[LoanStatus2["CLOSED"] = 7] = "CLOSED";
|
|
110701
|
+
return LoanStatus2;
|
|
110702
|
+
})(LoanStatus || {});
|
|
110703
|
+
|
|
110675
110704
|
// src/modules/loan/loan-query.module.ts
|
|
110676
110705
|
var POSITION_CORE_ABI = [
|
|
110677
110706
|
"function getPositionDetails(bytes32) view returns (tuple(bytes32 positionId, bytes32 pkpId, uint256 ucdDebt, string vaultAddress, address borrower, uint40 createdAt, uint40 lastUpdated, uint16 selectedTerm, uint40 expiryAt, uint8 status, uint40 previousExpiryAt, uint16 totalTerm))"
|
|
@@ -111034,44 +111063,22 @@ var LoanQuery = class {
|
|
|
111034
111063
|
* Map numeric status to string for subgraph queries
|
|
111035
111064
|
*/
|
|
111036
111065
|
mapStatusToString(status) {
|
|
111037
|
-
|
|
111038
|
-
0: "PENDING_DEPOSIT",
|
|
111039
|
-
1: "ACTIVE",
|
|
111040
|
-
2: "EXPIRED",
|
|
111041
|
-
3: "REPAID",
|
|
111042
|
-
4: "LIQUIDATED",
|
|
111043
|
-
5: "EXTENDED"
|
|
111044
|
-
};
|
|
111045
|
-
return statusMap[status] || "ACTIVE";
|
|
111066
|
+
return LoanStatus[status] ?? "ACTIVE";
|
|
111046
111067
|
}
|
|
111047
111068
|
/**
|
|
111048
111069
|
* Map string status to numeric for filtering
|
|
111049
111070
|
*/
|
|
111050
111071
|
mapStringToStatus(statusString) {
|
|
111051
|
-
const
|
|
111052
|
-
|
|
111053
|
-
|
|
111054
|
-
EXPIRED: 2,
|
|
111055
|
-
REPAID: 3,
|
|
111056
|
-
LIQUIDATED: 4,
|
|
111057
|
-
EXTENDED: 5
|
|
111058
|
-
};
|
|
111059
|
-
return statusMap[statusString.toUpperCase()] ?? null;
|
|
111072
|
+
const key = statusString.toUpperCase();
|
|
111073
|
+
const value = LoanStatus[key];
|
|
111074
|
+
return typeof value === "number" ? value : null;
|
|
111060
111075
|
}
|
|
111061
111076
|
/**
|
|
111062
111077
|
* Validate if a string is a valid loan status
|
|
111063
111078
|
*/
|
|
111064
111079
|
isValidStatus(statusString) {
|
|
111065
|
-
const
|
|
111066
|
-
|
|
111067
|
-
"ACTIVE",
|
|
111068
|
-
"EXPIRED",
|
|
111069
|
-
"REPAID",
|
|
111070
|
-
"LIQUIDATED",
|
|
111071
|
-
"EXTENDED",
|
|
111072
|
-
"CLOSED"
|
|
111073
|
-
];
|
|
111074
|
-
return validStatuses.includes(statusString.toUpperCase());
|
|
111080
|
+
const key = statusString.toUpperCase();
|
|
111081
|
+
return typeof LoanStatus[key] === "number";
|
|
111075
111082
|
}
|
|
111076
111083
|
/**
|
|
111077
111084
|
* Get loans for a borrower
|
|
@@ -111084,18 +111091,18 @@ var LoanQuery = class {
|
|
|
111084
111091
|
return this.getLoans({ borrower, orderBy, orderDirection }, pagination);
|
|
111085
111092
|
}
|
|
111086
111093
|
/**
|
|
111087
|
-
* Get active loans (status =
|
|
111094
|
+
* Get active loans (status = ACTIVE)
|
|
111088
111095
|
*
|
|
111089
111096
|
* @param pagination - Pagination parameters
|
|
111090
111097
|
* @returns Paginated active loans
|
|
111091
111098
|
*/
|
|
111092
111099
|
async getActiveLoans(pagination) {
|
|
111093
|
-
return this.getLoans({ status:
|
|
111100
|
+
return this.getLoans({ status: 2 /* ACTIVE */ }, pagination);
|
|
111094
111101
|
}
|
|
111095
111102
|
/**
|
|
111096
111103
|
* Get loans by state/status
|
|
111097
111104
|
*
|
|
111098
|
-
* @param state - Loan state (PENDING_DEPOSIT, ACTIVE, EXPIRED,
|
|
111105
|
+
* @param state - Loan state (PENDING_DEPOSIT, PENDING_MINT, ACTIVE, EXPIRED, LIQUIDATABLE, LIQUIDATED, REPAID, CLOSED)
|
|
111099
111106
|
* @param pagination - Pagination parameters
|
|
111100
111107
|
* @returns Paginated loans matching the specified state
|
|
111101
111108
|
*/
|
|
@@ -111103,7 +111110,7 @@ var LoanQuery = class {
|
|
|
111103
111110
|
if (!this.isValidStatus(state)) {
|
|
111104
111111
|
return failure(
|
|
111105
111112
|
new SDKError({
|
|
111106
|
-
message: `Invalid loan state: ${state}. Valid states are: PENDING_DEPOSIT, ACTIVE, EXPIRED,
|
|
111113
|
+
message: `Invalid loan state: ${state}. Valid states are: PENDING_DEPOSIT, PENDING_MINT, ACTIVE, EXPIRED, LIQUIDATABLE, LIQUIDATED, REPAID, CLOSED`,
|
|
111107
111114
|
category: "VALIDATION" /* VALIDATION */,
|
|
111108
111115
|
severity: "LOW" /* LOW */,
|
|
111109
111116
|
context: { state }
|
|
@@ -117086,19 +117093,6 @@ async function safeWaitForTransaction(tx, confirmations = 1, timeout = 6e4) {
|
|
|
117086
117093
|
throw new Error(`Transaction ${txHash} confirmation timed out after ${timeout}ms`);
|
|
117087
117094
|
}
|
|
117088
117095
|
|
|
117089
|
-
// src/types/loanStatus.ts
|
|
117090
|
-
var LoanStatus = /* @__PURE__ */ ((LoanStatus2) => {
|
|
117091
|
-
LoanStatus2[LoanStatus2["PENDING_DEPOSIT"] = 0] = "PENDING_DEPOSIT";
|
|
117092
|
-
LoanStatus2[LoanStatus2["PENDING_MINT"] = 1] = "PENDING_MINT";
|
|
117093
|
-
LoanStatus2[LoanStatus2["ACTIVE"] = 2] = "ACTIVE";
|
|
117094
|
-
LoanStatus2[LoanStatus2["EXPIRED"] = 3] = "EXPIRED";
|
|
117095
|
-
LoanStatus2[LoanStatus2["LIQUIDATABLE"] = 4] = "LIQUIDATABLE";
|
|
117096
|
-
LoanStatus2[LoanStatus2["LIQUIDATED"] = 5] = "LIQUIDATED";
|
|
117097
|
-
LoanStatus2[LoanStatus2["REPAID"] = 6] = "REPAID";
|
|
117098
|
-
LoanStatus2[LoanStatus2["CLOSED"] = 7] = "CLOSED";
|
|
117099
|
-
return LoanStatus2;
|
|
117100
|
-
})(LoanStatus || {});
|
|
117101
|
-
|
|
117102
117096
|
// src/modules/diamond-hands-sdk.ts
|
|
117103
117097
|
var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
117104
117098
|
config;
|
|
@@ -122928,11 +122922,15 @@ Error data: ${errorData || "none"}`
|
|
|
122928
122922
|
async getAddressBalance(vaultAddress) {
|
|
122929
122923
|
this.ensureInitialized();
|
|
122930
122924
|
try {
|
|
122931
|
-
if (this.config
|
|
122925
|
+
if (!isServiceModeConfig(this.config)) {
|
|
122932
122926
|
throw new Error("getAddressBalance requires service mode \u2014 standalone mode is not supported");
|
|
122933
122927
|
}
|
|
122928
|
+
const trimmedAddress = vaultAddress?.trim();
|
|
122929
|
+
if (!trimmedAddress) {
|
|
122930
|
+
throw new Error("vaultAddress is required");
|
|
122931
|
+
}
|
|
122934
122932
|
const serviceEndpoint = this.config.serviceEndpoint;
|
|
122935
|
-
const url = `${serviceEndpoint}/api/lit/address-balance?vaultAddress=${encodeURIComponent(
|
|
122933
|
+
const url = `${serviceEndpoint}/api/lit/address-balance?vaultAddress=${encodeURIComponent(trimmedAddress)}`;
|
|
122936
122934
|
const response = await fetch(url, {
|
|
122937
122935
|
headers: await this.getAuthHeader()
|
|
122938
122936
|
});
|
|
@@ -134,7 +134,7 @@ export declare class LoanQuery {
|
|
|
134
134
|
*/
|
|
135
135
|
getLoansByBorrower(borrower: string, pagination?: PaginationParams, orderBy?: "createdAt" | "lastUpdatedAt" | "ucdDebt", orderDirection?: "asc" | "desc"): Promise<Result<PaginatedLoansResponse, SDKError>>;
|
|
136
136
|
/**
|
|
137
|
-
* Get active loans (status =
|
|
137
|
+
* Get active loans (status = ACTIVE)
|
|
138
138
|
*
|
|
139
139
|
* @param pagination - Pagination parameters
|
|
140
140
|
* @returns Paginated active loans
|
|
@@ -143,7 +143,7 @@ export declare class LoanQuery {
|
|
|
143
143
|
/**
|
|
144
144
|
* Get loans by state/status
|
|
145
145
|
*
|
|
146
|
-
* @param state - Loan state (PENDING_DEPOSIT, ACTIVE, EXPIRED,
|
|
146
|
+
* @param state - Loan state (PENDING_DEPOSIT, PENDING_MINT, ACTIVE, EXPIRED, LIQUIDATABLE, LIQUIDATED, REPAID, CLOSED)
|
|
147
147
|
* @param pagination - Pagination parameters
|
|
148
148
|
* @returns Paginated loans matching the specified state
|
|
149
149
|
*/
|
|
@@ -8,5 +8,9 @@
|
|
|
8
8
|
* loopback by RFC 6761, but not every resolver honours it strictly — a hostile or misconfigured
|
|
9
9
|
* DNS could resolve `foo.localhost` to an off-host IP and exfiltrate the cleartext token. Exact
|
|
10
10
|
* loopback literals + the numeric 127.0.0.0/8 range can't be DNS-hijacked.
|
|
11
|
+
*
|
|
12
|
+
* IPv4-mapped IPv6 loopback (e.g. `http://[::ffff:127.0.0.1]`) is intentionally NOT accepted: the
|
|
13
|
+
* URL parser normalises it to a hex form (`[::ffff:7f00:1]`) that is fragile to match safely. Use
|
|
14
|
+
* `127.0.0.1`, `::1`, or `localhost` for local development.
|
|
11
15
|
*/
|
|
12
16
|
export declare function assertSafeServiceEndpoint(endpoint: string): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gvnrdao/dh-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.274",
|
|
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",
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
},
|
|
82
82
|
"sideEffects": false,
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@gvnrdao/dh-lit-actions": "^0.0.
|
|
85
|
-
"@gvnrdao/dh-lit-ops": "^0.0.
|
|
84
|
+
"@gvnrdao/dh-lit-actions": "^0.0.306",
|
|
85
|
+
"@gvnrdao/dh-lit-ops": "^0.0.293",
|
|
86
86
|
"@noble/hashes": "^1.5.0",
|
|
87
87
|
"axios": "^1.15.2",
|
|
88
88
|
"bech32": "^2.0.0",
|