@gvnrdao/dh-sdk 0.0.280 → 0.0.281
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 +1 -1
- package/browser/dist/browser.js.LICENSE.txt +1 -1
- package/dist/deployments.js +13 -17
- package/dist/deployments.mjs +13 -17
- package/dist/index.js +151 -82
- package/dist/index.mjs +151 -82
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -3964,9 +3964,9 @@ var init_deployment_addresses = __esm({
|
|
|
3964
3964
|
};
|
|
3965
3965
|
LOCALHOST_DEPLOYMENT = {
|
|
3966
3966
|
network: "localhost",
|
|
3967
|
-
chainId:
|
|
3968
|
-
timestamp: "2026-
|
|
3969
|
-
deployer: "",
|
|
3967
|
+
chainId: 1337,
|
|
3968
|
+
timestamp: "2026-06-15T13:32:40.927Z",
|
|
3969
|
+
deployer: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
3970
3970
|
contracts: {
|
|
3971
3971
|
MessageHashBuilder: "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
|
|
3972
3972
|
UpgradeValidator: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
|
|
@@ -3975,15 +3975,13 @@ var init_deployment_addresses = __esm({
|
|
|
3975
3975
|
PositionManagerCoreModule: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
3976
3976
|
TermManagerModule: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
|
|
3977
3977
|
LoanOperationsManagerModule: "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
|
|
3978
|
-
BTCSpendAuthorizer: "
|
|
3979
|
-
CollateralManagerModule: "
|
|
3980
|
-
LiquidationManagerModule: "
|
|
3978
|
+
BTCSpendAuthorizer: "0xc6e7DF5E7b4f2A278906862b61205850344D4e7d",
|
|
3979
|
+
CollateralManagerModule: "0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44",
|
|
3980
|
+
LiquidationManagerModule: "0x4A679253410272dd5232B3Ff7cF5dbB88f295319",
|
|
3981
3981
|
CircuitBreakerModule: "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
|
|
3982
|
-
AdminModule: "
|
|
3982
|
+
AdminModule: "0x09635F643e140090A9A8Dcd712eD6285858ceBef",
|
|
3983
3983
|
PositionManagerViews: "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
|
|
3984
|
-
PositionManager: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB"
|
|
3985
|
-
OperationAuthorizationRegistry: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
|
|
3986
|
-
PKPValidation: "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc"
|
|
3984
|
+
PositionManager: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB"
|
|
3987
3985
|
},
|
|
3988
3986
|
latestEnv: {
|
|
3989
3987
|
UCD_TOKEN: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
@@ -4016,15 +4014,13 @@ var init_deployment_addresses = __esm({
|
|
|
4016
4014
|
PositionManagerCoreModule: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
4017
4015
|
TermManagerModule: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
|
|
4018
4016
|
LoanOperationsManagerModule: "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
|
|
4019
|
-
BTCSpendAuthorizer: "
|
|
4020
|
-
CollateralManagerModule: "
|
|
4021
|
-
LiquidationManagerModule: "
|
|
4017
|
+
BTCSpendAuthorizer: "0xc6e7DF5E7b4f2A278906862b61205850344D4e7d",
|
|
4018
|
+
CollateralManagerModule: "0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44",
|
|
4019
|
+
LiquidationManagerModule: "0x4A679253410272dd5232B3Ff7cF5dbB88f295319",
|
|
4022
4020
|
CircuitBreakerModule: "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
|
|
4023
|
-
AdminModule: "
|
|
4021
|
+
AdminModule: "0x09635F643e140090A9A8Dcd712eD6285858ceBef",
|
|
4024
4022
|
PositionManagerViews: "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
|
|
4025
|
-
PositionManager: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB"
|
|
4026
|
-
OperationAuthorizationRegistry: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
|
|
4027
|
-
PKPValidation: "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc"
|
|
4023
|
+
PositionManager: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB"
|
|
4028
4024
|
};
|
|
4029
4025
|
ALL_DEPLOYMENTS = {
|
|
4030
4026
|
sepolia: SEPOLIA_DEPLOYMENT,
|
|
@@ -31388,103 +31384,103 @@ var require_pkg_src = __commonJS({
|
|
|
31388
31384
|
}
|
|
31389
31385
|
},
|
|
31390
31386
|
btcTransactionSigner: {
|
|
31391
|
-
cid: "
|
|
31387
|
+
cid: "QmZs56sVTCJv7mgvyRYfpYHFvFLcSeXa4H44qUYT7z14QP",
|
|
31392
31388
|
authorizedCidHex: cidToHex(
|
|
31393
|
-
"
|
|
31389
|
+
"QmZs56sVTCJv7mgvyRYfpYHFvFLcSeXa4H44qUYT7z14QP"
|
|
31394
31390
|
),
|
|
31395
31391
|
name: "Btc Transaction Signer",
|
|
31396
31392
|
description: "Production Btc Transaction Signer",
|
|
31397
31393
|
version: "1.0.0",
|
|
31398
31394
|
deployed: true,
|
|
31399
|
-
deployedAt:
|
|
31400
|
-
size:
|
|
31401
|
-
hash: "
|
|
31395
|
+
deployedAt: 1781542204806,
|
|
31396
|
+
size: 42376,
|
|
31397
|
+
hash: "f4aed3d88f6fbff6623ed2047436cecd4f561a74883171ea6f4ebe0a1129973c"
|
|
31402
31398
|
},
|
|
31403
31399
|
ucdMintValidator: {
|
|
31404
|
-
cid: "
|
|
31400
|
+
cid: "QmPir8F8jmJ4ssQpEC3xFxkEnZxMHcgS6VxBQE1jkTLj5K",
|
|
31405
31401
|
authorizedCidHex: cidToHex(
|
|
31406
|
-
"
|
|
31402
|
+
"QmPir8F8jmJ4ssQpEC3xFxkEnZxMHcgS6VxBQE1jkTLj5K"
|
|
31407
31403
|
),
|
|
31408
31404
|
name: "Ucd Mint Validator",
|
|
31409
31405
|
description: "Production Ucd Mint Validator",
|
|
31410
31406
|
version: "1.0.0",
|
|
31411
31407
|
deployed: true,
|
|
31412
|
-
deployedAt:
|
|
31413
|
-
size:
|
|
31414
|
-
hash: "
|
|
31415
|
-
validatorWalletAddress: "
|
|
31408
|
+
deployedAt: 1781542207366,
|
|
31409
|
+
size: 72074,
|
|
31410
|
+
hash: "567a51d3beaedbda4f0af2636835ca8a2af89c2264e91f8dc31f522c1a424b7b",
|
|
31411
|
+
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
31416
31412
|
pkp: {
|
|
31417
31413
|
publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
|
|
31418
31414
|
ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
|
|
31419
31415
|
}
|
|
31420
31416
|
},
|
|
31421
31417
|
processPaymentValidator: {
|
|
31422
|
-
cid: "
|
|
31418
|
+
cid: "QmVq19NXJEpMMvaWQdsU5czLoqh28WGWoGgKMSYFaCmfa9",
|
|
31423
31419
|
authorizedCidHex: cidToHex(
|
|
31424
|
-
"
|
|
31420
|
+
"QmVq19NXJEpMMvaWQdsU5czLoqh28WGWoGgKMSYFaCmfa9"
|
|
31425
31421
|
),
|
|
31426
31422
|
name: "Process Payment Validator",
|
|
31427
31423
|
description: "Production Process Payment Validator",
|
|
31428
31424
|
version: "1.0.0",
|
|
31429
31425
|
deployed: true,
|
|
31430
|
-
deployedAt:
|
|
31431
|
-
size:
|
|
31432
|
-
hash: "
|
|
31433
|
-
validatorWalletAddress: "
|
|
31426
|
+
deployedAt: 1781542209526,
|
|
31427
|
+
size: 68239,
|
|
31428
|
+
hash: "ada27fea57aa3f3b861c49e75ed1f80b72500fdccc1d6e88ee1a3c1396b81867",
|
|
31429
|
+
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
31434
31430
|
pkp: {
|
|
31435
31431
|
publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
|
|
31436
31432
|
ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
|
|
31437
31433
|
}
|
|
31438
31434
|
},
|
|
31439
31435
|
extendPositionValidator: {
|
|
31440
|
-
cid: "
|
|
31436
|
+
cid: "QmP2u3bgKLtfqsFMp6Li72zMY8ZZH3ttAqp9W2wwonUmcb",
|
|
31441
31437
|
authorizedCidHex: cidToHex(
|
|
31442
|
-
"
|
|
31438
|
+
"QmP2u3bgKLtfqsFMp6Li72zMY8ZZH3ttAqp9W2wwonUmcb"
|
|
31443
31439
|
),
|
|
31444
31440
|
name: "Extend Position Validator",
|
|
31445
31441
|
description: "Production Extend Position Validator",
|
|
31446
31442
|
version: "1.0.1",
|
|
31447
31443
|
deployed: true,
|
|
31448
|
-
deployedAt:
|
|
31449
|
-
size:
|
|
31450
|
-
hash: "
|
|
31451
|
-
validatorWalletAddress: "
|
|
31444
|
+
deployedAt: 1781542211640,
|
|
31445
|
+
size: 66543,
|
|
31446
|
+
hash: "0db666fa2888e9acea13d8e4d79edd4ca252f5a4bb06d97e53aa14a9a34b7143",
|
|
31447
|
+
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
31452
31448
|
pkp: {
|
|
31453
31449
|
publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
|
|
31454
31450
|
ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
|
|
31455
31451
|
}
|
|
31456
31452
|
},
|
|
31457
31453
|
btcWithdrawal: {
|
|
31458
|
-
cid: "
|
|
31454
|
+
cid: "QmXtmLdGuEqMKKAtV7d8sHpUV32Kt74na4dRQdpWLasbHJ",
|
|
31459
31455
|
authorizedCidHex: cidToHex(
|
|
31460
|
-
"
|
|
31456
|
+
"QmXtmLdGuEqMKKAtV7d8sHpUV32Kt74na4dRQdpWLasbHJ"
|
|
31461
31457
|
),
|
|
31462
31458
|
name: "Btc Withdrawal",
|
|
31463
31459
|
description: "Production Btc Withdrawal",
|
|
31464
31460
|
version: "1.0.0",
|
|
31465
31461
|
deployed: true,
|
|
31466
|
-
deployedAt:
|
|
31467
|
-
size:
|
|
31468
|
-
hash: "
|
|
31469
|
-
validatorWalletAddress: "
|
|
31462
|
+
deployedAt: 1781542212709,
|
|
31463
|
+
size: 79782,
|
|
31464
|
+
hash: "e824eb473df8eba3a025ac3adc46730dbf89f90884d7c05a78cc07b90d6bc4df",
|
|
31465
|
+
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
31470
31466
|
pkp: {
|
|
31471
31467
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
31472
31468
|
ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
|
|
31473
31469
|
}
|
|
31474
31470
|
},
|
|
31475
31471
|
liquidationValidator: {
|
|
31476
|
-
cid: "
|
|
31472
|
+
cid: "QmVicBXuZVY8t4DXLPjvXjzLqnBtnogAh5HT7BaL9VeDwF",
|
|
31477
31473
|
authorizedCidHex: cidToHex(
|
|
31478
|
-
"
|
|
31474
|
+
"QmVicBXuZVY8t4DXLPjvXjzLqnBtnogAh5HT7BaL9VeDwF"
|
|
31479
31475
|
),
|
|
31480
31476
|
name: "Liquidation Validator",
|
|
31481
31477
|
description: "Production Liquidation Validator",
|
|
31482
31478
|
version: "1.0.0",
|
|
31483
31479
|
deployed: true,
|
|
31484
|
-
deployedAt:
|
|
31485
|
-
size:
|
|
31486
|
-
hash: "
|
|
31487
|
-
validatorWalletAddress: "
|
|
31480
|
+
deployedAt: 1781542213421,
|
|
31481
|
+
size: 58444,
|
|
31482
|
+
hash: "0f42e9f8984433fef95875d35eb3c8d985e7ce15ad309e6aa1093d6fd1ba0bb5",
|
|
31483
|
+
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
31488
31484
|
pkp: {
|
|
31489
31485
|
publicKey: "0x041a241de58976c13e3d7ca5a18e494f7330151e3818706135d50176e78ffb673e58b11f0b67a87c73fade6c6b27d6e7a7377ea9f4c10bf31880f1d725f18cc6f8",
|
|
31490
31486
|
ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
|
|
@@ -31509,18 +31505,18 @@ var require_pkg_src = __commonJS({
|
|
|
31509
31505
|
}
|
|
31510
31506
|
},
|
|
31511
31507
|
loanVaultBtcBalance: {
|
|
31512
|
-
cid: "
|
|
31508
|
+
cid: "QmUmqL4LcjDSpw2TtuWMcw8xYk8hPxgagY2qHDU8Mx1PLG",
|
|
31513
31509
|
authorizedCidHex: cidToHex(
|
|
31514
|
-
"
|
|
31510
|
+
"QmUmqL4LcjDSpw2TtuWMcw8xYk8hPxgagY2qHDU8Mx1PLG"
|
|
31515
31511
|
),
|
|
31516
31512
|
name: "Loan Vault Btc Balance",
|
|
31517
31513
|
description: "Production Loan Vault Btc Balance",
|
|
31518
31514
|
version: "1.0.0",
|
|
31519
31515
|
deployed: true,
|
|
31520
|
-
deployedAt:
|
|
31521
|
-
size:
|
|
31522
|
-
hash: "
|
|
31523
|
-
validatorWalletAddress: "
|
|
31516
|
+
deployedAt: 1781542215432,
|
|
31517
|
+
size: 48397,
|
|
31518
|
+
hash: "da3750a70e532b87f3590a3e2d8c2d51e700589f6e111bb291384ab01304af35",
|
|
31519
|
+
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
31524
31520
|
pkp: {
|
|
31525
31521
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
31526
31522
|
ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
|
|
@@ -31533,18 +31529,18 @@ var require_pkg_src = __commonJS({
|
|
|
31533
31529
|
// Requires BitcoinProviderRegistry.addAllowedCid(chainId, keccak256(utf8(cid)))
|
|
31534
31530
|
// on each target chain (the action decrypts registry slots). No OAR entry.
|
|
31535
31531
|
btcAddressBalance: {
|
|
31536
|
-
cid: "
|
|
31532
|
+
cid: "QmWRDAg7ZCBFFhGfdXR7aUtQsG5qqBb1yVdLCxh8dPD7G5",
|
|
31537
31533
|
authorizedCidHex: cidToHex(
|
|
31538
|
-
"
|
|
31534
|
+
"QmWRDAg7ZCBFFhGfdXR7aUtQsG5qqBb1yVdLCxh8dPD7G5"
|
|
31539
31535
|
),
|
|
31540
31536
|
name: "Btc Address Balance",
|
|
31541
31537
|
description: "Address-only signed total BTC balance via registry consensus (no positionId, no price)",
|
|
31542
31538
|
version: "0.1.0",
|
|
31543
31539
|
deployed: true,
|
|
31544
|
-
deployedAt:
|
|
31545
|
-
size:
|
|
31546
|
-
hash: "
|
|
31547
|
-
validatorWalletAddress: "
|
|
31540
|
+
deployedAt: 1781542217452,
|
|
31541
|
+
size: 25519,
|
|
31542
|
+
hash: "000e2f8bdbccdc95b0db0fb3f12412e2e76eea16a8456d37914d324437ae291c",
|
|
31543
|
+
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
31548
31544
|
pkp: {
|
|
31549
31545
|
publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
|
|
31550
31546
|
ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
|
|
@@ -31577,18 +31573,18 @@ var require_pkg_src = __commonJS({
|
|
|
31577
31573
|
hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
|
|
31578
31574
|
},
|
|
31579
31575
|
staleSpendRecoveryValidator: {
|
|
31580
|
-
cid: "
|
|
31576
|
+
cid: "QmWqJZqoKUqMaGTXe9WUSwdDyeBwXJ9dnR3ioFnVK4RkN5",
|
|
31581
31577
|
authorizedCidHex: cidToHex(
|
|
31582
|
-
"
|
|
31578
|
+
"QmWqJZqoKUqMaGTXe9WUSwdDyeBwXJ9dnR3ioFnVK4RkN5"
|
|
31583
31579
|
),
|
|
31584
31580
|
name: "Stale Spend Recovery Validator",
|
|
31585
31581
|
description: "Production Stale Spend Recovery Validator",
|
|
31586
31582
|
version: "1.0.0",
|
|
31587
31583
|
deployed: true,
|
|
31588
|
-
deployedAt:
|
|
31589
|
-
size:
|
|
31590
|
-
hash: "
|
|
31591
|
-
validatorWalletAddress: "
|
|
31584
|
+
deployedAt: 1781542219438,
|
|
31585
|
+
size: 34413,
|
|
31586
|
+
hash: "26b11730cf5d9eb4af0b1fe65192d26ccee50369c0472211a0ea11e26ef51cc5",
|
|
31587
|
+
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
31592
31588
|
pkp: {
|
|
31593
31589
|
publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
|
|
31594
31590
|
ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
|
|
@@ -33335,12 +33331,83 @@ ${errorReport}`);
|
|
|
33335
33331
|
function isAbortError(error2) {
|
|
33336
33332
|
return error2 instanceof Error && error2.name === "AbortError";
|
|
33337
33333
|
}
|
|
33334
|
+
var BLOCKSTREAM_TOKEN_URL = "https://login.blockstream.com/realms/blockstream-public/protocol/openid-connect/token";
|
|
33335
|
+
var oauthTokenCache = /* @__PURE__ */ new Map();
|
|
33336
|
+
var OAUTH_TOKEN_TIMEOUT_MS = 1e4;
|
|
33337
|
+
async function getBlockstreamBearerToken(auth, timeoutMs) {
|
|
33338
|
+
const tokenUrl = auth.tokenUrl || BLOCKSTREAM_TOKEN_URL;
|
|
33339
|
+
const key = `${tokenUrl}
|
|
33340
|
+
${auth.clientId}`;
|
|
33341
|
+
const cached = oauthTokenCache.get(key);
|
|
33342
|
+
if (cached)
|
|
33343
|
+
return cached;
|
|
33344
|
+
const promise = (async () => {
|
|
33345
|
+
const body = `grant_type=client_credentials&client_id=${encodeURIComponent(auth.clientId)}&client_secret=${encodeURIComponent(auth.clientSecret)}&scope=openid`;
|
|
33346
|
+
const controller = new AbortController();
|
|
33347
|
+
const timeoutId = setTimeout(
|
|
33348
|
+
() => controller.abort(),
|
|
33349
|
+
timeoutMs && timeoutMs > 0 ? timeoutMs : OAUTH_TOKEN_TIMEOUT_MS
|
|
33350
|
+
);
|
|
33351
|
+
let resp;
|
|
33352
|
+
try {
|
|
33353
|
+
resp = await fetch(tokenUrl, {
|
|
33354
|
+
method: "POST",
|
|
33355
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
33356
|
+
body,
|
|
33357
|
+
signal: controller.signal
|
|
33358
|
+
});
|
|
33359
|
+
} finally {
|
|
33360
|
+
clearTimeout(timeoutId);
|
|
33361
|
+
}
|
|
33362
|
+
if (!resp.ok) {
|
|
33363
|
+
throw new Error(
|
|
33364
|
+
`Blockstream OAuth token exchange failed: ${resp.status} ${resp.statusText}`
|
|
33365
|
+
);
|
|
33366
|
+
}
|
|
33367
|
+
const json = await resp.json();
|
|
33368
|
+
const token = json?.access_token;
|
|
33369
|
+
if (typeof token !== "string" || token.length === 0) {
|
|
33370
|
+
throw new Error(
|
|
33371
|
+
"Blockstream OAuth token exchange returned no access_token"
|
|
33372
|
+
);
|
|
33373
|
+
}
|
|
33374
|
+
return token;
|
|
33375
|
+
})();
|
|
33376
|
+
promise.catch(() => oauthTokenCache.delete(key));
|
|
33377
|
+
oauthTokenCache.set(key, promise);
|
|
33378
|
+
return promise;
|
|
33379
|
+
}
|
|
33380
|
+
async function authHeaders(auth, timeoutMs) {
|
|
33381
|
+
if (!auth)
|
|
33382
|
+
return {};
|
|
33383
|
+
switch (auth.provider) {
|
|
33384
|
+
case "esplora":
|
|
33385
|
+
return {};
|
|
33386
|
+
case "maestro":
|
|
33387
|
+
return { "api-key": auth.apiKey };
|
|
33388
|
+
case "blockstream-enterprise": {
|
|
33389
|
+
const token = await getBlockstreamBearerToken(auth, timeoutMs);
|
|
33390
|
+
return { Authorization: `Bearer ${token}` };
|
|
33391
|
+
}
|
|
33392
|
+
default:
|
|
33393
|
+
return {};
|
|
33394
|
+
}
|
|
33395
|
+
}
|
|
33338
33396
|
var BitcoinDataProvider = class {
|
|
33339
33397
|
constructor(config) {
|
|
33340
33398
|
this.config = config;
|
|
33341
33399
|
this.timeout = config.timeout || 15e3;
|
|
33342
33400
|
this.logger = LitActionLogger.create("BitcoinDataProvider");
|
|
33343
33401
|
}
|
|
33402
|
+
/**
|
|
33403
|
+
* Merge per-provider auth headers into a base header set. No-op for public
|
|
33404
|
+
* Esplora / regtest faucet (no `auth`); attaches the `api-key` header for
|
|
33405
|
+
* Maestro and performs a (memoized) OAuth exchange → `Bearer` for Blockstream
|
|
33406
|
+
* Enterprise. Awaited at every fetch site so a single run shares one token.
|
|
33407
|
+
*/
|
|
33408
|
+
async withAuth(base22 = {}) {
|
|
33409
|
+
return { ...base22, ...await authHeaders(this.config.auth, this.timeout) };
|
|
33410
|
+
}
|
|
33344
33411
|
/**
|
|
33345
33412
|
* Get current Bitcoin block height from provider
|
|
33346
33413
|
*/
|
|
@@ -33359,11 +33426,11 @@ ${errorReport}`);
|
|
|
33359
33426
|
`${this.config.providerUrl}/blocks/tip/height`,
|
|
33360
33427
|
{
|
|
33361
33428
|
signal: controller.signal,
|
|
33362
|
-
headers: {
|
|
33429
|
+
headers: await this.withAuth({
|
|
33363
33430
|
Accept: "text/plain",
|
|
33364
33431
|
"User-Agent": "Mozilla/5.0 (compatible; DiamondHandsValidator/1.0)",
|
|
33365
33432
|
"ngrok-skip-browser-warning": "true"
|
|
33366
|
-
}
|
|
33433
|
+
})
|
|
33367
33434
|
}
|
|
33368
33435
|
);
|
|
33369
33436
|
clearTimeout(timeoutId);
|
|
@@ -33533,12 +33600,12 @@ ${errorReport}`);
|
|
|
33533
33600
|
* Internal method to fetch UTXOs from a specific provider
|
|
33534
33601
|
*
|
|
33535
33602
|
* Supports standard Esplora API format:
|
|
33536
|
-
* - Standard format: {providerUrl}/address/{address}/
|
|
33603
|
+
* - Standard format: {providerUrl}/address/{address}/utxo
|
|
33537
33604
|
* - providerUrl must include full base path (e.g., "http://localhost:3002/api/esplora")
|
|
33538
33605
|
*/
|
|
33539
33606
|
async fetchUTXOsFromProvider(providerUrl, address) {
|
|
33540
33607
|
this.logger.stepStart("1", "fetchUTXOsFromProvider");
|
|
33541
|
-
const endpoint = `${providerUrl}/address/${address}/
|
|
33608
|
+
const endpoint = `${providerUrl}/address/${address}/utxo`;
|
|
33542
33609
|
this.logger.log("1", `Fetching UTXOs from ${endpoint}`);
|
|
33543
33610
|
const controller = new AbortController();
|
|
33544
33611
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
@@ -33548,18 +33615,18 @@ ${errorReport}`);
|
|
|
33548
33615
|
this.getCurrentBlockHeight(),
|
|
33549
33616
|
fetch(endpoint, {
|
|
33550
33617
|
signal: controller.signal,
|
|
33551
|
-
headers: {
|
|
33618
|
+
headers: await this.withAuth({
|
|
33552
33619
|
Accept: "application/json",
|
|
33553
33620
|
"Content-Type": "application/json",
|
|
33554
33621
|
"User-Agent": "Mozilla/5.0 (compatible; DiamondHandsValidator/1.0)",
|
|
33555
33622
|
"ngrok-skip-browser-warning": "true"
|
|
33556
33623
|
// Skip ngrok browser warning page
|
|
33557
|
-
}
|
|
33624
|
+
})
|
|
33558
33625
|
})
|
|
33559
33626
|
]);
|
|
33560
33627
|
clearTimeout(timeoutId);
|
|
33561
33628
|
litDebugLog(
|
|
33562
|
-
`[BitcoinDataProvider] parallel(tipHeight + GET
|
|
33629
|
+
`[BitcoinDataProvider] parallel(tipHeight + GET utxo) wall ${Date.now() - tParallel}ms endpoint tail .../${address.slice(0, 12)}.../utxo (timeout budget ${this.timeout}ms)`
|
|
33563
33630
|
);
|
|
33564
33631
|
this.logger.log("1", `Current block height: ${currentBlockHeight}`);
|
|
33565
33632
|
if (!response.ok) {
|
|
@@ -33671,12 +33738,12 @@ ${errorReport}`);
|
|
|
33671
33738
|
const t0 = Date.now();
|
|
33672
33739
|
const response = await fetch(endpoint, {
|
|
33673
33740
|
signal: controller.signal,
|
|
33674
|
-
headers: {
|
|
33741
|
+
headers: await this.withAuth({
|
|
33675
33742
|
Accept: "application/json",
|
|
33676
33743
|
"Content-Type": "application/json",
|
|
33677
33744
|
"User-Agent": "Mozilla/5.0 (compatible; DiamondHandsValidator/1.0)",
|
|
33678
33745
|
"ngrok-skip-browser-warning": "true"
|
|
33679
|
-
}
|
|
33746
|
+
})
|
|
33680
33747
|
});
|
|
33681
33748
|
clearTimeout(timeoutId);
|
|
33682
33749
|
litDebugLog(
|
|
@@ -33750,7 +33817,8 @@ ${errorReport}`);
|
|
|
33750
33817
|
try {
|
|
33751
33818
|
const t0 = Date.now();
|
|
33752
33819
|
const response = await fetch(`${this.config.providerUrl}/tx/${txid}`, {
|
|
33753
|
-
signal: controller.signal
|
|
33820
|
+
signal: controller.signal,
|
|
33821
|
+
headers: await this.withAuth()
|
|
33754
33822
|
});
|
|
33755
33823
|
clearTimeout(timeoutId);
|
|
33756
33824
|
litDebugLog(
|
|
@@ -33772,7 +33840,7 @@ ${errorReport}`);
|
|
|
33772
33840
|
try {
|
|
33773
33841
|
const tipResp = await fetch(
|
|
33774
33842
|
`${this.config.providerUrl}/blocks/tip/height`,
|
|
33775
|
-
{ signal: controller.signal }
|
|
33843
|
+
{ signal: controller.signal, headers: await this.withAuth() }
|
|
33776
33844
|
);
|
|
33777
33845
|
if (!tipResp.ok) {
|
|
33778
33846
|
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
@@ -33823,7 +33891,8 @@ ${errorReport}`);
|
|
|
33823
33891
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
33824
33892
|
try {
|
|
33825
33893
|
const response = await fetch(`${this.config.providerUrl}/tx/${txid}`, {
|
|
33826
|
-
signal: controller.signal
|
|
33894
|
+
signal: controller.signal,
|
|
33895
|
+
headers: await this.withAuth()
|
|
33827
33896
|
});
|
|
33828
33897
|
clearTimeout(timeoutId);
|
|
33829
33898
|
if (!response.ok) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gvnrdao/dh-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.281",
|
|
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.310",
|
|
85
|
+
"@gvnrdao/dh-lit-ops": "^0.0.298",
|
|
86
86
|
"@noble/hashes": "^1.5.0",
|
|
87
87
|
"axios": "^1.17.0",
|
|
88
88
|
"bech32": "^2.0.0",
|