@gvnrdao/dh-sdk 0.0.143 → 0.0.144
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 +2 -2
- package/dist/index.js +64 -12
- package/dist/index.mjs +64 -12
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -12746,7 +12746,7 @@ var init_deployment_addresses = __esm({
|
|
|
12746
12746
|
LOCALHOST_DEPLOYMENT = {
|
|
12747
12747
|
"network": "localhost",
|
|
12748
12748
|
"chainId": 31337,
|
|
12749
|
-
"timestamp": "2026-01-
|
|
12749
|
+
"timestamp": "2026-01-14T14:31:57.573Z",
|
|
12750
12750
|
"deployer": "",
|
|
12751
12751
|
"contracts": {
|
|
12752
12752
|
"UpgradeValidator": "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6",
|
|
@@ -48010,7 +48010,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
48010
48010
|
loanCreation: 1,
|
|
48011
48011
|
// Default PKP security validation version
|
|
48012
48012
|
minting: 4,
|
|
48013
|
-
// Default business rules validation version
|
|
48013
|
+
// Default business rules validation version
|
|
48014
48014
|
payment: 1,
|
|
48015
48015
|
// Default payment validation version
|
|
48016
48016
|
extension: 4
|
|
@@ -48692,7 +48692,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
48692
48692
|
* @returns Transaction receipt
|
|
48693
48693
|
*/
|
|
48694
48694
|
async extendPosition(_positionId, _selectedTerm) {
|
|
48695
|
-
throw new Error(
|
|
48695
|
+
throw new Error(
|
|
48696
|
+
"extendPosition not yet implemented - requires requestExtendAuthorization in lit-ops"
|
|
48697
|
+
);
|
|
48696
48698
|
}
|
|
48697
48699
|
/**
|
|
48698
48700
|
* Make a payment on a loan position
|
|
@@ -49036,7 +49038,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
49036
49038
|
},
|
|
49037
49039
|
userSignature: auth.signature,
|
|
49038
49040
|
customRpcUrl,
|
|
49039
|
-
customBitcoinRpcUrl
|
|
49041
|
+
customBitcoinRpcUrl,
|
|
49042
|
+
priceProviders: this.config.priceProviders
|
|
49043
|
+
// Pass price provider API keys
|
|
49040
49044
|
});
|
|
49041
49045
|
if (this.config.debug) {
|
|
49042
49046
|
log.info(` Withdrawal Auth Result (attempt ${attempt}):`, {
|
|
@@ -49198,7 +49202,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
49198
49202
|
const positionManagerContract = new ethers_exports.Contract(
|
|
49199
49203
|
this.config.contractAddresses.positionManager,
|
|
49200
49204
|
[
|
|
49201
|
-
"function withdrawBTC((bytes32 positionId, bytes32 actionHash, bytes32 authorizedSpendsHash, bytes32 ucdDebtHash, string withdrawalAddress, uint256 totalDeduction, uint256 newCollateral, uint256 quantumTimestamp, uint256 btcPrice, string utxoTxid, uint32 utxoVout) params, bytes signature) external returns (bool)"
|
|
49205
|
+
"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 signature) external returns (bool)"
|
|
49202
49206
|
],
|
|
49203
49207
|
this.config.contractSigner
|
|
49204
49208
|
);
|
|
@@ -49207,6 +49211,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
49207
49211
|
actionHash: validationResponse.actionHash,
|
|
49208
49212
|
authorizedSpendsHash: validationResponse.authorizedSpendsHash,
|
|
49209
49213
|
ucdDebtHash: validationResponse.ucdDebtHash,
|
|
49214
|
+
contractBundleHash: validationResponse.contractBundleHash,
|
|
49210
49215
|
withdrawalAddress: validationResponse.destinationAddress,
|
|
49211
49216
|
totalDeduction: validationResponse.totalDeduction,
|
|
49212
49217
|
newCollateral: validationResponse.remainingCollateral,
|
|
@@ -49217,20 +49222,67 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
49217
49222
|
utxoVout: validationResponse.utxoVout
|
|
49218
49223
|
// Real Bitcoin UTXO vout
|
|
49219
49224
|
};
|
|
49220
|
-
|
|
49221
|
-
|
|
49222
|
-
|
|
49223
|
-
|
|
49225
|
+
if (this.config.debug) {
|
|
49226
|
+
log.info("\u{1F4DD} Withdrawal params before transaction:", {
|
|
49227
|
+
positionId: withdrawalParams.positionId,
|
|
49228
|
+
actionHash: withdrawalParams.actionHash,
|
|
49229
|
+
authorizedSpendsHash: withdrawalParams.authorizedSpendsHash,
|
|
49230
|
+
ucdDebtHash: withdrawalParams.ucdDebtHash,
|
|
49231
|
+
contractBundleHash: withdrawalParams.contractBundleHash,
|
|
49232
|
+
withdrawalAddress: withdrawalParams.withdrawalAddress,
|
|
49233
|
+
totalDeduction: withdrawalParams.totalDeduction?.toString(),
|
|
49234
|
+
newCollateral: withdrawalParams.newCollateral?.toString(),
|
|
49235
|
+
quantumTimestamp: withdrawalParams.quantumTimestamp?.toString(),
|
|
49236
|
+
btcPrice: withdrawalParams.btcPrice?.toString(),
|
|
49237
|
+
utxoTxid: withdrawalParams.utxoTxid,
|
|
49238
|
+
utxoVout: withdrawalParams.utxoVout
|
|
49239
|
+
});
|
|
49240
|
+
}
|
|
49241
|
+
let tx;
|
|
49242
|
+
try {
|
|
49243
|
+
tx = await positionManagerContract["withdrawBTC"](
|
|
49244
|
+
withdrawalParams,
|
|
49245
|
+
signatureBytes
|
|
49246
|
+
);
|
|
49247
|
+
} catch (txError) {
|
|
49248
|
+
const txErrorMsg = txError instanceof Error ? txError.message : String(txError);
|
|
49249
|
+
if (this.config.debug) {
|
|
49250
|
+
log.error("\u274C withdrawBTC transaction failed", {
|
|
49251
|
+
error: txErrorMsg,
|
|
49252
|
+
withdrawalParams,
|
|
49253
|
+
signatureBytesLength: signatureBytes.length
|
|
49254
|
+
});
|
|
49255
|
+
}
|
|
49256
|
+
return {
|
|
49257
|
+
success: false,
|
|
49258
|
+
error: `Transaction submission failed: ${txErrorMsg}`
|
|
49259
|
+
};
|
|
49260
|
+
}
|
|
49224
49261
|
if (this.config.debug) {
|
|
49225
49262
|
log.info("\u2705 Transaction submitted, waiting for confirmation:", {
|
|
49226
49263
|
txHash: tx.hash
|
|
49227
49264
|
});
|
|
49228
49265
|
}
|
|
49229
|
-
|
|
49266
|
+
let receipt;
|
|
49267
|
+
try {
|
|
49268
|
+
receipt = await tx.wait();
|
|
49269
|
+
} catch (waitError) {
|
|
49270
|
+
const waitErrorMsg = waitError instanceof Error ? waitError.message : String(waitError);
|
|
49271
|
+
if (this.config.debug) {
|
|
49272
|
+
log.error("\u274C Transaction wait failed", {
|
|
49273
|
+
error: waitErrorMsg,
|
|
49274
|
+
txHash: tx.hash
|
|
49275
|
+
});
|
|
49276
|
+
}
|
|
49277
|
+
return {
|
|
49278
|
+
success: false,
|
|
49279
|
+
error: `Transaction confirmation failed: ${waitErrorMsg}`
|
|
49280
|
+
};
|
|
49281
|
+
}
|
|
49230
49282
|
if (this.config.debug) {
|
|
49231
49283
|
log.info("\u2705 BTC withdrawal confirmed", {
|
|
49232
49284
|
blockNumber: receipt.blockNumber,
|
|
49233
|
-
gasUsed: receipt.gasUsed
|
|
49285
|
+
gasUsed: receipt.gasUsed?.toString() || "unknown"
|
|
49234
49286
|
});
|
|
49235
49287
|
}
|
|
49236
49288
|
return {
|
|
@@ -49240,7 +49292,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
49240
49292
|
amountWithdrawn: withdrawalAmount.toString(),
|
|
49241
49293
|
evmTransactionHash: receipt.transactionHash,
|
|
49242
49294
|
blockNumber: receipt.blockNumber,
|
|
49243
|
-
gasUsed: receipt.gasUsed
|
|
49295
|
+
gasUsed: receipt.gasUsed?.toString() || "unknown",
|
|
49244
49296
|
utxoTxid: validationResponse.utxoTxid,
|
|
49245
49297
|
utxoVout: validationResponse.utxoVout
|
|
49246
49298
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -12752,7 +12752,7 @@ var init_deployment_addresses = __esm({
|
|
|
12752
12752
|
LOCALHOST_DEPLOYMENT = {
|
|
12753
12753
|
"network": "localhost",
|
|
12754
12754
|
"chainId": 31337,
|
|
12755
|
-
"timestamp": "2026-01-
|
|
12755
|
+
"timestamp": "2026-01-14T14:31:57.573Z",
|
|
12756
12756
|
"deployer": "",
|
|
12757
12757
|
"contracts": {
|
|
12758
12758
|
"UpgradeValidator": "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6",
|
|
@@ -47915,7 +47915,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
47915
47915
|
loanCreation: 1,
|
|
47916
47916
|
// Default PKP security validation version
|
|
47917
47917
|
minting: 4,
|
|
47918
|
-
// Default business rules validation version
|
|
47918
|
+
// Default business rules validation version
|
|
47919
47919
|
payment: 1,
|
|
47920
47920
|
// Default payment validation version
|
|
47921
47921
|
extension: 4
|
|
@@ -48597,7 +48597,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
48597
48597
|
* @returns Transaction receipt
|
|
48598
48598
|
*/
|
|
48599
48599
|
async extendPosition(_positionId, _selectedTerm) {
|
|
48600
|
-
throw new Error(
|
|
48600
|
+
throw new Error(
|
|
48601
|
+
"extendPosition not yet implemented - requires requestExtendAuthorization in lit-ops"
|
|
48602
|
+
);
|
|
48601
48603
|
}
|
|
48602
48604
|
/**
|
|
48603
48605
|
* Make a payment on a loan position
|
|
@@ -48941,7 +48943,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
48941
48943
|
},
|
|
48942
48944
|
userSignature: auth.signature,
|
|
48943
48945
|
customRpcUrl,
|
|
48944
|
-
customBitcoinRpcUrl
|
|
48946
|
+
customBitcoinRpcUrl,
|
|
48947
|
+
priceProviders: this.config.priceProviders
|
|
48948
|
+
// Pass price provider API keys
|
|
48945
48949
|
});
|
|
48946
48950
|
if (this.config.debug) {
|
|
48947
48951
|
log.info(` Withdrawal Auth Result (attempt ${attempt}):`, {
|
|
@@ -49103,7 +49107,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
49103
49107
|
const positionManagerContract = new ethers_exports.Contract(
|
|
49104
49108
|
this.config.contractAddresses.positionManager,
|
|
49105
49109
|
[
|
|
49106
|
-
"function withdrawBTC((bytes32 positionId, bytes32 actionHash, bytes32 authorizedSpendsHash, bytes32 ucdDebtHash, string withdrawalAddress, uint256 totalDeduction, uint256 newCollateral, uint256 quantumTimestamp, uint256 btcPrice, string utxoTxid, uint32 utxoVout) params, bytes signature) external returns (bool)"
|
|
49110
|
+
"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 signature) external returns (bool)"
|
|
49107
49111
|
],
|
|
49108
49112
|
this.config.contractSigner
|
|
49109
49113
|
);
|
|
@@ -49112,6 +49116,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
49112
49116
|
actionHash: validationResponse.actionHash,
|
|
49113
49117
|
authorizedSpendsHash: validationResponse.authorizedSpendsHash,
|
|
49114
49118
|
ucdDebtHash: validationResponse.ucdDebtHash,
|
|
49119
|
+
contractBundleHash: validationResponse.contractBundleHash,
|
|
49115
49120
|
withdrawalAddress: validationResponse.destinationAddress,
|
|
49116
49121
|
totalDeduction: validationResponse.totalDeduction,
|
|
49117
49122
|
newCollateral: validationResponse.remainingCollateral,
|
|
@@ -49122,20 +49127,67 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
49122
49127
|
utxoVout: validationResponse.utxoVout
|
|
49123
49128
|
// Real Bitcoin UTXO vout
|
|
49124
49129
|
};
|
|
49125
|
-
|
|
49126
|
-
|
|
49127
|
-
|
|
49128
|
-
|
|
49130
|
+
if (this.config.debug) {
|
|
49131
|
+
log.info("\u{1F4DD} Withdrawal params before transaction:", {
|
|
49132
|
+
positionId: withdrawalParams.positionId,
|
|
49133
|
+
actionHash: withdrawalParams.actionHash,
|
|
49134
|
+
authorizedSpendsHash: withdrawalParams.authorizedSpendsHash,
|
|
49135
|
+
ucdDebtHash: withdrawalParams.ucdDebtHash,
|
|
49136
|
+
contractBundleHash: withdrawalParams.contractBundleHash,
|
|
49137
|
+
withdrawalAddress: withdrawalParams.withdrawalAddress,
|
|
49138
|
+
totalDeduction: withdrawalParams.totalDeduction?.toString(),
|
|
49139
|
+
newCollateral: withdrawalParams.newCollateral?.toString(),
|
|
49140
|
+
quantumTimestamp: withdrawalParams.quantumTimestamp?.toString(),
|
|
49141
|
+
btcPrice: withdrawalParams.btcPrice?.toString(),
|
|
49142
|
+
utxoTxid: withdrawalParams.utxoTxid,
|
|
49143
|
+
utxoVout: withdrawalParams.utxoVout
|
|
49144
|
+
});
|
|
49145
|
+
}
|
|
49146
|
+
let tx;
|
|
49147
|
+
try {
|
|
49148
|
+
tx = await positionManagerContract["withdrawBTC"](
|
|
49149
|
+
withdrawalParams,
|
|
49150
|
+
signatureBytes
|
|
49151
|
+
);
|
|
49152
|
+
} catch (txError) {
|
|
49153
|
+
const txErrorMsg = txError instanceof Error ? txError.message : String(txError);
|
|
49154
|
+
if (this.config.debug) {
|
|
49155
|
+
log.error("\u274C withdrawBTC transaction failed", {
|
|
49156
|
+
error: txErrorMsg,
|
|
49157
|
+
withdrawalParams,
|
|
49158
|
+
signatureBytesLength: signatureBytes.length
|
|
49159
|
+
});
|
|
49160
|
+
}
|
|
49161
|
+
return {
|
|
49162
|
+
success: false,
|
|
49163
|
+
error: `Transaction submission failed: ${txErrorMsg}`
|
|
49164
|
+
};
|
|
49165
|
+
}
|
|
49129
49166
|
if (this.config.debug) {
|
|
49130
49167
|
log.info("\u2705 Transaction submitted, waiting for confirmation:", {
|
|
49131
49168
|
txHash: tx.hash
|
|
49132
49169
|
});
|
|
49133
49170
|
}
|
|
49134
|
-
|
|
49171
|
+
let receipt;
|
|
49172
|
+
try {
|
|
49173
|
+
receipt = await tx.wait();
|
|
49174
|
+
} catch (waitError) {
|
|
49175
|
+
const waitErrorMsg = waitError instanceof Error ? waitError.message : String(waitError);
|
|
49176
|
+
if (this.config.debug) {
|
|
49177
|
+
log.error("\u274C Transaction wait failed", {
|
|
49178
|
+
error: waitErrorMsg,
|
|
49179
|
+
txHash: tx.hash
|
|
49180
|
+
});
|
|
49181
|
+
}
|
|
49182
|
+
return {
|
|
49183
|
+
success: false,
|
|
49184
|
+
error: `Transaction confirmation failed: ${waitErrorMsg}`
|
|
49185
|
+
};
|
|
49186
|
+
}
|
|
49135
49187
|
if (this.config.debug) {
|
|
49136
49188
|
log.info("\u2705 BTC withdrawal confirmed", {
|
|
49137
49189
|
blockNumber: receipt.blockNumber,
|
|
49138
|
-
gasUsed: receipt.gasUsed
|
|
49190
|
+
gasUsed: receipt.gasUsed?.toString() || "unknown"
|
|
49139
49191
|
});
|
|
49140
49192
|
}
|
|
49141
49193
|
return {
|
|
@@ -49145,7 +49197,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
49145
49197
|
amountWithdrawn: withdrawalAmount.toString(),
|
|
49146
49198
|
evmTransactionHash: receipt.transactionHash,
|
|
49147
49199
|
blockNumber: receipt.blockNumber,
|
|
49148
|
-
gasUsed: receipt.gasUsed
|
|
49200
|
+
gasUsed: receipt.gasUsed?.toString() || "unknown",
|
|
49149
49201
|
utxoTxid: validationResponse.utxoTxid,
|
|
49150
49202
|
utxoVout: validationResponse.utxoVout
|
|
49151
49203
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gvnrdao/dh-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.144",
|
|
4
4
|
"description": "TypeScript SDK for Diamond Hands Protocol - Bitcoin-backed lending with LIT Protocol PKPs",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"author": "Diamond Hands Protocol",
|
|
50
50
|
"license": "MIT",
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@gvnrdao/dh-lit-actions": "^0.0.
|
|
53
|
-
"@gvnrdao/dh-lit-ops": "^0.0.
|
|
52
|
+
"@gvnrdao/dh-lit-actions": "^0.0.193",
|
|
53
|
+
"@gvnrdao/dh-lit-ops": "^0.0.183",
|
|
54
54
|
"@lit-protocol/lit-node-client": "^7.3.1",
|
|
55
55
|
"@noble/hashes": "^1.5.0",
|
|
56
56
|
"axios": "^1.5.0",
|