@gvnrdao/dh-sdk 0.0.218 → 0.0.220
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/dist/index.js +69 -66
- package/dist/index.mjs +69 -66
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -12685,9 +12685,9 @@ var require_elliptic = __commonJS({
|
|
|
12685
12685
|
}
|
|
12686
12686
|
});
|
|
12687
12687
|
|
|
12688
|
-
//
|
|
12688
|
+
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js
|
|
12689
12689
|
var require_pkg_src = __commonJS({
|
|
12690
|
-
"
|
|
12690
|
+
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js"(exports, module2) {
|
|
12691
12691
|
"use strict";
|
|
12692
12692
|
var __defProp2 = Object.defineProperty;
|
|
12693
12693
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -13426,17 +13426,17 @@ var require_pkg_src = __commonJS({
|
|
|
13426
13426
|
}
|
|
13427
13427
|
},
|
|
13428
13428
|
btcWithdrawal: {
|
|
13429
|
-
cid: "
|
|
13429
|
+
cid: "QmQC7QKobtNJKArGK7rgGj8ZCcEWt1pBKXPyd5SZ2fi4tt",
|
|
13430
13430
|
authorizedCidHex: cidToHex(
|
|
13431
|
-
"
|
|
13431
|
+
"QmQC7QKobtNJKArGK7rgGj8ZCcEWt1pBKXPyd5SZ2fi4tt"
|
|
13432
13432
|
),
|
|
13433
13433
|
name: "Btc Withdrawal",
|
|
13434
13434
|
description: "Production Btc Withdrawal",
|
|
13435
|
-
version: "1.0.
|
|
13435
|
+
version: "1.0.1",
|
|
13436
13436
|
deployed: true,
|
|
13437
|
-
deployedAt:
|
|
13438
|
-
size:
|
|
13439
|
-
hash: "
|
|
13437
|
+
deployedAt: 1777474196351,
|
|
13438
|
+
size: 72236,
|
|
13439
|
+
hash: "5d2d3672dfa4027fd17d6bf4740995561ccc4dbe1ed388be19c241ecf5f4018f",
|
|
13440
13440
|
validatorWalletAddress: "0xbb137fbda353199e9419b698c57a742124d4987d",
|
|
13441
13441
|
pkp: {
|
|
13442
13442
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
@@ -37158,12 +37158,6 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37158
37158
|
* @param config - SDK configuration
|
|
37159
37159
|
*/
|
|
37160
37160
|
constructor(config) {
|
|
37161
|
-
console.log(
|
|
37162
|
-
"[DEBUG] Constructor START - config keys:",
|
|
37163
|
-
Object.keys(config),
|
|
37164
|
-
"serviceEndpoint:",
|
|
37165
|
-
config["serviceEndpoint"]
|
|
37166
|
-
);
|
|
37167
37161
|
if (!config.provider && config.ethRpcUrl) {
|
|
37168
37162
|
config.provider = new ethers_exports.providers.JsonRpcProvider(config.ethRpcUrl);
|
|
37169
37163
|
}
|
|
@@ -37174,12 +37168,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37174
37168
|
network: config.litNetwork
|
|
37175
37169
|
});
|
|
37176
37170
|
}
|
|
37177
|
-
console.log("[DEBUG] Before CacheManager init");
|
|
37178
37171
|
this.cacheManager = new CacheManager({
|
|
37179
37172
|
debug: config.debug
|
|
37180
37173
|
});
|
|
37181
|
-
console.log("[DEBUG] After CacheManager init");
|
|
37182
|
-
console.log("[DEBUG] Before ContractManager init");
|
|
37183
37174
|
const contractManagerResult = createContractManager({
|
|
37184
37175
|
provider: config.provider,
|
|
37185
37176
|
signer: config.contractSigner,
|
|
@@ -37359,17 +37350,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37359
37350
|
*/
|
|
37360
37351
|
static async create(config) {
|
|
37361
37352
|
const userProvidedServiceEndpoint = config.serviceEndpoint;
|
|
37362
|
-
console.log(
|
|
37363
|
-
"[DEBUG] DiamondHandsSDK.create - userProvidedServiceEndpoint:",
|
|
37364
|
-
userProvidedServiceEndpoint
|
|
37365
|
-
);
|
|
37366
37353
|
const enrichedConfig = await _DiamondHandsSDK.enrichConfigWithNetworkDefaults(config);
|
|
37367
37354
|
if (userProvidedServiceEndpoint) {
|
|
37368
37355
|
enrichedConfig.serviceEndpoint = userProvidedServiceEndpoint;
|
|
37369
|
-
console.log(
|
|
37370
|
-
"[DEBUG] DiamondHandsSDK.create - restored userProvidedServiceEndpoint:",
|
|
37371
|
-
userProvidedServiceEndpoint
|
|
37372
|
-
);
|
|
37373
37356
|
}
|
|
37374
37357
|
const configError = validateSDKConfig(enrichedConfig);
|
|
37375
37358
|
if (configError) {
|
|
@@ -37409,10 +37392,6 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37409
37392
|
*/
|
|
37410
37393
|
static async enrichConfigWithNetworkDefaults(config) {
|
|
37411
37394
|
const { getNetworkConfig: getNetworkConfig2, getNetworkConfigByName: getNetworkConfigByName2 } = await Promise.resolve().then(() => (init_network_configs(), network_configs_exports));
|
|
37412
|
-
console.log(
|
|
37413
|
-
"[DEBUG] enrichConfigWithNetworkDefaults - input config.serviceEndpoint:",
|
|
37414
|
-
config.serviceEndpoint
|
|
37415
|
-
);
|
|
37416
37395
|
let chainId = config.chainId;
|
|
37417
37396
|
if (!chainId) {
|
|
37418
37397
|
try {
|
|
@@ -37497,9 +37476,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37497
37476
|
...config.contractAddresses || {}
|
|
37498
37477
|
// User-provided individual overrides (only specified fields)
|
|
37499
37478
|
};
|
|
37500
|
-
|
|
37501
|
-
"[SDK] enrichConfigWithNetworkDefaults - contractAddresses after merge",
|
|
37502
|
-
{
|
|
37479
|
+
if (config.debug) {
|
|
37480
|
+
log.info("[SDK] enrichConfigWithNetworkDefaults - contractAddresses after merge", {
|
|
37503
37481
|
keys: Object.keys(enrichedConfig.contractAddresses || {}),
|
|
37504
37482
|
hasPositionManager: !!enrichedConfig.contractAddresses?.positionManager,
|
|
37505
37483
|
hasLoanOperationsManager: !!enrichedConfig.contractAddresses?.loanOperationsManager,
|
|
@@ -37509,8 +37487,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37509
37487
|
loanOperationsManager: enrichedConfig.contractAddresses?.loanOperationsManager || "MISSING",
|
|
37510
37488
|
termManager: enrichedConfig.contractAddresses?.termManager || "MISSING",
|
|
37511
37489
|
ucdController: enrichedConfig.contractAddresses?.ucdController || "MISSING"
|
|
37512
|
-
}
|
|
37513
|
-
|
|
37490
|
+
});
|
|
37491
|
+
}
|
|
37514
37492
|
if (config.debug) {
|
|
37515
37493
|
log.info("\u2705 Contract addresses loaded from network config", {
|
|
37516
37494
|
overridden: Object.keys(config.contractAddresses || {}).length,
|
|
@@ -37529,10 +37507,6 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37529
37507
|
});
|
|
37530
37508
|
}
|
|
37531
37509
|
}
|
|
37532
|
-
console.log(
|
|
37533
|
-
"[DEBUG] enrichConfigWithNetworkDefaults - output config.serviceEndpoint:",
|
|
37534
|
-
enrichedConfig.serviceEndpoint
|
|
37535
|
-
);
|
|
37536
37510
|
if (!enrichedConfig.validators) {
|
|
37537
37511
|
enrichedConfig.validators = {
|
|
37538
37512
|
loanCreation: 1,
|
|
@@ -41024,11 +40998,13 @@ Error data: ${errorData || "none"}`
|
|
|
41024
40998
|
transactionHash: transactionHash || "none"
|
|
41025
40999
|
});
|
|
41026
41000
|
}
|
|
41027
|
-
|
|
41028
|
-
error:
|
|
41029
|
-
|
|
41030
|
-
|
|
41031
|
-
|
|
41001
|
+
if (this.config.debug) {
|
|
41002
|
+
log.error("\u274C PAYMENT ERROR:", {
|
|
41003
|
+
error: errorMsg,
|
|
41004
|
+
errorType: typeof error,
|
|
41005
|
+
transactionHash: transactionHash || "none"
|
|
41006
|
+
});
|
|
41007
|
+
}
|
|
41032
41008
|
if (this.config.debug) {
|
|
41033
41009
|
log.error("\u274C Payment failed", {
|
|
41034
41010
|
transactionHash: transactionHash || "not available",
|
|
@@ -41553,32 +41529,59 @@ Error data: ${errorData || "none"}`
|
|
|
41553
41529
|
} catch (txError) {
|
|
41554
41530
|
const txErrorMsg = txError instanceof Error ? txError.message : String(txError);
|
|
41555
41531
|
if (this.config.debug) {
|
|
41556
|
-
log.
|
|
41557
|
-
|
|
41558
|
-
|
|
41559
|
-
|
|
41560
|
-
});
|
|
41532
|
+
log.warn(
|
|
41533
|
+
"\u26A0\uFE0F withdrawBTC contract interface failed, falling back to raw transaction",
|
|
41534
|
+
{ error: txErrorMsg }
|
|
41535
|
+
);
|
|
41561
41536
|
}
|
|
41562
41537
|
try {
|
|
41563
|
-
const
|
|
41564
|
-
const
|
|
41565
|
-
|
|
41566
|
-
|
|
41567
|
-
|
|
41568
|
-
|
|
41569
|
-
|
|
41570
|
-
|
|
41571
|
-
|
|
41572
|
-
|
|
41573
|
-
|
|
41574
|
-
|
|
41575
|
-
|
|
41576
|
-
|
|
41538
|
+
const contractAddress = this.getContractAddressesOrThrow().positionManager;
|
|
41539
|
+
const iface = new ethers_exports.utils.Interface([
|
|
41540
|
+
"function withdrawBTC((bytes32 positionId, bytes32 actionHash, bytes32 authorizedSpendsHash, bytes32 ucdDebtHash, bytes32 contractBundleHash, string withdrawalAddress, uint256 totalDeduction, uint256 newCollateral, uint256 quantumTimestamp, uint256 btcPrice, string utxoTxid, uint32 utxoVout) params, bytes withdrawalValidatorSignature, bytes btcSpendAuthSignature) external returns (bool)"
|
|
41541
|
+
]);
|
|
41542
|
+
const calldata = iface.encodeFunctionData("withdrawBTC", [
|
|
41543
|
+
withdrawalParams,
|
|
41544
|
+
signatureBytes,
|
|
41545
|
+
btcSpendAuthBytes
|
|
41546
|
+
]);
|
|
41547
|
+
const signer = this.getSignerOrThrow();
|
|
41548
|
+
tx = await signer.sendTransaction({
|
|
41549
|
+
to: contractAddress,
|
|
41550
|
+
data: calldata,
|
|
41551
|
+
value: "0x0",
|
|
41552
|
+
gasLimit: 1e6
|
|
41553
|
+
});
|
|
41554
|
+
if (this.config.debug) {
|
|
41555
|
+
log.info("\u2705 withdrawBTC raw transaction fallback succeeded", {
|
|
41556
|
+
txHash: tx.hash
|
|
41557
|
+
});
|
|
41558
|
+
}
|
|
41559
|
+
} catch (rawError) {
|
|
41560
|
+
const rawErrorMsg = rawError instanceof Error ? rawError.message : String(rawError);
|
|
41561
|
+
if (this.config.debug) {
|
|
41562
|
+
log.error("\u274C withdrawBTC transaction failed (raw fallback also failed)", {
|
|
41563
|
+
error: rawErrorMsg,
|
|
41564
|
+
withdrawalParams,
|
|
41565
|
+
signatureBytesLength: signatureBytes.length
|
|
41566
|
+
});
|
|
41567
|
+
}
|
|
41568
|
+
try {
|
|
41569
|
+
const position = await this.getPosition(positionId);
|
|
41570
|
+
const btcAmount = (Number(withdrawalAmount) / 1e8).toFixed(8);
|
|
41571
|
+
const message = formatBTCWithdrawalFailureMessage(
|
|
41572
|
+
btcAmount,
|
|
41573
|
+
position?.vaultAddress || "unknown",
|
|
41574
|
+
withdrawalAddress,
|
|
41575
|
+
positionId
|
|
41576
|
+
);
|
|
41577
|
+
await this._relayNotification(message);
|
|
41578
|
+
} catch {
|
|
41579
|
+
}
|
|
41580
|
+
return {
|
|
41581
|
+
success: false,
|
|
41582
|
+
error: `Transaction submission failed: ${rawErrorMsg}`
|
|
41583
|
+
};
|
|
41577
41584
|
}
|
|
41578
|
-
return {
|
|
41579
|
-
success: false,
|
|
41580
|
-
error: `Transaction submission failed: ${txErrorMsg}`
|
|
41581
|
-
};
|
|
41582
41585
|
}
|
|
41583
41586
|
if (this.config.debug) {
|
|
41584
41587
|
log.info("\u2705 Transaction submitted, waiting for confirmation:", {
|
package/dist/index.mjs
CHANGED
|
@@ -12691,9 +12691,9 @@ var require_elliptic = __commonJS({
|
|
|
12691
12691
|
}
|
|
12692
12692
|
});
|
|
12693
12693
|
|
|
12694
|
-
//
|
|
12694
|
+
// node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js
|
|
12695
12695
|
var require_pkg_src = __commonJS({
|
|
12696
|
-
"
|
|
12696
|
+
"node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js"(exports, module) {
|
|
12697
12697
|
"use strict";
|
|
12698
12698
|
var __defProp2 = Object.defineProperty;
|
|
12699
12699
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -13432,17 +13432,17 @@ var require_pkg_src = __commonJS({
|
|
|
13432
13432
|
}
|
|
13433
13433
|
},
|
|
13434
13434
|
btcWithdrawal: {
|
|
13435
|
-
cid: "
|
|
13435
|
+
cid: "QmQC7QKobtNJKArGK7rgGj8ZCcEWt1pBKXPyd5SZ2fi4tt",
|
|
13436
13436
|
authorizedCidHex: cidToHex(
|
|
13437
|
-
"
|
|
13437
|
+
"QmQC7QKobtNJKArGK7rgGj8ZCcEWt1pBKXPyd5SZ2fi4tt"
|
|
13438
13438
|
),
|
|
13439
13439
|
name: "Btc Withdrawal",
|
|
13440
13440
|
description: "Production Btc Withdrawal",
|
|
13441
|
-
version: "1.0.
|
|
13441
|
+
version: "1.0.1",
|
|
13442
13442
|
deployed: true,
|
|
13443
|
-
deployedAt:
|
|
13444
|
-
size:
|
|
13445
|
-
hash: "
|
|
13443
|
+
deployedAt: 1777474196351,
|
|
13444
|
+
size: 72236,
|
|
13445
|
+
hash: "5d2d3672dfa4027fd17d6bf4740995561ccc4dbe1ed388be19c241ecf5f4018f",
|
|
13446
13446
|
validatorWalletAddress: "0xbb137fbda353199e9419b698c57a742124d4987d",
|
|
13447
13447
|
pkp: {
|
|
13448
13448
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
@@ -37086,12 +37086,6 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37086
37086
|
* @param config - SDK configuration
|
|
37087
37087
|
*/
|
|
37088
37088
|
constructor(config) {
|
|
37089
|
-
console.log(
|
|
37090
|
-
"[DEBUG] Constructor START - config keys:",
|
|
37091
|
-
Object.keys(config),
|
|
37092
|
-
"serviceEndpoint:",
|
|
37093
|
-
config["serviceEndpoint"]
|
|
37094
|
-
);
|
|
37095
37089
|
if (!config.provider && config.ethRpcUrl) {
|
|
37096
37090
|
config.provider = new ethers_exports.providers.JsonRpcProvider(config.ethRpcUrl);
|
|
37097
37091
|
}
|
|
@@ -37102,12 +37096,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37102
37096
|
network: config.litNetwork
|
|
37103
37097
|
});
|
|
37104
37098
|
}
|
|
37105
|
-
console.log("[DEBUG] Before CacheManager init");
|
|
37106
37099
|
this.cacheManager = new CacheManager({
|
|
37107
37100
|
debug: config.debug
|
|
37108
37101
|
});
|
|
37109
|
-
console.log("[DEBUG] After CacheManager init");
|
|
37110
|
-
console.log("[DEBUG] Before ContractManager init");
|
|
37111
37102
|
const contractManagerResult = createContractManager({
|
|
37112
37103
|
provider: config.provider,
|
|
37113
37104
|
signer: config.contractSigner,
|
|
@@ -37287,17 +37278,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37287
37278
|
*/
|
|
37288
37279
|
static async create(config) {
|
|
37289
37280
|
const userProvidedServiceEndpoint = config.serviceEndpoint;
|
|
37290
|
-
console.log(
|
|
37291
|
-
"[DEBUG] DiamondHandsSDK.create - userProvidedServiceEndpoint:",
|
|
37292
|
-
userProvidedServiceEndpoint
|
|
37293
|
-
);
|
|
37294
37281
|
const enrichedConfig = await _DiamondHandsSDK.enrichConfigWithNetworkDefaults(config);
|
|
37295
37282
|
if (userProvidedServiceEndpoint) {
|
|
37296
37283
|
enrichedConfig.serviceEndpoint = userProvidedServiceEndpoint;
|
|
37297
|
-
console.log(
|
|
37298
|
-
"[DEBUG] DiamondHandsSDK.create - restored userProvidedServiceEndpoint:",
|
|
37299
|
-
userProvidedServiceEndpoint
|
|
37300
|
-
);
|
|
37301
37284
|
}
|
|
37302
37285
|
const configError = validateSDKConfig(enrichedConfig);
|
|
37303
37286
|
if (configError) {
|
|
@@ -37337,10 +37320,6 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37337
37320
|
*/
|
|
37338
37321
|
static async enrichConfigWithNetworkDefaults(config) {
|
|
37339
37322
|
const { getNetworkConfig: getNetworkConfig2, getNetworkConfigByName: getNetworkConfigByName2 } = await Promise.resolve().then(() => (init_network_configs(), network_configs_exports));
|
|
37340
|
-
console.log(
|
|
37341
|
-
"[DEBUG] enrichConfigWithNetworkDefaults - input config.serviceEndpoint:",
|
|
37342
|
-
config.serviceEndpoint
|
|
37343
|
-
);
|
|
37344
37323
|
let chainId = config.chainId;
|
|
37345
37324
|
if (!chainId) {
|
|
37346
37325
|
try {
|
|
@@ -37425,9 +37404,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37425
37404
|
...config.contractAddresses || {}
|
|
37426
37405
|
// User-provided individual overrides (only specified fields)
|
|
37427
37406
|
};
|
|
37428
|
-
|
|
37429
|
-
"[SDK] enrichConfigWithNetworkDefaults - contractAddresses after merge",
|
|
37430
|
-
{
|
|
37407
|
+
if (config.debug) {
|
|
37408
|
+
log.info("[SDK] enrichConfigWithNetworkDefaults - contractAddresses after merge", {
|
|
37431
37409
|
keys: Object.keys(enrichedConfig.contractAddresses || {}),
|
|
37432
37410
|
hasPositionManager: !!enrichedConfig.contractAddresses?.positionManager,
|
|
37433
37411
|
hasLoanOperationsManager: !!enrichedConfig.contractAddresses?.loanOperationsManager,
|
|
@@ -37437,8 +37415,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37437
37415
|
loanOperationsManager: enrichedConfig.contractAddresses?.loanOperationsManager || "MISSING",
|
|
37438
37416
|
termManager: enrichedConfig.contractAddresses?.termManager || "MISSING",
|
|
37439
37417
|
ucdController: enrichedConfig.contractAddresses?.ucdController || "MISSING"
|
|
37440
|
-
}
|
|
37441
|
-
|
|
37418
|
+
});
|
|
37419
|
+
}
|
|
37442
37420
|
if (config.debug) {
|
|
37443
37421
|
log.info("\u2705 Contract addresses loaded from network config", {
|
|
37444
37422
|
overridden: Object.keys(config.contractAddresses || {}).length,
|
|
@@ -37457,10 +37435,6 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
37457
37435
|
});
|
|
37458
37436
|
}
|
|
37459
37437
|
}
|
|
37460
|
-
console.log(
|
|
37461
|
-
"[DEBUG] enrichConfigWithNetworkDefaults - output config.serviceEndpoint:",
|
|
37462
|
-
enrichedConfig.serviceEndpoint
|
|
37463
|
-
);
|
|
37464
37438
|
if (!enrichedConfig.validators) {
|
|
37465
37439
|
enrichedConfig.validators = {
|
|
37466
37440
|
loanCreation: 1,
|
|
@@ -40952,11 +40926,13 @@ Error data: ${errorData || "none"}`
|
|
|
40952
40926
|
transactionHash: transactionHash || "none"
|
|
40953
40927
|
});
|
|
40954
40928
|
}
|
|
40955
|
-
|
|
40956
|
-
error:
|
|
40957
|
-
|
|
40958
|
-
|
|
40959
|
-
|
|
40929
|
+
if (this.config.debug) {
|
|
40930
|
+
log.error("\u274C PAYMENT ERROR:", {
|
|
40931
|
+
error: errorMsg,
|
|
40932
|
+
errorType: typeof error,
|
|
40933
|
+
transactionHash: transactionHash || "none"
|
|
40934
|
+
});
|
|
40935
|
+
}
|
|
40960
40936
|
if (this.config.debug) {
|
|
40961
40937
|
log.error("\u274C Payment failed", {
|
|
40962
40938
|
transactionHash: transactionHash || "not available",
|
|
@@ -41481,32 +41457,59 @@ Error data: ${errorData || "none"}`
|
|
|
41481
41457
|
} catch (txError) {
|
|
41482
41458
|
const txErrorMsg = txError instanceof Error ? txError.message : String(txError);
|
|
41483
41459
|
if (this.config.debug) {
|
|
41484
|
-
log.
|
|
41485
|
-
|
|
41486
|
-
|
|
41487
|
-
|
|
41488
|
-
});
|
|
41460
|
+
log.warn(
|
|
41461
|
+
"\u26A0\uFE0F withdrawBTC contract interface failed, falling back to raw transaction",
|
|
41462
|
+
{ error: txErrorMsg }
|
|
41463
|
+
);
|
|
41489
41464
|
}
|
|
41490
41465
|
try {
|
|
41491
|
-
const
|
|
41492
|
-
const
|
|
41493
|
-
|
|
41494
|
-
|
|
41495
|
-
|
|
41496
|
-
|
|
41497
|
-
|
|
41498
|
-
|
|
41499
|
-
|
|
41500
|
-
|
|
41501
|
-
|
|
41502
|
-
|
|
41503
|
-
|
|
41504
|
-
|
|
41466
|
+
const contractAddress = this.getContractAddressesOrThrow().positionManager;
|
|
41467
|
+
const iface = new ethers_exports.utils.Interface([
|
|
41468
|
+
"function withdrawBTC((bytes32 positionId, bytes32 actionHash, bytes32 authorizedSpendsHash, bytes32 ucdDebtHash, bytes32 contractBundleHash, string withdrawalAddress, uint256 totalDeduction, uint256 newCollateral, uint256 quantumTimestamp, uint256 btcPrice, string utxoTxid, uint32 utxoVout) params, bytes withdrawalValidatorSignature, bytes btcSpendAuthSignature) external returns (bool)"
|
|
41469
|
+
]);
|
|
41470
|
+
const calldata = iface.encodeFunctionData("withdrawBTC", [
|
|
41471
|
+
withdrawalParams,
|
|
41472
|
+
signatureBytes,
|
|
41473
|
+
btcSpendAuthBytes
|
|
41474
|
+
]);
|
|
41475
|
+
const signer = this.getSignerOrThrow();
|
|
41476
|
+
tx = await signer.sendTransaction({
|
|
41477
|
+
to: contractAddress,
|
|
41478
|
+
data: calldata,
|
|
41479
|
+
value: "0x0",
|
|
41480
|
+
gasLimit: 1e6
|
|
41481
|
+
});
|
|
41482
|
+
if (this.config.debug) {
|
|
41483
|
+
log.info("\u2705 withdrawBTC raw transaction fallback succeeded", {
|
|
41484
|
+
txHash: tx.hash
|
|
41485
|
+
});
|
|
41486
|
+
}
|
|
41487
|
+
} catch (rawError) {
|
|
41488
|
+
const rawErrorMsg = rawError instanceof Error ? rawError.message : String(rawError);
|
|
41489
|
+
if (this.config.debug) {
|
|
41490
|
+
log.error("\u274C withdrawBTC transaction failed (raw fallback also failed)", {
|
|
41491
|
+
error: rawErrorMsg,
|
|
41492
|
+
withdrawalParams,
|
|
41493
|
+
signatureBytesLength: signatureBytes.length
|
|
41494
|
+
});
|
|
41495
|
+
}
|
|
41496
|
+
try {
|
|
41497
|
+
const position = await this.getPosition(positionId);
|
|
41498
|
+
const btcAmount = (Number(withdrawalAmount) / 1e8).toFixed(8);
|
|
41499
|
+
const message = formatBTCWithdrawalFailureMessage(
|
|
41500
|
+
btcAmount,
|
|
41501
|
+
position?.vaultAddress || "unknown",
|
|
41502
|
+
withdrawalAddress,
|
|
41503
|
+
positionId
|
|
41504
|
+
);
|
|
41505
|
+
await this._relayNotification(message);
|
|
41506
|
+
} catch {
|
|
41507
|
+
}
|
|
41508
|
+
return {
|
|
41509
|
+
success: false,
|
|
41510
|
+
error: `Transaction submission failed: ${rawErrorMsg}`
|
|
41511
|
+
};
|
|
41505
41512
|
}
|
|
41506
|
-
return {
|
|
41507
|
-
success: false,
|
|
41508
|
-
error: `Transaction submission failed: ${txErrorMsg}`
|
|
41509
|
-
};
|
|
41510
41513
|
}
|
|
41511
41514
|
if (this.config.debug) {
|
|
41512
41515
|
log.info("\u2705 Transaction submitted, waiting for confirmation:", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gvnrdao/dh-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.220",
|
|
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",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
},
|
|
71
71
|
"sideEffects": false,
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@gvnrdao/dh-lit-actions": "^0.0.
|
|
74
|
-
"@gvnrdao/dh-lit-ops": "^0.0.
|
|
73
|
+
"@gvnrdao/dh-lit-actions": "^0.0.284",
|
|
74
|
+
"@gvnrdao/dh-lit-ops": "^0.0.256",
|
|
75
75
|
"@noble/hashes": "^1.5.0",
|
|
76
76
|
"axios": "^1.15.2",
|
|
77
77
|
"bech32": "^2.0.0",
|