@gvnrdao/dh-mcp 0.5.19 → 0.5.21
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/boundary.js +1278 -443
- package/dist/connector-embed.js +1797 -582
- package/dist/connector.js +3144 -1017
- package/dist/index.js +1326 -468
- package/package.json +14 -3
package/dist/boundary.js
CHANGED
|
@@ -13422,6 +13422,12 @@ var require_follow_redirects = __commonJS({
|
|
|
13422
13422
|
RedirectableRequest.prototype._sanitizeOptions = function(options) {
|
|
13423
13423
|
if (!options.headers) {
|
|
13424
13424
|
options.headers = {};
|
|
13425
|
+
} else if (Array.isArray(options.headers)) {
|
|
13426
|
+
var headerList = options.headers;
|
|
13427
|
+
options.headers = {};
|
|
13428
|
+
for (var i = 0; i < headerList.length; i += 2) {
|
|
13429
|
+
options.headers[headerList[i]] = headerList[i + 1];
|
|
13430
|
+
}
|
|
13425
13431
|
}
|
|
13426
13432
|
if (!isArray2(options.sensitiveHeaders)) {
|
|
13427
13433
|
options.sensitiveHeaders = [];
|
|
@@ -13696,7 +13702,7 @@ var require_follow_redirects = __commonJS({
|
|
|
13696
13702
|
return URL3 && value instanceof URL3;
|
|
13697
13703
|
}
|
|
13698
13704
|
function escapeRegex(regex) {
|
|
13699
|
-
return regex.replace(/[\]\\/()
|
|
13705
|
+
return regex.replace(/[[\]\\/()*+?.^$|]/g, "\\$&");
|
|
13700
13706
|
}
|
|
13701
13707
|
module2.exports = wrap({ http: http4, https: https2 });
|
|
13702
13708
|
module2.exports.wrap = wrap;
|
|
@@ -14450,113 +14456,113 @@ var require_pkg_src = __commonJS({
|
|
|
14450
14456
|
deployedAt: 1784569687492,
|
|
14451
14457
|
size: 4140,
|
|
14452
14458
|
hash: "4c0d65bf1f33cdac22a78fd8c4764319cc3fe00650e0fe7fa8a6090d9a318a7b",
|
|
14453
|
-
validatorWalletAddress: "
|
|
14459
|
+
validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
|
|
14454
14460
|
pkp: {
|
|
14455
14461
|
publicKey: "0x04ec0e3acc40884e3f366ca469d08899eb640ad5259fa196b0238075086208a9f8732a3175704f35f0bcc28e07406cfb24c254efd1e7355640577330f0d2dd755f",
|
|
14456
|
-
ethAddress: "
|
|
14462
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14457
14463
|
}
|
|
14458
14464
|
},
|
|
14459
14465
|
btcTransactionSigner: {
|
|
14460
|
-
cid: "
|
|
14466
|
+
cid: "QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U",
|
|
14461
14467
|
authorizedCidHex: cidToHex(
|
|
14462
|
-
"
|
|
14468
|
+
"QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U"
|
|
14463
14469
|
),
|
|
14464
14470
|
name: "Btc Transaction Signer",
|
|
14465
14471
|
description: "Production Btc Transaction Signer",
|
|
14466
14472
|
version: "1.1.1",
|
|
14467
14473
|
deployed: true,
|
|
14468
|
-
deployedAt:
|
|
14469
|
-
size:
|
|
14470
|
-
hash: "
|
|
14474
|
+
deployedAt: 1790246185256,
|
|
14475
|
+
size: 73313,
|
|
14476
|
+
hash: "d8b6bc646ba33fee7d46c8e9b281de776081ea6f182f56fd15d4c52aaf3dd030"
|
|
14471
14477
|
},
|
|
14472
14478
|
ucdMintValidator: {
|
|
14473
|
-
cid: "
|
|
14479
|
+
cid: "QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe",
|
|
14474
14480
|
authorizedCidHex: cidToHex(
|
|
14475
|
-
"
|
|
14481
|
+
"QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe"
|
|
14476
14482
|
),
|
|
14477
14483
|
name: "Ucd Mint Validator",
|
|
14478
14484
|
description: "Production Ucd Mint Validator",
|
|
14479
|
-
version: "1.
|
|
14485
|
+
version: "1.3.0",
|
|
14480
14486
|
deployed: true,
|
|
14481
|
-
deployedAt:
|
|
14482
|
-
size:
|
|
14483
|
-
hash: "
|
|
14484
|
-
validatorWalletAddress: "
|
|
14487
|
+
deployedAt: 1790246219868,
|
|
14488
|
+
size: 90022,
|
|
14489
|
+
hash: "65e8cb778c2b767ae6eb37cb5db7b4c5a3f2468d508463c847c83c1b6825fadd",
|
|
14490
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14485
14491
|
pkp: {
|
|
14486
14492
|
publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
|
|
14487
|
-
ethAddress: "
|
|
14493
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14488
14494
|
}
|
|
14489
14495
|
},
|
|
14490
14496
|
processPaymentValidator: {
|
|
14491
|
-
cid: "
|
|
14497
|
+
cid: "QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8",
|
|
14492
14498
|
authorizedCidHex: cidToHex(
|
|
14493
|
-
"
|
|
14499
|
+
"QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8"
|
|
14494
14500
|
),
|
|
14495
14501
|
name: "Process Payment Validator",
|
|
14496
14502
|
description: "Production Process Payment Validator",
|
|
14497
14503
|
version: "1.2.1",
|
|
14498
14504
|
deployed: true,
|
|
14499
|
-
deployedAt:
|
|
14500
|
-
size:
|
|
14501
|
-
hash: "
|
|
14502
|
-
validatorWalletAddress: "
|
|
14505
|
+
deployedAt: 1790246225795,
|
|
14506
|
+
size: 85107,
|
|
14507
|
+
hash: "25ecf952c4c44c40b0920b92d57906e7010ed9a38e2ba41ccdee6d3377c2b596",
|
|
14508
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14503
14509
|
pkp: {
|
|
14504
14510
|
publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
|
|
14505
|
-
ethAddress: "
|
|
14511
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14506
14512
|
}
|
|
14507
14513
|
},
|
|
14508
14514
|
extendPositionValidator: {
|
|
14509
|
-
cid: "
|
|
14515
|
+
cid: "QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX",
|
|
14510
14516
|
authorizedCidHex: cidToHex(
|
|
14511
|
-
"
|
|
14517
|
+
"QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX"
|
|
14512
14518
|
),
|
|
14513
14519
|
name: "Extend Position Validator",
|
|
14514
14520
|
description: "Production Extend Position Validator",
|
|
14515
14521
|
version: "1.2.1",
|
|
14516
14522
|
deployed: true,
|
|
14517
|
-
deployedAt:
|
|
14518
|
-
size:
|
|
14519
|
-
hash: "
|
|
14520
|
-
validatorWalletAddress: "
|
|
14523
|
+
deployedAt: 1790246231975,
|
|
14524
|
+
size: 82853,
|
|
14525
|
+
hash: "25d4887b7f646649db2bb7f2bfb77d039db83228a6c454377ca26c779b0903cc",
|
|
14526
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14521
14527
|
pkp: {
|
|
14522
14528
|
publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
|
|
14523
|
-
ethAddress: "
|
|
14529
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14524
14530
|
}
|
|
14525
14531
|
},
|
|
14526
14532
|
btcWithdrawal: {
|
|
14527
|
-
cid: "
|
|
14533
|
+
cid: "QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP",
|
|
14528
14534
|
authorizedCidHex: cidToHex(
|
|
14529
|
-
"
|
|
14535
|
+
"QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP"
|
|
14530
14536
|
),
|
|
14531
14537
|
name: "Btc Withdrawal",
|
|
14532
14538
|
description: "Production Btc Withdrawal",
|
|
14533
14539
|
version: "1.2.7",
|
|
14534
14540
|
deployed: true,
|
|
14535
|
-
deployedAt:
|
|
14536
|
-
size:
|
|
14537
|
-
hash: "
|
|
14538
|
-
validatorWalletAddress: "
|
|
14541
|
+
deployedAt: 1790246239599,
|
|
14542
|
+
size: 101228,
|
|
14543
|
+
hash: "2ed25eca6cc80a43061b7ad119737af48158fdb61d59f10cd06cea51b607f112",
|
|
14544
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14539
14545
|
pkp: {
|
|
14540
14546
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
14541
|
-
ethAddress: "
|
|
14547
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14542
14548
|
}
|
|
14543
14549
|
},
|
|
14544
14550
|
liquidationValidator: {
|
|
14545
|
-
cid: "
|
|
14551
|
+
cid: "QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb",
|
|
14546
14552
|
authorizedCidHex: cidToHex(
|
|
14547
|
-
"
|
|
14553
|
+
"QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb"
|
|
14548
14554
|
),
|
|
14549
14555
|
name: "Liquidation Validator",
|
|
14550
14556
|
description: "Production Liquidation Validator",
|
|
14551
14557
|
version: "1.2.1",
|
|
14552
14558
|
deployed: true,
|
|
14553
|
-
deployedAt:
|
|
14554
|
-
size:
|
|
14555
|
-
hash: "
|
|
14556
|
-
validatorWalletAddress: "
|
|
14559
|
+
deployedAt: 1790246247904,
|
|
14560
|
+
size: 70308,
|
|
14561
|
+
hash: "582ccf0ec7f715195e20fdc885996743cb42125b64173424e360ee63db62bbd8",
|
|
14562
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14557
14563
|
pkp: {
|
|
14558
14564
|
publicKey: "0x041a241de58976c13e3d7ca5a18e494f7330151e3818706135d50176e78ffb673e58b11f0b67a87c73fade6c6b27d6e7a7377ea9f4c10bf31880f1d725f18cc6f8",
|
|
14559
|
-
ethAddress: "
|
|
14565
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14560
14566
|
}
|
|
14561
14567
|
},
|
|
14562
14568
|
priceOracle: {
|
|
@@ -14571,28 +14577,28 @@ var require_pkg_src = __commonJS({
|
|
|
14571
14577
|
deployedAt: 1781116663270,
|
|
14572
14578
|
size: 8695,
|
|
14573
14579
|
hash: "ba20ade60a7fa5acd80dadfafa179c507388cfe6ce48a22a672d70b317ffcc74",
|
|
14574
|
-
validatorWalletAddress: "
|
|
14580
|
+
validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
|
|
14575
14581
|
pkp: {
|
|
14576
14582
|
publicKey: "0x043beaa1da47875601a8d6f430b1438ee2d4732eefd06e5c63a474bbdaf9e7df1797b1b951e041b627c2bf839788164825324c9cbd1e2d6f740fdd4bff69b1900b",
|
|
14577
|
-
ethAddress: "
|
|
14583
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14578
14584
|
}
|
|
14579
14585
|
},
|
|
14580
14586
|
loanVaultBtcBalance: {
|
|
14581
|
-
cid: "
|
|
14587
|
+
cid: "QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W",
|
|
14582
14588
|
authorizedCidHex: cidToHex(
|
|
14583
|
-
"
|
|
14589
|
+
"QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W"
|
|
14584
14590
|
),
|
|
14585
14591
|
name: "Loan Vault Btc Balance",
|
|
14586
14592
|
description: "Production Loan Vault Btc Balance",
|
|
14587
14593
|
version: "1.2.1",
|
|
14588
14594
|
deployed: true,
|
|
14589
|
-
deployedAt:
|
|
14590
|
-
size:
|
|
14591
|
-
hash: "
|
|
14592
|
-
validatorWalletAddress: "
|
|
14595
|
+
deployedAt: 1790179961079,
|
|
14596
|
+
size: 60046,
|
|
14597
|
+
hash: "922e86c0a667fe0c0945771f84aa6b9fe08be9c96dd2f73a9c5cb257d24e22b0",
|
|
14598
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14593
14599
|
pkp: {
|
|
14594
14600
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
14595
|
-
ethAddress: "
|
|
14601
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14596
14602
|
}
|
|
14597
14603
|
},
|
|
14598
14604
|
// btc-address-balance (Option B) — address-only signed total balance via
|
|
@@ -14602,21 +14608,21 @@ var require_pkg_src = __commonJS({
|
|
|
14602
14608
|
// Requires BitcoinProviderRegistry.addAllowedCid(chainId, keccak256(utf8(cid)))
|
|
14603
14609
|
// on each target chain (the action decrypts registry slots). No OAR entry.
|
|
14604
14610
|
btcAddressBalance: {
|
|
14605
|
-
cid: "
|
|
14611
|
+
cid: "QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN",
|
|
14606
14612
|
authorizedCidHex: cidToHex(
|
|
14607
|
-
"
|
|
14613
|
+
"QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN"
|
|
14608
14614
|
),
|
|
14609
14615
|
name: "Btc Address Balance",
|
|
14610
14616
|
description: "Address-only signed total BTC balance via registry consensus (no positionId, no price)",
|
|
14611
14617
|
version: "0.2.1",
|
|
14612
14618
|
deployed: true,
|
|
14613
|
-
deployedAt:
|
|
14614
|
-
size:
|
|
14615
|
-
hash: "
|
|
14616
|
-
validatorWalletAddress: "
|
|
14619
|
+
deployedAt: 1790179971315,
|
|
14620
|
+
size: 30295,
|
|
14621
|
+
hash: "2c67d9cfa4d50e835fbb28ae50e80217ceb2be3bb862c89290aadf43fdc739c9",
|
|
14622
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14617
14623
|
pkp: {
|
|
14618
14624
|
publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
|
|
14619
|
-
ethAddress: "
|
|
14625
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14620
14626
|
}
|
|
14621
14627
|
},
|
|
14622
14628
|
alwaysSigner: {
|
|
@@ -14646,48 +14652,74 @@ var require_pkg_src = __commonJS({
|
|
|
14646
14652
|
hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
|
|
14647
14653
|
},
|
|
14648
14654
|
agentModuleExecutor: {
|
|
14649
|
-
cid: "
|
|
14655
|
+
cid: "QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX",
|
|
14650
14656
|
authorizedCidHex: cidToHex(
|
|
14651
|
-
"
|
|
14657
|
+
"QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX"
|
|
14652
14658
|
),
|
|
14653
14659
|
name: "Agent Module Executor",
|
|
14654
14660
|
description: "Production Agent Module Executor",
|
|
14655
14661
|
version: "1.1.1",
|
|
14656
14662
|
deployed: true,
|
|
14657
|
-
deployedAt:
|
|
14658
|
-
size:
|
|
14659
|
-
hash: "
|
|
14663
|
+
deployedAt: 1790179978959,
|
|
14664
|
+
size: 14688,
|
|
14665
|
+
hash: "8edb9b12c784c8d7d153cce97235584c24665a788767ae68713dce91109ab35e"
|
|
14660
14666
|
},
|
|
14661
14667
|
staleSpendRecoveryValidator: {
|
|
14662
|
-
cid: "
|
|
14668
|
+
cid: "Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz",
|
|
14663
14669
|
authorizedCidHex: cidToHex(
|
|
14664
|
-
"
|
|
14670
|
+
"Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz"
|
|
14665
14671
|
),
|
|
14666
14672
|
name: "Stale Spend Recovery Validator",
|
|
14667
14673
|
description: "Production Stale Spend Recovery Validator",
|
|
14668
14674
|
version: "1.1.2",
|
|
14669
14675
|
deployed: true,
|
|
14670
|
-
deployedAt:
|
|
14671
|
-
size:
|
|
14672
|
-
hash: "
|
|
14673
|
-
validatorWalletAddress: "
|
|
14676
|
+
deployedAt: 1790246256280,
|
|
14677
|
+
size: 48143,
|
|
14678
|
+
hash: "ec9236bcbe0af24d3e1844791fc8fe37371bbecd8ce95d02e13f7c6e1fc7d94c",
|
|
14679
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14674
14680
|
pkp: {
|
|
14675
14681
|
publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
|
|
14676
|
-
ethAddress: "
|
|
14682
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14677
14683
|
}
|
|
14678
14684
|
},
|
|
14679
14685
|
btcUtxoInvalidator: {
|
|
14680
|
-
cid: "
|
|
14686
|
+
cid: "QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX",
|
|
14681
14687
|
authorizedCidHex: cidToHex(
|
|
14682
|
-
"
|
|
14688
|
+
"QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX"
|
|
14683
14689
|
),
|
|
14684
14690
|
name: "Btc Utxo Invalidator",
|
|
14685
14691
|
description: "Production Btc Utxo Invalidator",
|
|
14686
14692
|
version: "1.0.0",
|
|
14687
14693
|
deployed: true,
|
|
14688
|
-
deployedAt:
|
|
14689
|
-
size:
|
|
14690
|
-
hash: "
|
|
14694
|
+
deployedAt: 1790246264563,
|
|
14695
|
+
size: 69219,
|
|
14696
|
+
hash: "bda048d8cd6b5a39c2774bcf1320e82d1eea935c2a521006fb8b887e13b6dd8d"
|
|
14697
|
+
},
|
|
14698
|
+
carryCollateralAttestation: {
|
|
14699
|
+
cid: "QmYWULmXD9S5AmTdQqWqoZ28ctsZQNcXkAgre9G2Xo9dh8",
|
|
14700
|
+
authorizedCidHex: cidToHex(
|
|
14701
|
+
"QmYWULmXD9S5AmTdQqWqoZ28ctsZQNcXkAgre9G2Xo9dh8"
|
|
14702
|
+
),
|
|
14703
|
+
name: "Carry Collateral Attestation",
|
|
14704
|
+
description: "LoanCarryVault collateral attestation (borrower, BTC vault, confirmed BTC)",
|
|
14705
|
+
version: "1.0.0",
|
|
14706
|
+
deployed: true,
|
|
14707
|
+
deployedAt: 1790927734070,
|
|
14708
|
+
size: 21156,
|
|
14709
|
+
hash: "05b177e0bb36b0483db4a42d33c1bbbf47eb9ef34ae278459397d51a7f8957ff"
|
|
14710
|
+
},
|
|
14711
|
+
carryFundingAttestation: {
|
|
14712
|
+
cid: "QmWhox3xUZMNR5NpPZ9WLSPC5GoW4ms88GanVRKr8uuS3W",
|
|
14713
|
+
authorizedCidHex: cidToHex(
|
|
14714
|
+
"QmWhox3xUZMNR5NpPZ9WLSPC5GoW4ms88GanVRKr8uuS3W"
|
|
14715
|
+
),
|
|
14716
|
+
name: "Carry Funding Attestation",
|
|
14717
|
+
description: "LoanCarryVault funding attestation (Hyperliquid BTC windowed hourly average)",
|
|
14718
|
+
version: "1.0.0",
|
|
14719
|
+
deployed: true,
|
|
14720
|
+
deployedAt: 1790925699980,
|
|
14721
|
+
size: 7193,
|
|
14722
|
+
hash: "4944ada61610cf64b32e33b5be62087088dcf5e821040c69e67942e643ce74c9"
|
|
14691
14723
|
}
|
|
14692
14724
|
};
|
|
14693
14725
|
function getDeploymentsForNetwork(network) {
|
|
@@ -15431,7 +15463,7 @@ ${errorReport}`);
|
|
|
15431
15463
|
}
|
|
15432
15464
|
init_debug_logger();
|
|
15433
15465
|
init_session_signature_cache();
|
|
15434
|
-
var
|
|
15466
|
+
var import_ethers52 = require("ethers");
|
|
15435
15467
|
var EXPIRED_LOAN_MIN_LIQUIDATION_THRESHOLD_BPS = 11e3;
|
|
15436
15468
|
var GRACE_PERIOD_DAYS = 30;
|
|
15437
15469
|
var SATOSHIS_PER_BITCOIN = 100000000n;
|
|
@@ -15453,7 +15485,10 @@ ${errorReport}`);
|
|
|
15453
15485
|
BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
|
|
15454
15486
|
BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
|
|
15455
15487
|
LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
|
|
15456
|
-
PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
|
|
15488
|
+
PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C",
|
|
15489
|
+
TermManagerModule: "0xDB99CdF883ffa38acD099bC39F8d1f4508c9239E",
|
|
15490
|
+
UCDController: "0x4b4f8063048bCD59D469219E3f07C6aaDF4f6157",
|
|
15491
|
+
LiquidationManagerModule: "0x74B28695352E7bf736D6c9F76ccb7B4439477De9"
|
|
15457
15492
|
},
|
|
15458
15493
|
11155111: {
|
|
15459
15494
|
PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
|
|
@@ -15461,7 +15496,10 @@ ${errorReport}`);
|
|
|
15461
15496
|
BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
|
|
15462
15497
|
BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
|
|
15463
15498
|
LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
|
|
15464
|
-
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
|
|
15499
|
+
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
15500
|
+
TermManagerModule: "0x94Adc6F9558368B1482197584f1fc7133Ecf835b",
|
|
15501
|
+
UCDController: "0x360Bde4e489ee94E26601B206932De09EE60FF04",
|
|
15502
|
+
LiquidationManagerModule: "0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76"
|
|
15465
15503
|
}
|
|
15466
15504
|
};
|
|
15467
15505
|
function getPinnedContractAddresses(chainId) {
|
|
@@ -15647,10 +15685,10 @@ ${errorReport}`);
|
|
|
15647
15685
|
};
|
|
15648
15686
|
}
|
|
15649
15687
|
const ratioBigInt = collateralValueUsd * UCD_TOKEN_DECIMALS * 10000n / ucdDebt;
|
|
15650
|
-
const
|
|
15688
|
+
const collateralRatioBps2 = Number(ratioBigInt);
|
|
15651
15689
|
return {
|
|
15652
15690
|
collateralValueUsd,
|
|
15653
|
-
collateralRatioBps
|
|
15691
|
+
collateralRatioBps: collateralRatioBps2
|
|
15654
15692
|
};
|
|
15655
15693
|
}
|
|
15656
15694
|
function hasSufficientCollateralForDebt(collateralValueUsd, currentDebt, additionalDebt, requiredRatioBps) {
|
|
@@ -16495,6 +16533,17 @@ ${auth.clientId}`;
|
|
|
16495
16533
|
);
|
|
16496
16534
|
}
|
|
16497
16535
|
}
|
|
16536
|
+
var TIP_READ_FAILURE_PREFIX = "Bitcoin tip-height read failed";
|
|
16537
|
+
var BitcoinTipUnreadableError = class extends Error {
|
|
16538
|
+
constructor(message) {
|
|
16539
|
+
super(message);
|
|
16540
|
+
this.isBitcoinTipUnreadable = true;
|
|
16541
|
+
this.name = "BitcoinTipUnreadableError";
|
|
16542
|
+
}
|
|
16543
|
+
};
|
|
16544
|
+
function isBitcoinTipUnreadableError(error) {
|
|
16545
|
+
return typeof error === "object" && error !== null && error.isBitcoinTipUnreadable === true;
|
|
16546
|
+
}
|
|
16498
16547
|
var BitcoinDataProvider = class {
|
|
16499
16548
|
constructor(config) {
|
|
16500
16549
|
this.config = config;
|
|
@@ -16946,27 +16995,12 @@ ${auth.clientId}`;
|
|
|
16946
16995
|
if (!data.status.confirmed || !data.status.block_height) {
|
|
16947
16996
|
return { txid: data.txid ?? txid, confirmations: 0 };
|
|
16948
16997
|
}
|
|
16949
|
-
|
|
16950
|
-
|
|
16951
|
-
|
|
16952
|
-
|
|
16953
|
-
|
|
16954
|
-
|
|
16955
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
16956
|
-
}
|
|
16957
|
-
const tipBody = (await tipResp.text()).trim();
|
|
16958
|
-
const tipHeight = Number.parseInt(tipBody, 10);
|
|
16959
|
-
if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
|
|
16960
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
16961
|
-
}
|
|
16962
|
-
const depth = tipHeight - data.status.block_height + 1;
|
|
16963
|
-
return {
|
|
16964
|
-
txid: data.txid ?? txid,
|
|
16965
|
-
confirmations: depth > 0 ? depth : 0
|
|
16966
|
-
};
|
|
16967
|
-
} catch {
|
|
16968
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
16969
|
-
}
|
|
16998
|
+
const tipHeight = await this.fetchTipHeight(controller.signal);
|
|
16999
|
+
const depth = tipHeight - data.status.block_height + 1;
|
|
17000
|
+
return {
|
|
17001
|
+
txid: data.txid ?? txid,
|
|
17002
|
+
confirmations: depth > 0 ? depth : 0
|
|
17003
|
+
};
|
|
16970
17004
|
}
|
|
16971
17005
|
return null;
|
|
16972
17006
|
} catch (error) {
|
|
@@ -16974,12 +17008,55 @@ ${auth.clientId}`;
|
|
|
16974
17008
|
if (isAbortError(error)) {
|
|
16975
17009
|
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
16976
17010
|
}
|
|
17011
|
+
if (isBitcoinTipUnreadableError(error)) {
|
|
17012
|
+
throw error;
|
|
17013
|
+
}
|
|
16977
17014
|
if (getUnknownErrorMessage(error).includes("404")) {
|
|
16978
17015
|
return null;
|
|
16979
17016
|
}
|
|
16980
17017
|
throw error;
|
|
16981
17018
|
}
|
|
16982
17019
|
}
|
|
17020
|
+
/**
|
|
17021
|
+
* Current chain tip height from THIS provider — or throw.
|
|
17022
|
+
*
|
|
17023
|
+
* Every exit is a throw naming the provider and the precise failure, because
|
|
17024
|
+
* the only alternative is inventing a confirmation depth (see the call site).
|
|
17025
|
+
* The single `try` exists solely to attach that name to a transport-level
|
|
17026
|
+
* rejection (DNS, TLS, connection reset, abort); it re-throws the cause
|
|
17027
|
+
* verbatim inside the message and never substitutes a value — authorized for
|
|
17028
|
+
* this case by the Batch 2 plan, §C2.
|
|
17029
|
+
*
|
|
17030
|
+
* @param signal - The caller's AbortSignal, so this read shares the same
|
|
17031
|
+
* timeout budget as the transaction fetch it serves.
|
|
17032
|
+
*/
|
|
17033
|
+
async fetchTipHeight(signal) {
|
|
17034
|
+
const endpoint = `${this.config.providerUrl}/blocks/tip/height`;
|
|
17035
|
+
let tipResp;
|
|
17036
|
+
try {
|
|
17037
|
+
tipResp = await fetch(endpoint, {
|
|
17038
|
+
signal,
|
|
17039
|
+
headers: await this.withAuth()
|
|
17040
|
+
});
|
|
17041
|
+
} catch (error) {
|
|
17042
|
+
throw new BitcoinTipUnreadableError(
|
|
17043
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} threw \u2014 ${getUnknownErrorMessage(error)}`
|
|
17044
|
+
);
|
|
17045
|
+
}
|
|
17046
|
+
if (!tipResp.ok) {
|
|
17047
|
+
throw new BitcoinTipUnreadableError(
|
|
17048
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} \u2192 ${tipResp.status} ${tipResp.statusText}`
|
|
17049
|
+
);
|
|
17050
|
+
}
|
|
17051
|
+
const tipBody = (await tipResp.text()).trim();
|
|
17052
|
+
const tipHeight = Number.parseInt(tipBody, 10);
|
|
17053
|
+
if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
|
|
17054
|
+
throw new BitcoinTipUnreadableError(
|
|
17055
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} returned an unusable tip height "${tipBody.slice(0, 64)}"`
|
|
17056
|
+
);
|
|
17057
|
+
}
|
|
17058
|
+
return tipHeight;
|
|
17059
|
+
}
|
|
16983
17060
|
/**
|
|
16984
17061
|
* Get outputs (vouts) of a Bitcoin transaction
|
|
16985
17062
|
*
|
|
@@ -17614,10 +17691,13 @@ ${auth.clientId}`;
|
|
|
17614
17691
|
* only on unanimity. The confirmed-balance consensus the validators run
|
|
17615
17692
|
* covers `chain_stats` only, so without this the primary provider alone
|
|
17616
17693
|
* could fabricate an unconfirmed UTXO plus a self-consistent parent proof
|
|
17617
|
-
* and inflate the signed balance. Any
|
|
17618
|
-
*
|
|
17619
|
-
*
|
|
17620
|
-
*
|
|
17694
|
+
* and inflate the signed balance. Any verdict disagreement THROWS
|
|
17695
|
+
* (fail-closed) — exclusion on a suppressed proof would deflate the balance
|
|
17696
|
+
* and open a wrongful-liquidation window, so neither direction may proceed
|
|
17697
|
+
* without agreement. A provider that cannot state the chain tip — and only
|
|
17698
|
+
* that failure — is dropped from the quorum rather than aborting the read (it
|
|
17699
|
+
* never counts as agreeing), and falling below `minConsensusProviders`
|
|
17700
|
+
* survivors throws — see `verifyParentIsSelfSpendConsensus`.
|
|
17621
17701
|
*
|
|
17622
17702
|
* The same per-provider `/tx` fetch also returns the parent's outputs, and
|
|
17623
17703
|
* every provider must corroborate each claimed UTXO (index, vault address,
|
|
@@ -17712,10 +17792,26 @@ ${auth.clientId}`;
|
|
|
17712
17792
|
}
|
|
17713
17793
|
/**
|
|
17714
17794
|
* Run the self-spend proof against every configured provider and require
|
|
17715
|
-
* unanimity
|
|
17716
|
-
*
|
|
17795
|
+
* unanimity AMONG THE PROVIDERS THAT ANSWERED. Fail-closed on disagreement:
|
|
17796
|
+
* a verdict mismatch throws and aborts the balance calculation — see
|
|
17717
17797
|
* classifySelfChange for why exclusion is not a safe fallback here.
|
|
17718
17798
|
*
|
|
17799
|
+
* Quorum semantics (2026-09-23, plan C2). ONE failure class is tolerated: a
|
|
17800
|
+
* provider that could not state the chain tip (`BitcoinTipUnreadableError`).
|
|
17801
|
+
* It is ABSENT from the quorum — never counted as agreeing, never allowed to
|
|
17802
|
+
* decide the verdict — and the policy floor, not "at least one", decides when
|
|
17803
|
+
* that absence is fatal: below `minConsensusProviders` surviving readings
|
|
17804
|
+
* there is no cross-check left to trust, and the read fails loudly naming
|
|
17805
|
+
* every provider that dropped out.
|
|
17806
|
+
*
|
|
17807
|
+
* Why only that class. `getTransaction` now throws on an unreadable tip
|
|
17808
|
+
* instead of fabricating `confirmations: 1`; without this carve-out one flaky
|
|
17809
|
+
* `/blocks/tip/height` endpoint would take every balance and spend path down
|
|
17810
|
+
* with it. Every OTHER failure remains fatal, as before: a provider that
|
|
17811
|
+
* answers "I have never seen that transaction" is making a claim about the
|
|
17812
|
+
* chain rather than suffering an outage, and that shape is precisely the
|
|
17813
|
+
* fabricated-UTXO signature the fail-closed rule exists to catch.
|
|
17814
|
+
*
|
|
17719
17815
|
* When the parent IS a unanimous self-spend, every provider's view of the
|
|
17720
17816
|
* parent's OUTPUTS must additionally corroborate the primary's claimed
|
|
17721
17817
|
* UTXOs (index exists, pays the vault, exact value). Without this, a
|
|
@@ -17740,32 +17836,52 @@ ${auth.clientId}`;
|
|
|
17740
17836
|
)
|
|
17741
17837
|
)
|
|
17742
17838
|
);
|
|
17743
|
-
const
|
|
17744
|
-
|
|
17745
|
-
|
|
17746
|
-
|
|
17747
|
-
|
|
17839
|
+
const answered = [];
|
|
17840
|
+
const absences = [];
|
|
17841
|
+
const failures = [];
|
|
17842
|
+
settled.forEach((result, i) => {
|
|
17843
|
+
if (result.status === "fulfilled") {
|
|
17844
|
+
answered.push({ index: i, evaluation: result.value });
|
|
17845
|
+
return;
|
|
17846
|
+
}
|
|
17847
|
+
const described = `${providerName(i)} \u2192 ${result.reason?.message ?? String(result.reason)}`;
|
|
17848
|
+
if (isBitcoinTipUnreadableError(result.reason)) {
|
|
17849
|
+
absences.push(described);
|
|
17850
|
+
return;
|
|
17851
|
+
}
|
|
17852
|
+
failures.push(described);
|
|
17853
|
+
});
|
|
17748
17854
|
if (failures.length > 0) {
|
|
17749
17855
|
throw new Error(
|
|
17750
17856
|
`Self-change classification failed for tx ${parentTxid} on ${failures.length}/${providerConfigs.length} provider(s): ${failures.join("; ")}`
|
|
17751
17857
|
);
|
|
17752
17858
|
}
|
|
17753
|
-
const
|
|
17754
|
-
|
|
17755
|
-
|
|
17756
|
-
|
|
17757
|
-
|
|
17758
|
-
|
|
17859
|
+
const floor = Math.max(1, this.minConsensusProviders);
|
|
17860
|
+
if (answered.length < floor) {
|
|
17861
|
+
throw new Error(
|
|
17862
|
+
`Self-change classification for tx ${parentTxid}: only ${answered.length}/${providerConfigs.length} provider(s) could state a confirmation depth, below this chain's floor of ${floor}. Unreadable tips: ${absences.join("; ")}`
|
|
17863
|
+
);
|
|
17864
|
+
}
|
|
17865
|
+
if (absences.length > 0) {
|
|
17866
|
+
litDebugLog(
|
|
17867
|
+
`[VaultBalance] self-change: tx ${parentTxid} classified on a reduced quorum \u2014 ${answered.length}/${providerConfigs.length} provider(s) answered (floor ${floor}); dropped for an unreadable chain tip: ${absences.join("; ")}`
|
|
17868
|
+
);
|
|
17869
|
+
}
|
|
17870
|
+
const first = answered[0];
|
|
17871
|
+
const disagreements = answered.slice(1).filter((a) => a.evaluation.selfSpend !== first.evaluation.selfSpend).map(
|
|
17872
|
+
(a) => `${providerName(first.index)}=${first.evaluation.selfSpend} vs ${providerName(a.index)}=${a.evaluation.selfSpend}`
|
|
17759
17873
|
);
|
|
17760
17874
|
if (disagreements.length > 0) {
|
|
17761
17875
|
throw new Error(
|
|
17762
17876
|
`Self-change consensus mismatch for tx ${parentTxid}: ${disagreements.join("; ")}. A provider may be compromised or out of sync; refusing to sign.`
|
|
17763
17877
|
);
|
|
17764
17878
|
}
|
|
17765
|
-
if (!
|
|
17879
|
+
if (!first.evaluation.selfSpend) {
|
|
17766
17880
|
return false;
|
|
17767
17881
|
}
|
|
17768
|
-
const outputMismatches =
|
|
17882
|
+
const outputMismatches = answered.map(
|
|
17883
|
+
(a) => a.evaluation.outputMismatch ? `${providerName(a.index)} \u2192 ${a.evaluation.outputMismatch}` : null
|
|
17884
|
+
).filter((m) => m !== null);
|
|
17769
17885
|
if (outputMismatches.length > 0) {
|
|
17770
17886
|
throw new Error(
|
|
17771
17887
|
`Self-change output claim mismatch for tx ${parentTxid}: ${outputMismatches.join("; ")}. The reported UTXO set contradicts the parent transaction; refusing to sign.`
|
|
@@ -18008,16 +18124,6 @@ ${auth.clientId}`;
|
|
|
18008
18124
|
minConfirmations
|
|
18009
18125
|
);
|
|
18010
18126
|
const authorizedSpends = await this.getAuthorizedSpendsFromContract(positionId);
|
|
18011
|
-
for (const spend of authorizedSpends) {
|
|
18012
|
-
const utxoStillExists = utxoSet.utxos.some(
|
|
18013
|
-
(utxo) => utxo.txid === spend.txid && utxo.vout === spend.vout
|
|
18014
|
-
);
|
|
18015
|
-
if (utxoStillExists) {
|
|
18016
|
-
throw new Error(
|
|
18017
|
-
`Authorized UTXO ${spend.txid}:${spend.vout} not yet spent. Transaction was authorized in smart contract but not signed and broadcasted to Bitcoin network. Complete the transaction by signing and broadcasting it.`
|
|
18018
|
-
);
|
|
18019
|
-
}
|
|
18020
|
-
}
|
|
18021
18127
|
const authorizedBalance = authorizedSpends.reduce(
|
|
18022
18128
|
(sum, spend) => sum + spend.satoshis,
|
|
18023
18129
|
0n
|
|
@@ -18313,7 +18419,13 @@ ${auth.clientId}`;
|
|
|
18313
18419
|
allowDevSinglePriceProvider: false,
|
|
18314
18420
|
minBitcoinBalanceConfirmations: 1,
|
|
18315
18421
|
minBitcoinSpendConfirmations: 1,
|
|
18316
|
-
|
|
18422
|
+
// 2 since 2026-09-23. It was 1 because Sepolia ran a single faucet provider
|
|
18423
|
+
// "by design", so the consensus floor was documented as a mainnet-only
|
|
18424
|
+
// guarantee. The registry now holds two, and leaving the floor at 1 meant
|
|
18425
|
+
// Sepolia could never exercise the multi-provider agreement the stale-spend
|
|
18426
|
+
// and balance paths rely on — the one environment where that logic is
|
|
18427
|
+
// supposed to be proved before mainnet.
|
|
18428
|
+
minConsensusProviders: 2
|
|
18317
18429
|
},
|
|
18318
18430
|
[
|
|
18319
18431
|
"ethereum"
|
|
@@ -18347,12 +18459,12 @@ ${auth.clientId}`;
|
|
|
18347
18459
|
}
|
|
18348
18460
|
async function executeVaultSnapshot(params) {
|
|
18349
18461
|
global.ethers = {
|
|
18350
|
-
...
|
|
18462
|
+
...import_ethers52.ethers,
|
|
18351
18463
|
providers: {
|
|
18352
|
-
StaticJsonRpcProvider:
|
|
18464
|
+
StaticJsonRpcProvider: import_ethers52.ethers.JsonRpcProvider
|
|
18353
18465
|
},
|
|
18354
|
-
Contract:
|
|
18355
|
-
utils:
|
|
18466
|
+
Contract: import_ethers52.ethers.Contract,
|
|
18467
|
+
utils: import_ethers52.ethers
|
|
18356
18468
|
// v6 moved utils to top level
|
|
18357
18469
|
};
|
|
18358
18470
|
global.Lit = {
|
|
@@ -23922,9 +24034,35 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
|
|
|
23922
24034
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
23923
24035
|
};
|
|
23924
24036
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
24037
|
+
exports2.computeCidV0 = computeCidV0;
|
|
23925
24038
|
exports2.fetchLitActionCodeFromIpfs = fetchLitActionCodeFromIpfs;
|
|
23926
24039
|
var axios_1 = __importDefault(require_axios());
|
|
24040
|
+
var ethers_1 = require("ethers");
|
|
23927
24041
|
var ipfsCodeCache = /* @__PURE__ */ new Map();
|
|
24042
|
+
var CIDV0 = /^Qm[1-9A-HJ-NP-Za-km-z]{44}$/;
|
|
24043
|
+
var SINGLE_BLOCK_MAX_BYTES = 262144;
|
|
24044
|
+
function varint(n) {
|
|
24045
|
+
const out = [];
|
|
24046
|
+
while (n >= 128) {
|
|
24047
|
+
out.push(n & 127 | 128);
|
|
24048
|
+
n >>>= 7;
|
|
24049
|
+
}
|
|
24050
|
+
out.push(n);
|
|
24051
|
+
return out;
|
|
24052
|
+
}
|
|
24053
|
+
function computeCidV0(content) {
|
|
24054
|
+
const n = varint(content.length);
|
|
24055
|
+
const unixfs = new Uint8Array([8, 2, 18, ...n, ...content, 24, ...n]);
|
|
24056
|
+
const node = new Uint8Array([10, ...varint(unixfs.length), ...unixfs]);
|
|
24057
|
+
return (0, ethers_1.encodeBase58)(new Uint8Array([18, 32, ...(0, ethers_1.getBytes)((0, ethers_1.sha256)(node))]));
|
|
24058
|
+
}
|
|
24059
|
+
function responseBytes(data) {
|
|
24060
|
+
if (data instanceof Uint8Array)
|
|
24061
|
+
return data;
|
|
24062
|
+
if (data instanceof ArrayBuffer)
|
|
24063
|
+
return new Uint8Array(data);
|
|
24064
|
+
return null;
|
|
24065
|
+
}
|
|
23928
24066
|
var GATEWAY_TIMEOUT_MS = 2e4;
|
|
23929
24067
|
var buildGatewayList = (cid, pinataJwt) => {
|
|
23930
24068
|
const gateways = [];
|
|
@@ -23945,6 +24083,9 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
|
|
|
23945
24083
|
}
|
|
23946
24084
|
return cached;
|
|
23947
24085
|
}
|
|
24086
|
+
if (!CIDV0.test(cid)) {
|
|
24087
|
+
throw new Error(`Refusing to fetch LIT Action for ${cid}: only CIDv0 (Qm\u2026) content can be verified`);
|
|
24088
|
+
}
|
|
23948
24089
|
const pinataJwt = options.pinataJwt ?? process.env.PINATA_JWT;
|
|
23949
24090
|
const extraGateways = options.extraGateways?.map((t) => ({ url: t.replace("{cid}", cid) })) ?? [];
|
|
23950
24091
|
const gateways = [...extraGateways, ...buildGatewayList(cid, pinataJwt)];
|
|
@@ -23956,19 +24097,32 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
|
|
|
23956
24097
|
}
|
|
23957
24098
|
const response = await axios_1.default.get(gateway.url, {
|
|
23958
24099
|
timeout: GATEWAY_TIMEOUT_MS,
|
|
24100
|
+
responseType: "arraybuffer",
|
|
23959
24101
|
headers: {
|
|
23960
24102
|
Accept: "text/plain, application/javascript, text/javascript",
|
|
23961
24103
|
...gateway.headers
|
|
23962
24104
|
}
|
|
23963
24105
|
});
|
|
23964
|
-
|
|
23965
|
-
|
|
23966
|
-
|
|
23967
|
-
|
|
23968
|
-
ipfsCodeCache.set(cid, response.data);
|
|
23969
|
-
return response.data;
|
|
24106
|
+
const bytes = responseBytes(response.data);
|
|
24107
|
+
if (!bytes || bytes.length === 0) {
|
|
24108
|
+
failures.push(`${gateway.url}: HTTP ${response.status} returned ${bytes ? "an empty body" : typeof response.data}, expected bytes`);
|
|
24109
|
+
continue;
|
|
23970
24110
|
}
|
|
23971
|
-
|
|
24111
|
+
if (bytes.length > SINGLE_BLOCK_MAX_BYTES) {
|
|
24112
|
+
failures.push(`${gateway.url}: ${bytes.length} bytes exceeds the single-block CIDv0 limit (${SINGLE_BLOCK_MAX_BYTES}); content cannot be verified`);
|
|
24113
|
+
continue;
|
|
24114
|
+
}
|
|
24115
|
+
const actualCid = computeCidV0(bytes);
|
|
24116
|
+
if (actualCid !== cid) {
|
|
24117
|
+
failures.push(`${gateway.url}: content hashes to ${actualCid}, not the requested CID`);
|
|
24118
|
+
continue;
|
|
24119
|
+
}
|
|
24120
|
+
const code = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
24121
|
+
if (options.debug) {
|
|
24122
|
+
console.log(`\u2705 [fetchLitActionCodeFromIpfs] Fetched and verified from ${gateway.url}`);
|
|
24123
|
+
}
|
|
24124
|
+
ipfsCodeCache.set(cid, code);
|
|
24125
|
+
return code;
|
|
23972
24126
|
} catch (error) {
|
|
23973
24127
|
const message = error instanceof Error ? error.message : String(error);
|
|
23974
24128
|
failures.push(`${gateway.url}: ${message}`);
|
|
@@ -25456,6 +25610,53 @@ var require_pkp_signer_module = __commonJS({
|
|
|
25456
25610
|
}
|
|
25457
25611
|
});
|
|
25458
25612
|
|
|
25613
|
+
// node_modules/@gvnrdao/dh-lit-ops/dist/modules/mainnet-validator-wallets.js
|
|
25614
|
+
var require_mainnet_validator_wallets = __commonJS({
|
|
25615
|
+
"node_modules/@gvnrdao/dh-lit-ops/dist/modules/mainnet-validator-wallets.js"(exports2) {
|
|
25616
|
+
"use strict";
|
|
25617
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
25618
|
+
exports2.MAINNET_OP_VALIDATOR_WALLETS = exports2.SEPOLIA_DEFAULT_VALIDATOR_WALLET = exports2.NON_MAINNET_CHAIN_IDS = void 0;
|
|
25619
|
+
exports2.resolveMainnetValidatorWallet = resolveMainnetValidatorWallet;
|
|
25620
|
+
exports2.NON_MAINNET_CHAIN_IDS = /* @__PURE__ */ new Set([
|
|
25621
|
+
11155111,
|
|
25622
|
+
// Sepolia
|
|
25623
|
+
1337,
|
|
25624
|
+
// Hardhat (DH local deployment chainId)
|
|
25625
|
+
31337
|
|
25626
|
+
// Hardhat (default)
|
|
25627
|
+
]);
|
|
25628
|
+
exports2.SEPOLIA_DEFAULT_VALIDATOR_WALLET = "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c";
|
|
25629
|
+
exports2.MAINNET_OP_VALIDATOR_WALLETS = {
|
|
25630
|
+
ucdMintValidator: "0x19C8FeE0f8f4b6F9Aa8e521D4CC62F4697CF85af",
|
|
25631
|
+
processPaymentValidator: "0x01480725c1fA026fd4A6bfA3100c691aeC955135",
|
|
25632
|
+
extendPositionValidator: "0xcE08AF213D8d95ad3dD317276F9e93Ab2eD75030",
|
|
25633
|
+
btcWithdrawal: "0x69dCd1204CDB31437CaF7114f74422390b472d3A",
|
|
25634
|
+
loanVaultBtcBalance: "0xc3d549EEb62721750Ff6518f6730Ab0e8D0Fea97",
|
|
25635
|
+
liquidationValidator: "0x66B30C19173005A51f21e2e4180FD7BC8c1d485b",
|
|
25636
|
+
// Non-OAR: verified on-chain by BTCSpendAuthorizer.staleSpendValidatorAddress (set via
|
|
25637
|
+
// AdminModule to this PKP's derived signer). Self-deriving Safe-owned PKP; seed == signer.
|
|
25638
|
+
staleSpendRecoveryValidator: "0x58F9144cF9781c15C061ba86901905a5a19F7661",
|
|
25639
|
+
// Non-OAR: no on-chain consumer verifies these signatures. The Sepolia seed has no key
|
|
25640
|
+
// derivation registered on the mainnet Lit account, so they reuse the Safe-owned
|
|
25641
|
+
// pkp-validator PKP (live derivation, group 2). See
|
|
25642
|
+
// docs/INCIDENT_2026-09-21_MAINNET_PKP_DERIVATION_DECRYPT.md.
|
|
25643
|
+
btcAddressBalance: "0x19524aE4e514a0f08A542596c2DA0B2262c61f48",
|
|
25644
|
+
priceOracle: "0x19524aE4e514a0f08A542596c2DA0B2262c61f48"
|
|
25645
|
+
};
|
|
25646
|
+
function resolveMainnetValidatorWallet(args) {
|
|
25647
|
+
const { registryKey, chainId, wallet } = args;
|
|
25648
|
+
const isNonMainnetChain = Number.isFinite(chainId) && exports2.NON_MAINNET_CHAIN_IDS.has(chainId);
|
|
25649
|
+
if (isNonMainnetChain || !wallet || wallet.toLowerCase() !== exports2.SEPOLIA_DEFAULT_VALIDATOR_WALLET) {
|
|
25650
|
+
return wallet;
|
|
25651
|
+
}
|
|
25652
|
+
if (!registryKey || !Object.prototype.hasOwnProperty.call(exports2.MAINNET_OP_VALIDATOR_WALLETS, registryKey)) {
|
|
25653
|
+
return wallet;
|
|
25654
|
+
}
|
|
25655
|
+
return exports2.MAINNET_OP_VALIDATOR_WALLETS[registryKey];
|
|
25656
|
+
}
|
|
25657
|
+
}
|
|
25658
|
+
});
|
|
25659
|
+
|
|
25459
25660
|
// node_modules/@gvnrdao/dh-lit-ops/dist/utils/async-request.util.js
|
|
25460
25661
|
var require_async_request_util = __commonJS({
|
|
25461
25662
|
"node_modules/@gvnrdao/dh-lit-ops/dist/utils/async-request.util.js"(exports2) {
|
|
@@ -25483,7 +25684,9 @@ var require_async_request_util = __commonJS({
|
|
|
25483
25684
|
});
|
|
25484
25685
|
if (!submitResponse.ok) {
|
|
25485
25686
|
const errorText = await submitResponse.text();
|
|
25486
|
-
|
|
25687
|
+
const retryAfter = submitResponse.status === 429 ? submitResponse.headers.get("retry-after") : null;
|
|
25688
|
+
const retryHint = retryAfter && /^\d+$/.test(retryAfter.trim()) ? ` Retry after ${retryAfter.trim()}s.` : "";
|
|
25689
|
+
throw new Error(`Failed to submit request (${submitResponse.status}): ${errorText}${retryHint}`);
|
|
25487
25690
|
}
|
|
25488
25691
|
const submitEnvelope = await submitResponse.json();
|
|
25489
25692
|
if (!submitEnvelope.success || !submitEnvelope.data?.ticketId) {
|
|
@@ -25761,6 +25964,7 @@ var require_lit_ops_module = __commonJS({
|
|
|
25761
25964
|
var pkp_manager_module_1 = require_pkp_manager_module();
|
|
25762
25965
|
var pkp_minter_module_1 = require_pkp_minter_module();
|
|
25763
25966
|
var pkp_signer_module_1 = require_pkp_signer_module();
|
|
25967
|
+
var mainnet_validator_wallets_1 = require_mainnet_validator_wallets();
|
|
25764
25968
|
var async_request_util_1 = require_async_request_util();
|
|
25765
25969
|
var crypto_1 = require("crypto");
|
|
25766
25970
|
var lit_core_lit_action_client_1 = require_lit_core_lit_action_client();
|
|
@@ -25773,26 +25977,6 @@ var require_lit_ops_module = __commonJS({
|
|
|
25773
25977
|
{ name: "borrower", type: "address" }
|
|
25774
25978
|
]
|
|
25775
25979
|
};
|
|
25776
|
-
var NON_MAINNET_CHAIN_IDS = /* @__PURE__ */ new Set([
|
|
25777
|
-
11155111,
|
|
25778
|
-
// Sepolia
|
|
25779
|
-
1337,
|
|
25780
|
-
// Hardhat (DH local deployment chainId)
|
|
25781
|
-
31337
|
|
25782
|
-
// Hardhat (default)
|
|
25783
|
-
]);
|
|
25784
|
-
var SEPOLIA_DEFAULT_VALIDATOR_WALLET = "0x82db9f515957aa380b596c6ea2bd30cef181f236";
|
|
25785
|
-
var MAINNET_OP_VALIDATOR_WALLETS = {
|
|
25786
|
-
ucdMintValidator: "0x19C8FeE0f8f4b6F9Aa8e521D4CC62F4697CF85af",
|
|
25787
|
-
processPaymentValidator: "0x01480725c1fA026fd4A6bfA3100c691aeC955135",
|
|
25788
|
-
extendPositionValidator: "0xcE08AF213D8d95ad3dD317276F9e93Ab2eD75030",
|
|
25789
|
-
btcWithdrawal: "0x69dCd1204CDB31437CaF7114f74422390b472d3A",
|
|
25790
|
-
loanVaultBtcBalance: "0xc3d549EEb62721750Ff6518f6730Ab0e8D0Fea97",
|
|
25791
|
-
liquidationValidator: "0x66B30C19173005A51f21e2e4180FD7BC8c1d485b",
|
|
25792
|
-
// Non-OAR: verified on-chain by BTCSpendAuthorizer.staleSpendValidatorAddress (set via
|
|
25793
|
-
// AdminModule to this PKP's derived signer). Self-deriving Safe-owned PKP; seed == signer.
|
|
25794
|
-
staleSpendRecoveryValidator: "0x58F9144cF9781c15C061ba86901905a5a19F7661"
|
|
25795
|
-
};
|
|
25796
25980
|
function resolvePkpValidationRegistryAddress(config) {
|
|
25797
25981
|
const fromConfig = config.pkpValidationRegistryAddress;
|
|
25798
25982
|
return fromConfig || process.env.PKP_VALIDATION_REGISTRY_ADDRESS || process.env.PKP_VALIDATION_REGISTRY;
|
|
@@ -27033,17 +27217,18 @@ var require_lit_ops_module = __commonJS({
|
|
|
27033
27217
|
let effectiveValidatorWallet = litActionInfo.validatorWalletAddress;
|
|
27034
27218
|
const jp = jsParams;
|
|
27035
27219
|
const resolvedChainId = Number(jp.chainId ?? jp.auth?.chainId ?? jp.authMessage?.chainId ?? this.config.chainId);
|
|
27036
|
-
const
|
|
27037
|
-
|
|
27038
|
-
|
|
27039
|
-
|
|
27040
|
-
|
|
27041
|
-
|
|
27042
|
-
|
|
27043
|
-
|
|
27044
|
-
|
|
27045
|
-
effectiveValidatorWallet
|
|
27220
|
+
const reg = (0, dh_lit_actions_1.getDeploymentsForNetwork)(this.config.network);
|
|
27221
|
+
const registryKey = Object.keys(reg).find((k) => reg[k]?.cid === litActionInfo.cid);
|
|
27222
|
+
const mainnetWallet = (0, mainnet_validator_wallets_1.resolveMainnetValidatorWallet)({
|
|
27223
|
+
registryKey,
|
|
27224
|
+
chainId: resolvedChainId,
|
|
27225
|
+
wallet: effectiveValidatorWallet
|
|
27226
|
+
});
|
|
27227
|
+
if (mainnetWallet !== effectiveValidatorWallet) {
|
|
27228
|
+
if (this.config.debug) {
|
|
27229
|
+
console.log(`[${label}] mainnet validator remap (${registryKey}, chainId=${Number.isFinite(resolvedChainId) ? resolvedChainId : "unknown\u2192mainnet"}): ${effectiveValidatorWallet} -> ${mainnetWallet}`);
|
|
27046
27230
|
}
|
|
27231
|
+
effectiveValidatorWallet = mainnetWallet;
|
|
27047
27232
|
}
|
|
27048
27233
|
if (process.env.LIT_LANE_VALIDATOR_WALLET_OVERRIDE) {
|
|
27049
27234
|
if (process.env.LIT_LANE_GUARD !== "1") {
|
|
@@ -27159,7 +27344,7 @@ var require_lit_ops_module = __commonJS({
|
|
|
27159
27344
|
break;
|
|
27160
27345
|
case 11155111:
|
|
27161
27346
|
chain = "sepolia";
|
|
27162
|
-
bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://
|
|
27347
|
+
bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://regtest.diamondhands.credit/api/esplora";
|
|
27163
27348
|
break;
|
|
27164
27349
|
case 1337:
|
|
27165
27350
|
// Hardhat local testnet (actual deployment chainId)
|
|
@@ -27348,7 +27533,7 @@ var require_lit_ops_module = __commonJS({
|
|
|
27348
27533
|
break;
|
|
27349
27534
|
case 11155111:
|
|
27350
27535
|
chain = "sepolia";
|
|
27351
|
-
bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://
|
|
27536
|
+
bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://regtest.diamondhands.credit/api/esplora";
|
|
27352
27537
|
break;
|
|
27353
27538
|
case 1337:
|
|
27354
27539
|
// Hardhat local testnet (actual deployment chainId)
|
|
@@ -27539,7 +27724,7 @@ var require_lit_ops_module = __commonJS({
|
|
|
27539
27724
|
break;
|
|
27540
27725
|
case 11155111:
|
|
27541
27726
|
chain = "sepolia";
|
|
27542
|
-
bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://
|
|
27727
|
+
bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://regtest.diamondhands.credit/api/esplora";
|
|
27543
27728
|
break;
|
|
27544
27729
|
case 1337:
|
|
27545
27730
|
case 31337:
|
|
@@ -27687,7 +27872,7 @@ var require_lit_ops_module = __commonJS({
|
|
|
27687
27872
|
break;
|
|
27688
27873
|
case 11155111:
|
|
27689
27874
|
chain = "sepolia";
|
|
27690
|
-
bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://
|
|
27875
|
+
bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://regtest.diamondhands.credit/api/esplora";
|
|
27691
27876
|
break;
|
|
27692
27877
|
case 1337:
|
|
27693
27878
|
// Hardhat local testnet (actual deployment chainId)
|
|
@@ -27907,7 +28092,7 @@ var require_lit_ops_module = __commonJS({
|
|
|
27907
28092
|
bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://mempool.space/api";
|
|
27908
28093
|
break;
|
|
27909
28094
|
case 11155111:
|
|
27910
|
-
bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://
|
|
28095
|
+
bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://regtest.diamondhands.credit/api/esplora";
|
|
27911
28096
|
break;
|
|
27912
28097
|
case 1337:
|
|
27913
28098
|
// Hardhat local testnet (actual deployment chainId)
|
|
@@ -28210,7 +28395,11 @@ var require_lit_ops_module = __commonJS({
|
|
|
28210
28395
|
error: "sign=true requires price oracle PKP in registry (ethAddress/publicKey) or options.pkpId (Lit jsParams pkpId)"
|
|
28211
28396
|
};
|
|
28212
28397
|
}
|
|
28213
|
-
priceOracleParams.pkpId =
|
|
28398
|
+
priceOracleParams.pkpId = (0, mainnet_validator_wallets_1.resolveMainnetValidatorWallet)({
|
|
28399
|
+
registryKey: "priceOracle",
|
|
28400
|
+
chainId: Number(this.config.chainId),
|
|
28401
|
+
wallet: resolvedPkpId
|
|
28402
|
+
});
|
|
28214
28403
|
}
|
|
28215
28404
|
if (this.config.debug) {
|
|
28216
28405
|
console.log("\u{1F4B0} Calling Price Oracle LIT Action:");
|
|
@@ -40435,7 +40624,7 @@ var require_dist3 = __commonJS({
|
|
|
40435
40624
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
40436
40625
|
};
|
|
40437
40626
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
40438
|
-
exports2.default = exports2.broadcastSignedBitcoinTransaction = exports2.convertEthereumSignatureToBitcoinDER = exports2.CORE_API_TRANSPORT_FAILURE_MARKER = exports2.isCoreApiTransportError = exports2.describeErrorWithCause = exports2.normalizeCoreLitActionResult = exports2.executeLitActionViaCoreApi = exports2.fetchLitActionCodeFromIpfs = exports2.redactPositionIdForLog = exports2.asyncRequest = exports2.TaskQueue = exports2.TicketManager = exports2.PKPSigner = exports2.PKPAuthorizerUtils = exports2.PKPAuthorizer = exports2.PKPMinterUtils = exports2.PKPMinter = exports2.PKPManager = exports2.LitActionExecutor = exports2.LitAuthManager = exports2.LitOps = exports2.cidToHex = exports2.getDeploymentsForNetwork = void 0;
|
|
40627
|
+
exports2.default = exports2.broadcastSignedBitcoinTransaction = exports2.convertEthereumSignatureToBitcoinDER = exports2.CORE_API_TRANSPORT_FAILURE_MARKER = exports2.isCoreApiTransportError = exports2.describeErrorWithCause = exports2.normalizeCoreLitActionResult = exports2.executeLitActionViaCoreApi = exports2.fetchLitActionCodeFromIpfs = exports2.redactPositionIdForLog = exports2.asyncRequest = exports2.TaskQueue = exports2.TicketManager = exports2.PKPSigner = exports2.PKPAuthorizerUtils = exports2.PKPAuthorizer = exports2.PKPMinterUtils = exports2.PKPMinter = exports2.PKPManager = exports2.LitActionExecutor = exports2.LitAuthManager = exports2.resolveMainnetValidatorWallet = exports2.LitOps = exports2.cidToHex = exports2.getDeploymentsForNetwork = void 0;
|
|
40439
40628
|
__exportStar(require_interfaces(), exports2);
|
|
40440
40629
|
var dh_lit_actions_1 = require_pkg_src();
|
|
40441
40630
|
Object.defineProperty(exports2, "getDeploymentsForNetwork", { enumerable: true, get: function() {
|
|
@@ -40448,6 +40637,10 @@ var require_dist3 = __commonJS({
|
|
|
40448
40637
|
Object.defineProperty(exports2, "LitOps", { enumerable: true, get: function() {
|
|
40449
40638
|
return lit_ops_module_1.LitOps;
|
|
40450
40639
|
} });
|
|
40640
|
+
var mainnet_validator_wallets_1 = require_mainnet_validator_wallets();
|
|
40641
|
+
Object.defineProperty(exports2, "resolveMainnetValidatorWallet", { enumerable: true, get: function() {
|
|
40642
|
+
return mainnet_validator_wallets_1.resolveMainnetValidatorWallet;
|
|
40643
|
+
} });
|
|
40451
40644
|
var auth_manager_module_1 = require_auth_manager_module();
|
|
40452
40645
|
Object.defineProperty(exports2, "LitAuthManager", { enumerable: true, get: function() {
|
|
40453
40646
|
return auth_manager_module_1.LitAuthManager;
|
|
@@ -40590,7 +40783,8 @@ var init_wc_transport = __esm({
|
|
|
40590
40783
|
this.client = client;
|
|
40591
40784
|
this.cfg = cfg;
|
|
40592
40785
|
this.scratch = scratch;
|
|
40593
|
-
client.on("session_delete", () => {
|
|
40786
|
+
client.on("session_delete", ({ topic }) => {
|
|
40787
|
+
if (this.session === null || this.session.topic !== topic) return;
|
|
40594
40788
|
this.session = null;
|
|
40595
40789
|
this.sessionListener?.(null);
|
|
40596
40790
|
});
|
|
@@ -40602,7 +40796,7 @@ var init_wc_transport = __esm({
|
|
|
40602
40796
|
const client = await import_sign_client.default.init({
|
|
40603
40797
|
core,
|
|
40604
40798
|
projectId: cfg.projectId,
|
|
40605
|
-
metadata: WC_DAPP_METADATA
|
|
40799
|
+
metadata: cfg.metadata ?? WC_DAPP_METADATA
|
|
40606
40800
|
});
|
|
40607
40801
|
return new _WcTransport(client, cfg, scratch);
|
|
40608
40802
|
}
|
|
@@ -40620,14 +40814,21 @@ var init_wc_transport = __esm({
|
|
|
40620
40814
|
optionalNamespaces: wcSessionNamespaces(this.cfg.chainId)
|
|
40621
40815
|
});
|
|
40622
40816
|
if (!uri) throw new Error("WalletConnect returned no pairing URI");
|
|
40817
|
+
const pairingId = /^wc:([0-9a-f]+)@/i.exec(uri)?.[1];
|
|
40818
|
+
if (!pairingId) throw new Error(`WalletConnect pairing URI has no recognisable topic: ${uri.slice(0, 12)}\u2026`);
|
|
40623
40819
|
void approval().then((session) => {
|
|
40624
40820
|
const first = session.namespaces["eip155"]?.accounts[0];
|
|
40625
40821
|
if (!first) throw new Error("WalletConnect session carries no eip155 account");
|
|
40626
40822
|
const [, chainIdStr, account] = first.split(":");
|
|
40823
|
+
const previous = this.session;
|
|
40627
40824
|
this.session = { topic: session.topic, account, chainId: Number(chainIdStr) };
|
|
40628
|
-
this.sessionListener?.(this.active());
|
|
40825
|
+
const verdict = this.sessionListener?.({ ...this.active(), pairingId });
|
|
40826
|
+
if (verdict === false) {
|
|
40827
|
+
this.session = previous;
|
|
40828
|
+
void this.client.disconnect({ topic: session.topic, reason: { code: 6e3, message: "session refused by the bridge" } }).catch(() => void 0);
|
|
40829
|
+
}
|
|
40629
40830
|
}).catch((e) => console.error(`[dh-mcp] WalletConnect pairing failed: ${e.message}`));
|
|
40630
|
-
return { uri };
|
|
40831
|
+
return { uri, pairingId };
|
|
40631
40832
|
}
|
|
40632
40833
|
/** Route one wallet request over the active session. Throws on user rejection. */
|
|
40633
40834
|
async request(method, params) {
|
|
@@ -40662,6 +40863,7 @@ var import_node_crypto8 = require("crypto");
|
|
|
40662
40863
|
var fs5 = __toESM(require("fs"));
|
|
40663
40864
|
var os2 = __toESM(require("os"));
|
|
40664
40865
|
var path4 = __toESM(require("path"));
|
|
40866
|
+
var import_ethers51 = require("ethers");
|
|
40665
40867
|
|
|
40666
40868
|
// src/boundary/envelope.ts
|
|
40667
40869
|
function okEnvelope(data, source, warnings = []) {
|
|
@@ -40750,8 +40952,13 @@ function iso(sec) {
|
|
|
40750
40952
|
return new Date(sec * 1e3).toISOString();
|
|
40751
40953
|
}
|
|
40752
40954
|
var PSM_FLOOR_TOLERANCE_BPS = 100;
|
|
40955
|
+
var CANONICAL_MAINNET_USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
|
40956
|
+
function stablecoinKindFor(network, stablecoinAddress) {
|
|
40957
|
+
if (network !== "mainnet") return "mock";
|
|
40958
|
+
return stablecoinAddress.toLowerCase() === CANONICAL_MAINNET_USDC.toLowerCase() ? "circle" : "onchain";
|
|
40959
|
+
}
|
|
40753
40960
|
function failureToError(f) {
|
|
40754
|
-
const code = f.kind === "signer-missing" ? "SIGNER_UNAVAILABLE" : f.kind === "unavailable" ? "UPSTREAM_UNAVAILABLE" : f.kind === "not-found" ? "NOT_FOUND" : "UPSTREAM_REJECTED";
|
|
40961
|
+
const code = f.kind === "signer-missing" ? "SIGNER_UNAVAILABLE" : f.kind === "unavailable" ? "UPSTREAM_UNAVAILABLE" : f.kind === "unsupported" ? "NOT_IMPLEMENTED" : f.kind === "not-found" ? "NOT_FOUND" : "UPSTREAM_REJECTED";
|
|
40755
40962
|
const message = f.kind === "malformed" ? `${f.message} (upstream response failed integrity checks)` : f.message;
|
|
40756
40963
|
return boundaryError(code, message, {
|
|
40757
40964
|
source: f.source,
|
|
@@ -41227,7 +41434,7 @@ var BoundaryCore = class {
|
|
|
41227
41434
|
tokenAddress: a.tokenAddress,
|
|
41228
41435
|
spenderAddress: a.spenderAddress,
|
|
41229
41436
|
spenderContract: a.spenderContract,
|
|
41230
|
-
spenderReason: a.spenderContract === "SimplePSMV2" ?
|
|
41437
|
+
spenderReason: a.spenderContract === "SimplePSMV2" ? `the PSM contract itself pulls the ${a.tokenSymbol} it converts (transferFrom), so the ${a.tokenSymbol} allowance goes to the PSM` : "the PSM burns your UCD THROUGH the UCDController (controller.burnFromPsm), so the UCD allowance goes to the UCDController \u2014 a different contract than the PSM, by design",
|
|
41231
41438
|
before: a.before,
|
|
41232
41439
|
amountUnit: q.amountInUnit,
|
|
41233
41440
|
basis: "approvals are planned against the allowance read before signing: none when it already covers the amount; an exact approve when it is 0; a partial allowance is reset to 0 first (some tokens refuse a non-zero \u2192 non-zero approve). Every approve is EXACTLY the input amount \u2014 never unlimited."
|
|
@@ -41286,9 +41493,10 @@ var BoundaryCore = class {
|
|
|
41286
41493
|
chainId: this.deps.chainId,
|
|
41287
41494
|
psmAddress: s.psmAddress,
|
|
41288
41495
|
stablecoinAddress: s.stablecoinAddress,
|
|
41289
|
-
//
|
|
41290
|
-
// practice
|
|
41291
|
-
|
|
41496
|
+
// Labelled by the ACTUAL coin, not the network (C-49): `circle` only for canonical
|
|
41497
|
+
// mainnet USDC, `mock` for the practice token, `onchain` for any other real coin
|
|
41498
|
+
// (e.g. mainnet USDT) — a USDT swap must never render as "real USDC".
|
|
41499
|
+
stablecoinKind: stablecoinKindFor(this.deps.network, s.stablecoinAddress),
|
|
41292
41500
|
stablecoinSymbol: s.stablecoinSymbol,
|
|
41293
41501
|
stablecoinDecimals: s.stablecoinDecimals,
|
|
41294
41502
|
exchangeRate: s.exchangeRate,
|
|
@@ -43154,8 +43362,13 @@ var SignerManager = class {
|
|
|
43154
43362
|
mode: deps.initialMode,
|
|
43155
43363
|
borrower: deps.configuredBorrower ?? null
|
|
43156
43364
|
};
|
|
43365
|
+
if (deps.authenticatedBorrower) this.state = { ...this.state, borrower: deps.authenticatedBorrower };
|
|
43157
43366
|
}
|
|
43158
43367
|
state;
|
|
43368
|
+
/** True when the borrower is the signed-in identity and cannot be swapped. */
|
|
43369
|
+
identityPinned() {
|
|
43370
|
+
return this.deps.authenticatedBorrower !== void 0;
|
|
43371
|
+
}
|
|
43159
43372
|
mode() {
|
|
43160
43373
|
return this.state.mode;
|
|
43161
43374
|
}
|
|
@@ -43195,7 +43408,7 @@ var SignerManager = class {
|
|
|
43195
43408
|
this.deps.persistence.save(this.state);
|
|
43196
43409
|
}
|
|
43197
43410
|
resetBorrower() {
|
|
43198
|
-
this.state = { ...this.state, borrower: null };
|
|
43411
|
+
this.state = { ...this.state, borrower: this.deps.authenticatedBorrower ?? null };
|
|
43199
43412
|
this.deps.persistence.save(this.state);
|
|
43200
43413
|
}
|
|
43201
43414
|
async use(mode, opts) {
|
|
@@ -44270,6 +44483,35 @@ var import_ethers9 = require("ethers");
|
|
|
44270
44483
|
// src/boundary/upstream/shared/external-bridge/card.ts
|
|
44271
44484
|
var import_ethers7 = require("ethers");
|
|
44272
44485
|
init_tx_validator();
|
|
44486
|
+
|
|
44487
|
+
// src/boundary/upstream/shared/external-bridge/card-escape.ts
|
|
44488
|
+
var MAX_VALUE_CHARS = 200;
|
|
44489
|
+
function mustEscape(code) {
|
|
44490
|
+
if (code <= 31 || code === 127) return true;
|
|
44491
|
+
if (code >= 128 && code <= 159) return true;
|
|
44492
|
+
if (code === 8232 || code === 8233) return true;
|
|
44493
|
+
if (code >= 8234 && code <= 8238) return true;
|
|
44494
|
+
if (code >= 8294 && code <= 8297) return true;
|
|
44495
|
+
return false;
|
|
44496
|
+
}
|
|
44497
|
+
function safeValue(raw) {
|
|
44498
|
+
let out = "";
|
|
44499
|
+
for (const ch of String(raw)) {
|
|
44500
|
+
const code = ch.codePointAt(0);
|
|
44501
|
+
out += mustEscape(code) ? `\\u${code.toString(16).padStart(4, "0")}` : ch;
|
|
44502
|
+
if (out.length > MAX_VALUE_CHARS) return `${out.slice(0, MAX_VALUE_CHARS)}\u2026[truncated]`;
|
|
44503
|
+
}
|
|
44504
|
+
return out;
|
|
44505
|
+
}
|
|
44506
|
+
|
|
44507
|
+
// src/boundary/upstream/shared/external-bridge/card.ts
|
|
44508
|
+
function formatBtc(sats) {
|
|
44509
|
+
const negative = sats < 0n;
|
|
44510
|
+
const abs = negative ? -sats : sats;
|
|
44511
|
+
const whole = abs / 10n ** 8n;
|
|
44512
|
+
const frac = (abs % 10n ** 8n).toString().padStart(8, "0").replace(/0+$/, "");
|
|
44513
|
+
return `${negative ? "-" : ""}${whole}${frac ? "." + frac : ""}`;
|
|
44514
|
+
}
|
|
44273
44515
|
function formatUcd(wei) {
|
|
44274
44516
|
const negative = wei < 0n;
|
|
44275
44517
|
const abs = negative ? -wei : wei;
|
|
@@ -44315,15 +44557,15 @@ function cardForTx(tx2) {
|
|
|
44315
44557
|
"Operation: create a new borrowing position (your wallet is the borrower)",
|
|
44316
44558
|
`Term: ${Number(args[4])} months`,
|
|
44317
44559
|
`Position key (PKP id): ${String(args[0])}`,
|
|
44318
|
-
`BTC vault (mainnet form): ${
|
|
44319
|
-
`BTC vault (regtest form): ${
|
|
44560
|
+
`BTC vault (mainnet form): ${safeValue(args[2])}`,
|
|
44561
|
+
`BTC vault (regtest form): ${safeValue(args[3])}`,
|
|
44320
44562
|
`Validator generation: ${Number(args[5])}`,
|
|
44321
44563
|
...head
|
|
44322
44564
|
];
|
|
44323
44565
|
case "addAddress":
|
|
44324
44566
|
return [
|
|
44325
44567
|
"Operation: allowlist a Bitcoin withdrawal destination for YOUR account",
|
|
44326
|
-
`BTC address to allowlist: ${
|
|
44568
|
+
`BTC address to allowlist: ${safeValue(args[0])}`,
|
|
44327
44569
|
"Withdrawals to this address become possible only after the registry's on-chain delay",
|
|
44328
44570
|
...head
|
|
44329
44571
|
];
|
|
@@ -44351,15 +44593,40 @@ function cardForTx(tx2) {
|
|
|
44351
44593
|
`Minimum stablecoin out \u2014 the slippage floor (smallest units): ${String(args[2])}`,
|
|
44352
44594
|
...head
|
|
44353
44595
|
];
|
|
44596
|
+
case "withdrawBTC": {
|
|
44597
|
+
const p = args[0];
|
|
44598
|
+
return [
|
|
44599
|
+
"Operation: withdraw BTC from your vault \u2014 THIS MOVES BITCOIN OUT",
|
|
44600
|
+
`Position: ${safeValue(p.positionId)}`,
|
|
44601
|
+
// The destination is the whole security question of this card. It is a caller-
|
|
44602
|
+
// supplied string, hence safeValue: see the escaping note above.
|
|
44603
|
+
`BTC sent to: ${safeValue(p.withdrawalAddress)}`,
|
|
44604
|
+
`Leaves the vault (fee included): ${formatBtc(BigInt(p.totalDeduction))} BTC (${BigInt(p.totalDeduction)} sats)`,
|
|
44605
|
+
`Collateral remaining after this: ${formatBtc(BigInt(p.newCollateral))} BTC (${BigInt(p.newCollateral)} sats)`,
|
|
44606
|
+
`Spending vault UTXO: ${safeValue(p.utxoTxid)}:${Number(p.utxoVout)}`,
|
|
44607
|
+
...head
|
|
44608
|
+
];
|
|
44609
|
+
}
|
|
44610
|
+
case "setPositionDelegate":
|
|
44611
|
+
return [
|
|
44612
|
+
"Operation: set the DELEGATE for this position \u2014 this address may act on the position on your behalf",
|
|
44613
|
+
`Position: ${safeValue(args[0])}`,
|
|
44614
|
+
`Delegate address: ${safeValue(args[1])}`,
|
|
44615
|
+
"Setting the zero address removes the current delegate",
|
|
44616
|
+
...head
|
|
44617
|
+
];
|
|
44354
44618
|
default:
|
|
44355
|
-
|
|
44619
|
+
throw new Error(
|
|
44620
|
+
`no approval card is defined for the signable function "${name}" \u2014 add a case to cardForTx before this operation can be approved`
|
|
44621
|
+
);
|
|
44356
44622
|
}
|
|
44357
44623
|
}
|
|
44358
44624
|
function cardForTypedData(action, payload) {
|
|
44359
44625
|
const m = payload.message;
|
|
44360
44626
|
return [
|
|
44361
44627
|
`Operation: ${action} \u2014 this signature AUTHORIZES the operation described below; the protocol executes it after your approval`,
|
|
44362
|
-
|
|
44628
|
+
// `detail` here is a server-composed string — same escaping rule as the tx card.
|
|
44629
|
+
...Object.entries(m).map(([k, v]) => `${safeValue(k)}: ${safeValue(v)}`),
|
|
44363
44630
|
`Signing domain: ${String(payload.domain["name"])} v${String(payload.domain["version"])} \xB7 chain ${String(payload.domain["chainId"])}`
|
|
44364
44631
|
];
|
|
44365
44632
|
}
|
|
@@ -44710,12 +44977,10 @@ init_tx_validator();
|
|
|
44710
44977
|
|
|
44711
44978
|
// src/boundary/upstream/shared/quantum.ts
|
|
44712
44979
|
var QUANTUM_WINDOW_SECONDS = 60;
|
|
44713
|
-
var AUTH_VALIDITY_WINDOWS = 3;
|
|
44714
|
-
function authValiditySec() {
|
|
44715
|
-
return QUANTUM_WINDOW_SECONDS * AUTH_VALIDITY_WINDOWS;
|
|
44716
|
-
}
|
|
44717
44980
|
function isAuthFresh(issuedAtSec, nowSec) {
|
|
44718
|
-
|
|
44981
|
+
const sq = Math.floor(issuedAtSec / QUANTUM_WINDOW_SECONDS) * QUANTUM_WINDOW_SECONDS;
|
|
44982
|
+
const cq = Math.floor(nowSec / QUANTUM_WINDOW_SECONDS) * QUANTUM_WINDOW_SECONDS;
|
|
44983
|
+
return sq === cq - QUANTUM_WINDOW_SECONDS || sq === cq || sq === cq + QUANTUM_WINDOW_SECONDS;
|
|
44719
44984
|
}
|
|
44720
44985
|
function isStrictCurrentQuantum(issuedAtSec, nowSec) {
|
|
44721
44986
|
return issuedAtSec <= nowSec && Math.floor(issuedAtSec / QUANTUM_WINDOW_SECONDS) === Math.floor(nowSec / QUANTUM_WINDOW_SECONDS);
|
|
@@ -44756,7 +45021,7 @@ var SafeCeremony = class {
|
|
|
44756
45021
|
if (!auth.ok) return auth.refusal;
|
|
44757
45022
|
if (!isAuthFresh(issuedAtSec, surface.nowSec())) {
|
|
44758
45023
|
return this.refuse(
|
|
44759
|
-
`${p.action}: the owners' authorization expired \u2014 issued
|
|
45024
|
+
`${p.action}: the owners' authorization expired \u2014 issued outside the past/current/next quantum window (${QUANTUM_WINDOW_SECONDS}s quanta); gather the owners and sign again`
|
|
44760
45025
|
);
|
|
44761
45026
|
}
|
|
44762
45027
|
const raw = await executor.signTransaction({
|
|
@@ -51475,7 +51740,6 @@ var init_deployment_addresses = __esm2({
|
|
|
51475
51740
|
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
51476
51741
|
FeeRecipientRegistry: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
|
|
51477
51742
|
BitcoinWithdrawalAddressRegistry: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
|
|
51478
|
-
CarryAgentRegistry: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
|
|
51479
51743
|
AgentDelegationRegistry: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
|
|
51480
51744
|
DHAgentDelegate: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF",
|
|
51481
51745
|
AgentModuleFactory: "0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5"
|
|
@@ -51524,11 +51788,11 @@ var init_deployment_addresses = __esm2({
|
|
|
51524
51788
|
reason: "Shared upgrade script: AdminModule implementation update"
|
|
51525
51789
|
},
|
|
51526
51790
|
PositionManagerViews: {
|
|
51527
|
-
previousImplementation: "
|
|
51528
|
-
newImplementation: "
|
|
51529
|
-
upgradedAt: "2026-
|
|
51530
|
-
upgradedBy: "
|
|
51531
|
-
reason: "
|
|
51791
|
+
previousImplementation: "0xA455B542cFb36AF8451fc420dB89e590E5c87cef",
|
|
51792
|
+
newImplementation: "0x8cEB3F1c07fDB3301f55b96a5B9aDb33C8d36Da3",
|
|
51793
|
+
upgradedAt: "2026-10-02T17:04:25.853Z",
|
|
51794
|
+
upgradedBy: "0x0f8f23674cc90Ef7107930a4437341fD8B460362",
|
|
51795
|
+
reason: "1.1.2: getBackingVaults (PoR backing set) + implementation lock (constructor)"
|
|
51532
51796
|
},
|
|
51533
51797
|
TestPositionManager: {
|
|
51534
51798
|
previousImplementation: "0x0B46Ee1a9C6b42559758B7FF78294Cd867BB08f8",
|
|
@@ -51745,8 +52009,6 @@ var init_deployment_addresses = __esm2({
|
|
|
51745
52009
|
OPERATION_AUTHORIZATION_REGISTRY_IMPL: "0xe0D981B60351f0f8fFDA2b50C8180Fb37CeF3883",
|
|
51746
52010
|
BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
|
|
51747
52011
|
BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY_IMPL: "0x76E0a2c9d89562fD7c50b5f554d7fa25957e39Db",
|
|
51748
|
-
CARRY_AGENT_REGISTRY: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
|
|
51749
|
-
CARRY_AGENT_REGISTRY_IMPL: "0x1b11a3D5e46F3672E643c997f0d569DFf0b64a01",
|
|
51750
52012
|
AGENT_DELEGATION_REGISTRY: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
|
|
51751
52013
|
AGENT_DELEGATION_REGISTRY_IMPL: "0xE931E4b9ceF2A48Ac7D57192da4B523756cFC310",
|
|
51752
52014
|
DH_AGENT_DELEGATE: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF"
|
|
@@ -51778,7 +52040,6 @@ var init_deployment_addresses = __esm2({
|
|
|
51778
52040
|
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
51779
52041
|
FeeRecipientRegistry: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
|
|
51780
52042
|
BitcoinWithdrawalAddressRegistry: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
|
|
51781
|
-
CarryAgentRegistry: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
|
|
51782
52043
|
AgentDelegationRegistry: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
|
|
51783
52044
|
DHAgentDelegate: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF",
|
|
51784
52045
|
AgentModuleFactory: "0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5"
|
|
@@ -52753,113 +53014,113 @@ var require_pkg_src2 = __commonJS2({
|
|
|
52753
53014
|
deployedAt: 1784569687492,
|
|
52754
53015
|
size: 4140,
|
|
52755
53016
|
hash: "4c0d65bf1f33cdac22a78fd8c4764319cc3fe00650e0fe7fa8a6090d9a318a7b",
|
|
52756
|
-
validatorWalletAddress: "
|
|
53017
|
+
validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
|
|
52757
53018
|
pkp: {
|
|
52758
53019
|
publicKey: "0x04ec0e3acc40884e3f366ca469d08899eb640ad5259fa196b0238075086208a9f8732a3175704f35f0bcc28e07406cfb24c254efd1e7355640577330f0d2dd755f",
|
|
52759
|
-
ethAddress: "
|
|
53020
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52760
53021
|
}
|
|
52761
53022
|
},
|
|
52762
53023
|
btcTransactionSigner: {
|
|
52763
|
-
cid: "
|
|
53024
|
+
cid: "QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U",
|
|
52764
53025
|
authorizedCidHex: cidToHex(
|
|
52765
|
-
"
|
|
53026
|
+
"QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U"
|
|
52766
53027
|
),
|
|
52767
53028
|
name: "Btc Transaction Signer",
|
|
52768
53029
|
description: "Production Btc Transaction Signer",
|
|
52769
53030
|
version: "1.1.1",
|
|
52770
53031
|
deployed: true,
|
|
52771
|
-
deployedAt:
|
|
52772
|
-
size:
|
|
52773
|
-
hash: "
|
|
53032
|
+
deployedAt: 1790246185256,
|
|
53033
|
+
size: 73313,
|
|
53034
|
+
hash: "d8b6bc646ba33fee7d46c8e9b281de776081ea6f182f56fd15d4c52aaf3dd030"
|
|
52774
53035
|
},
|
|
52775
53036
|
ucdMintValidator: {
|
|
52776
|
-
cid: "
|
|
53037
|
+
cid: "QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe",
|
|
52777
53038
|
authorizedCidHex: cidToHex(
|
|
52778
|
-
"
|
|
53039
|
+
"QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe"
|
|
52779
53040
|
),
|
|
52780
53041
|
name: "Ucd Mint Validator",
|
|
52781
53042
|
description: "Production Ucd Mint Validator",
|
|
52782
|
-
version: "1.
|
|
53043
|
+
version: "1.3.0",
|
|
52783
53044
|
deployed: true,
|
|
52784
|
-
deployedAt:
|
|
52785
|
-
size:
|
|
52786
|
-
hash: "
|
|
52787
|
-
validatorWalletAddress: "
|
|
53045
|
+
deployedAt: 1790246219868,
|
|
53046
|
+
size: 90022,
|
|
53047
|
+
hash: "65e8cb778c2b767ae6eb37cb5db7b4c5a3f2468d508463c847c83c1b6825fadd",
|
|
53048
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
52788
53049
|
pkp: {
|
|
52789
53050
|
publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
|
|
52790
|
-
ethAddress: "
|
|
53051
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52791
53052
|
}
|
|
52792
53053
|
},
|
|
52793
53054
|
processPaymentValidator: {
|
|
52794
|
-
cid: "
|
|
53055
|
+
cid: "QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8",
|
|
52795
53056
|
authorizedCidHex: cidToHex(
|
|
52796
|
-
"
|
|
53057
|
+
"QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8"
|
|
52797
53058
|
),
|
|
52798
53059
|
name: "Process Payment Validator",
|
|
52799
53060
|
description: "Production Process Payment Validator",
|
|
52800
53061
|
version: "1.2.1",
|
|
52801
53062
|
deployed: true,
|
|
52802
|
-
deployedAt:
|
|
52803
|
-
size:
|
|
52804
|
-
hash: "
|
|
52805
|
-
validatorWalletAddress: "
|
|
53063
|
+
deployedAt: 1790246225795,
|
|
53064
|
+
size: 85107,
|
|
53065
|
+
hash: "25ecf952c4c44c40b0920b92d57906e7010ed9a38e2ba41ccdee6d3377c2b596",
|
|
53066
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
52806
53067
|
pkp: {
|
|
52807
53068
|
publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
|
|
52808
|
-
ethAddress: "
|
|
53069
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52809
53070
|
}
|
|
52810
53071
|
},
|
|
52811
53072
|
extendPositionValidator: {
|
|
52812
|
-
cid: "
|
|
53073
|
+
cid: "QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX",
|
|
52813
53074
|
authorizedCidHex: cidToHex(
|
|
52814
|
-
"
|
|
53075
|
+
"QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX"
|
|
52815
53076
|
),
|
|
52816
53077
|
name: "Extend Position Validator",
|
|
52817
53078
|
description: "Production Extend Position Validator",
|
|
52818
53079
|
version: "1.2.1",
|
|
52819
53080
|
deployed: true,
|
|
52820
|
-
deployedAt:
|
|
52821
|
-
size:
|
|
52822
|
-
hash: "
|
|
52823
|
-
validatorWalletAddress: "
|
|
53081
|
+
deployedAt: 1790246231975,
|
|
53082
|
+
size: 82853,
|
|
53083
|
+
hash: "25d4887b7f646649db2bb7f2bfb77d039db83228a6c454377ca26c779b0903cc",
|
|
53084
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
52824
53085
|
pkp: {
|
|
52825
53086
|
publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
|
|
52826
|
-
ethAddress: "
|
|
53087
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52827
53088
|
}
|
|
52828
53089
|
},
|
|
52829
53090
|
btcWithdrawal: {
|
|
52830
|
-
cid: "
|
|
53091
|
+
cid: "QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP",
|
|
52831
53092
|
authorizedCidHex: cidToHex(
|
|
52832
|
-
"
|
|
53093
|
+
"QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP"
|
|
52833
53094
|
),
|
|
52834
53095
|
name: "Btc Withdrawal",
|
|
52835
53096
|
description: "Production Btc Withdrawal",
|
|
52836
53097
|
version: "1.2.7",
|
|
52837
53098
|
deployed: true,
|
|
52838
|
-
deployedAt:
|
|
52839
|
-
size:
|
|
52840
|
-
hash: "
|
|
52841
|
-
validatorWalletAddress: "
|
|
53099
|
+
deployedAt: 1790246239599,
|
|
53100
|
+
size: 101228,
|
|
53101
|
+
hash: "2ed25eca6cc80a43061b7ad119737af48158fdb61d59f10cd06cea51b607f112",
|
|
53102
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
52842
53103
|
pkp: {
|
|
52843
53104
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
52844
|
-
ethAddress: "
|
|
53105
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52845
53106
|
}
|
|
52846
53107
|
},
|
|
52847
53108
|
liquidationValidator: {
|
|
52848
|
-
cid: "
|
|
53109
|
+
cid: "QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb",
|
|
52849
53110
|
authorizedCidHex: cidToHex(
|
|
52850
|
-
"
|
|
53111
|
+
"QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb"
|
|
52851
53112
|
),
|
|
52852
53113
|
name: "Liquidation Validator",
|
|
52853
53114
|
description: "Production Liquidation Validator",
|
|
52854
53115
|
version: "1.2.1",
|
|
52855
53116
|
deployed: true,
|
|
52856
|
-
deployedAt:
|
|
52857
|
-
size:
|
|
52858
|
-
hash: "
|
|
52859
|
-
validatorWalletAddress: "
|
|
53117
|
+
deployedAt: 1790246247904,
|
|
53118
|
+
size: 70308,
|
|
53119
|
+
hash: "582ccf0ec7f715195e20fdc885996743cb42125b64173424e360ee63db62bbd8",
|
|
53120
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
52860
53121
|
pkp: {
|
|
52861
53122
|
publicKey: "0x041a241de58976c13e3d7ca5a18e494f7330151e3818706135d50176e78ffb673e58b11f0b67a87c73fade6c6b27d6e7a7377ea9f4c10bf31880f1d725f18cc6f8",
|
|
52862
|
-
ethAddress: "
|
|
53123
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52863
53124
|
}
|
|
52864
53125
|
},
|
|
52865
53126
|
priceOracle: {
|
|
@@ -52874,28 +53135,28 @@ var require_pkg_src2 = __commonJS2({
|
|
|
52874
53135
|
deployedAt: 1781116663270,
|
|
52875
53136
|
size: 8695,
|
|
52876
53137
|
hash: "ba20ade60a7fa5acd80dadfafa179c507388cfe6ce48a22a672d70b317ffcc74",
|
|
52877
|
-
validatorWalletAddress: "
|
|
53138
|
+
validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
|
|
52878
53139
|
pkp: {
|
|
52879
53140
|
publicKey: "0x043beaa1da47875601a8d6f430b1438ee2d4732eefd06e5c63a474bbdaf9e7df1797b1b951e041b627c2bf839788164825324c9cbd1e2d6f740fdd4bff69b1900b",
|
|
52880
|
-
ethAddress: "
|
|
53141
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52881
53142
|
}
|
|
52882
53143
|
},
|
|
52883
53144
|
loanVaultBtcBalance: {
|
|
52884
|
-
cid: "
|
|
53145
|
+
cid: "QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W",
|
|
52885
53146
|
authorizedCidHex: cidToHex(
|
|
52886
|
-
"
|
|
53147
|
+
"QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W"
|
|
52887
53148
|
),
|
|
52888
53149
|
name: "Loan Vault Btc Balance",
|
|
52889
53150
|
description: "Production Loan Vault Btc Balance",
|
|
52890
53151
|
version: "1.2.1",
|
|
52891
53152
|
deployed: true,
|
|
52892
|
-
deployedAt:
|
|
52893
|
-
size:
|
|
52894
|
-
hash: "
|
|
52895
|
-
validatorWalletAddress: "
|
|
53153
|
+
deployedAt: 1790179961079,
|
|
53154
|
+
size: 60046,
|
|
53155
|
+
hash: "922e86c0a667fe0c0945771f84aa6b9fe08be9c96dd2f73a9c5cb257d24e22b0",
|
|
53156
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
52896
53157
|
pkp: {
|
|
52897
53158
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
52898
|
-
ethAddress: "
|
|
53159
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52899
53160
|
}
|
|
52900
53161
|
},
|
|
52901
53162
|
// btc-address-balance (Option B) — address-only signed total balance via
|
|
@@ -52905,21 +53166,21 @@ var require_pkg_src2 = __commonJS2({
|
|
|
52905
53166
|
// Requires BitcoinProviderRegistry.addAllowedCid(chainId, keccak256(utf8(cid)))
|
|
52906
53167
|
// on each target chain (the action decrypts registry slots). No OAR entry.
|
|
52907
53168
|
btcAddressBalance: {
|
|
52908
|
-
cid: "
|
|
53169
|
+
cid: "QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN",
|
|
52909
53170
|
authorizedCidHex: cidToHex(
|
|
52910
|
-
"
|
|
53171
|
+
"QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN"
|
|
52911
53172
|
),
|
|
52912
53173
|
name: "Btc Address Balance",
|
|
52913
53174
|
description: "Address-only signed total BTC balance via registry consensus (no positionId, no price)",
|
|
52914
53175
|
version: "0.2.1",
|
|
52915
53176
|
deployed: true,
|
|
52916
|
-
deployedAt:
|
|
52917
|
-
size:
|
|
52918
|
-
hash: "
|
|
52919
|
-
validatorWalletAddress: "
|
|
53177
|
+
deployedAt: 1790179971315,
|
|
53178
|
+
size: 30295,
|
|
53179
|
+
hash: "2c67d9cfa4d50e835fbb28ae50e80217ceb2be3bb862c89290aadf43fdc739c9",
|
|
53180
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
52920
53181
|
pkp: {
|
|
52921
53182
|
publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
|
|
52922
|
-
ethAddress: "
|
|
53183
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52923
53184
|
}
|
|
52924
53185
|
},
|
|
52925
53186
|
alwaysSigner: {
|
|
@@ -52949,48 +53210,74 @@ var require_pkg_src2 = __commonJS2({
|
|
|
52949
53210
|
hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
|
|
52950
53211
|
},
|
|
52951
53212
|
agentModuleExecutor: {
|
|
52952
|
-
cid: "
|
|
53213
|
+
cid: "QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX",
|
|
52953
53214
|
authorizedCidHex: cidToHex(
|
|
52954
|
-
"
|
|
53215
|
+
"QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX"
|
|
52955
53216
|
),
|
|
52956
53217
|
name: "Agent Module Executor",
|
|
52957
53218
|
description: "Production Agent Module Executor",
|
|
52958
53219
|
version: "1.1.1",
|
|
52959
53220
|
deployed: true,
|
|
52960
|
-
deployedAt:
|
|
52961
|
-
size:
|
|
52962
|
-
hash: "
|
|
53221
|
+
deployedAt: 1790179978959,
|
|
53222
|
+
size: 14688,
|
|
53223
|
+
hash: "8edb9b12c784c8d7d153cce97235584c24665a788767ae68713dce91109ab35e"
|
|
52963
53224
|
},
|
|
52964
53225
|
staleSpendRecoveryValidator: {
|
|
52965
|
-
cid: "
|
|
53226
|
+
cid: "Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz",
|
|
52966
53227
|
authorizedCidHex: cidToHex(
|
|
52967
|
-
"
|
|
53228
|
+
"Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz"
|
|
52968
53229
|
),
|
|
52969
53230
|
name: "Stale Spend Recovery Validator",
|
|
52970
53231
|
description: "Production Stale Spend Recovery Validator",
|
|
52971
53232
|
version: "1.1.2",
|
|
52972
53233
|
deployed: true,
|
|
52973
|
-
deployedAt:
|
|
52974
|
-
size:
|
|
52975
|
-
hash: "
|
|
52976
|
-
validatorWalletAddress: "
|
|
53234
|
+
deployedAt: 1790246256280,
|
|
53235
|
+
size: 48143,
|
|
53236
|
+
hash: "ec9236bcbe0af24d3e1844791fc8fe37371bbecd8ce95d02e13f7c6e1fc7d94c",
|
|
53237
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
52977
53238
|
pkp: {
|
|
52978
53239
|
publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
|
|
52979
|
-
ethAddress: "
|
|
53240
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52980
53241
|
}
|
|
52981
53242
|
},
|
|
52982
53243
|
btcUtxoInvalidator: {
|
|
52983
|
-
cid: "
|
|
53244
|
+
cid: "QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX",
|
|
52984
53245
|
authorizedCidHex: cidToHex(
|
|
52985
|
-
"
|
|
53246
|
+
"QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX"
|
|
52986
53247
|
),
|
|
52987
53248
|
name: "Btc Utxo Invalidator",
|
|
52988
53249
|
description: "Production Btc Utxo Invalidator",
|
|
52989
53250
|
version: "1.0.0",
|
|
52990
53251
|
deployed: true,
|
|
52991
|
-
deployedAt:
|
|
52992
|
-
size:
|
|
52993
|
-
hash: "
|
|
53252
|
+
deployedAt: 1790246264563,
|
|
53253
|
+
size: 69219,
|
|
53254
|
+
hash: "bda048d8cd6b5a39c2774bcf1320e82d1eea935c2a521006fb8b887e13b6dd8d"
|
|
53255
|
+
},
|
|
53256
|
+
carryCollateralAttestation: {
|
|
53257
|
+
cid: "QmYWULmXD9S5AmTdQqWqoZ28ctsZQNcXkAgre9G2Xo9dh8",
|
|
53258
|
+
authorizedCidHex: cidToHex(
|
|
53259
|
+
"QmYWULmXD9S5AmTdQqWqoZ28ctsZQNcXkAgre9G2Xo9dh8"
|
|
53260
|
+
),
|
|
53261
|
+
name: "Carry Collateral Attestation",
|
|
53262
|
+
description: "LoanCarryVault collateral attestation (borrower, BTC vault, confirmed BTC)",
|
|
53263
|
+
version: "1.0.0",
|
|
53264
|
+
deployed: true,
|
|
53265
|
+
deployedAt: 1790927734070,
|
|
53266
|
+
size: 21156,
|
|
53267
|
+
hash: "05b177e0bb36b0483db4a42d33c1bbbf47eb9ef34ae278459397d51a7f8957ff"
|
|
53268
|
+
},
|
|
53269
|
+
carryFundingAttestation: {
|
|
53270
|
+
cid: "QmWhox3xUZMNR5NpPZ9WLSPC5GoW4ms88GanVRKr8uuS3W",
|
|
53271
|
+
authorizedCidHex: cidToHex(
|
|
53272
|
+
"QmWhox3xUZMNR5NpPZ9WLSPC5GoW4ms88GanVRKr8uuS3W"
|
|
53273
|
+
),
|
|
53274
|
+
name: "Carry Funding Attestation",
|
|
53275
|
+
description: "LoanCarryVault funding attestation (Hyperliquid BTC windowed hourly average)",
|
|
53276
|
+
version: "1.0.0",
|
|
53277
|
+
deployed: true,
|
|
53278
|
+
deployedAt: 1790925699980,
|
|
53279
|
+
size: 7193,
|
|
53280
|
+
hash: "4944ada61610cf64b32e33b5be62087088dcf5e821040c69e67942e643ce74c9"
|
|
52994
53281
|
}
|
|
52995
53282
|
};
|
|
52996
53283
|
function getDeploymentsForNetwork(network) {
|
|
@@ -53758,7 +54045,10 @@ ${errorReport}`);
|
|
|
53758
54045
|
BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
|
|
53759
54046
|
BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
|
|
53760
54047
|
LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
|
|
53761
|
-
PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
|
|
54048
|
+
PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C",
|
|
54049
|
+
TermManagerModule: "0xDB99CdF883ffa38acD099bC39F8d1f4508c9239E",
|
|
54050
|
+
UCDController: "0x4b4f8063048bCD59D469219E3f07C6aaDF4f6157",
|
|
54051
|
+
LiquidationManagerModule: "0x74B28695352E7bf736D6c9F76ccb7B4439477De9"
|
|
53762
54052
|
},
|
|
53763
54053
|
11155111: {
|
|
53764
54054
|
PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
|
|
@@ -53766,7 +54056,10 @@ ${errorReport}`);
|
|
|
53766
54056
|
BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
|
|
53767
54057
|
BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
|
|
53768
54058
|
LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
|
|
53769
|
-
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
|
|
54059
|
+
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
54060
|
+
TermManagerModule: "0x94Adc6F9558368B1482197584f1fc7133Ecf835b",
|
|
54061
|
+
UCDController: "0x360Bde4e489ee94E26601B206932De09EE60FF04",
|
|
54062
|
+
LiquidationManagerModule: "0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76"
|
|
53770
54063
|
}
|
|
53771
54064
|
};
|
|
53772
54065
|
function getPinnedContractAddresses(chainId) {
|
|
@@ -53952,10 +54245,10 @@ ${errorReport}`);
|
|
|
53952
54245
|
};
|
|
53953
54246
|
}
|
|
53954
54247
|
const ratioBigInt = collateralValueUsd * UCD_TOKEN_DECIMALS * 10000n / ucdDebt;
|
|
53955
|
-
const
|
|
54248
|
+
const collateralRatioBps2 = Number(ratioBigInt);
|
|
53956
54249
|
return {
|
|
53957
54250
|
collateralValueUsd,
|
|
53958
|
-
collateralRatioBps
|
|
54251
|
+
collateralRatioBps: collateralRatioBps2
|
|
53959
54252
|
};
|
|
53960
54253
|
}
|
|
53961
54254
|
function hasSufficientCollateralForDebt(collateralValueUsd, currentDebt, additionalDebt, requiredRatioBps) {
|
|
@@ -54809,6 +55102,17 @@ ${auth.clientId}`;
|
|
|
54809
55102
|
);
|
|
54810
55103
|
}
|
|
54811
55104
|
}
|
|
55105
|
+
var TIP_READ_FAILURE_PREFIX = "Bitcoin tip-height read failed";
|
|
55106
|
+
var BitcoinTipUnreadableError = class extends Error {
|
|
55107
|
+
constructor(message) {
|
|
55108
|
+
super(message);
|
|
55109
|
+
this.isBitcoinTipUnreadable = true;
|
|
55110
|
+
this.name = "BitcoinTipUnreadableError";
|
|
55111
|
+
}
|
|
55112
|
+
};
|
|
55113
|
+
function isBitcoinTipUnreadableError(error) {
|
|
55114
|
+
return typeof error === "object" && error !== null && error.isBitcoinTipUnreadable === true;
|
|
55115
|
+
}
|
|
54812
55116
|
var BitcoinDataProvider = class {
|
|
54813
55117
|
constructor(config) {
|
|
54814
55118
|
this.config = config;
|
|
@@ -55260,27 +55564,12 @@ ${auth.clientId}`;
|
|
|
55260
55564
|
if (!data.status.confirmed || !data.status.block_height) {
|
|
55261
55565
|
return { txid: data.txid ?? txid, confirmations: 0 };
|
|
55262
55566
|
}
|
|
55263
|
-
|
|
55264
|
-
|
|
55265
|
-
|
|
55266
|
-
|
|
55267
|
-
|
|
55268
|
-
|
|
55269
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
55270
|
-
}
|
|
55271
|
-
const tipBody = (await tipResp.text()).trim();
|
|
55272
|
-
const tipHeight = Number.parseInt(tipBody, 10);
|
|
55273
|
-
if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
|
|
55274
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
55275
|
-
}
|
|
55276
|
-
const depth = tipHeight - data.status.block_height + 1;
|
|
55277
|
-
return {
|
|
55278
|
-
txid: data.txid ?? txid,
|
|
55279
|
-
confirmations: depth > 0 ? depth : 0
|
|
55280
|
-
};
|
|
55281
|
-
} catch {
|
|
55282
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
55283
|
-
}
|
|
55567
|
+
const tipHeight = await this.fetchTipHeight(controller.signal);
|
|
55568
|
+
const depth = tipHeight - data.status.block_height + 1;
|
|
55569
|
+
return {
|
|
55570
|
+
txid: data.txid ?? txid,
|
|
55571
|
+
confirmations: depth > 0 ? depth : 0
|
|
55572
|
+
};
|
|
55284
55573
|
}
|
|
55285
55574
|
return null;
|
|
55286
55575
|
} catch (error) {
|
|
@@ -55288,12 +55577,55 @@ ${auth.clientId}`;
|
|
|
55288
55577
|
if (isAbortError(error)) {
|
|
55289
55578
|
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
55290
55579
|
}
|
|
55580
|
+
if (isBitcoinTipUnreadableError(error)) {
|
|
55581
|
+
throw error;
|
|
55582
|
+
}
|
|
55291
55583
|
if (getUnknownErrorMessage(error).includes("404")) {
|
|
55292
55584
|
return null;
|
|
55293
55585
|
}
|
|
55294
55586
|
throw error;
|
|
55295
55587
|
}
|
|
55296
55588
|
}
|
|
55589
|
+
/**
|
|
55590
|
+
* Current chain tip height from THIS provider — or throw.
|
|
55591
|
+
*
|
|
55592
|
+
* Every exit is a throw naming the provider and the precise failure, because
|
|
55593
|
+
* the only alternative is inventing a confirmation depth (see the call site).
|
|
55594
|
+
* The single `try` exists solely to attach that name to a transport-level
|
|
55595
|
+
* rejection (DNS, TLS, connection reset, abort); it re-throws the cause
|
|
55596
|
+
* verbatim inside the message and never substitutes a value — authorized for
|
|
55597
|
+
* this case by the Batch 2 plan, §C2.
|
|
55598
|
+
*
|
|
55599
|
+
* @param signal - The caller's AbortSignal, so this read shares the same
|
|
55600
|
+
* timeout budget as the transaction fetch it serves.
|
|
55601
|
+
*/
|
|
55602
|
+
async fetchTipHeight(signal) {
|
|
55603
|
+
const endpoint = `${this.config.providerUrl}/blocks/tip/height`;
|
|
55604
|
+
let tipResp;
|
|
55605
|
+
try {
|
|
55606
|
+
tipResp = await fetch(endpoint, {
|
|
55607
|
+
signal,
|
|
55608
|
+
headers: await this.withAuth()
|
|
55609
|
+
});
|
|
55610
|
+
} catch (error) {
|
|
55611
|
+
throw new BitcoinTipUnreadableError(
|
|
55612
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} threw \u2014 ${getUnknownErrorMessage(error)}`
|
|
55613
|
+
);
|
|
55614
|
+
}
|
|
55615
|
+
if (!tipResp.ok) {
|
|
55616
|
+
throw new BitcoinTipUnreadableError(
|
|
55617
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} \u2192 ${tipResp.status} ${tipResp.statusText}`
|
|
55618
|
+
);
|
|
55619
|
+
}
|
|
55620
|
+
const tipBody = (await tipResp.text()).trim();
|
|
55621
|
+
const tipHeight = Number.parseInt(tipBody, 10);
|
|
55622
|
+
if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
|
|
55623
|
+
throw new BitcoinTipUnreadableError(
|
|
55624
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} returned an unusable tip height "${tipBody.slice(0, 64)}"`
|
|
55625
|
+
);
|
|
55626
|
+
}
|
|
55627
|
+
return tipHeight;
|
|
55628
|
+
}
|
|
55297
55629
|
/**
|
|
55298
55630
|
* Get outputs (vouts) of a Bitcoin transaction
|
|
55299
55631
|
*
|
|
@@ -55931,10 +56263,13 @@ ${auth.clientId}`;
|
|
|
55931
56263
|
* only on unanimity. The confirmed-balance consensus the validators run
|
|
55932
56264
|
* covers `chain_stats` only, so without this the primary provider alone
|
|
55933
56265
|
* could fabricate an unconfirmed UTXO plus a self-consistent parent proof
|
|
55934
|
-
* and inflate the signed balance. Any
|
|
55935
|
-
*
|
|
55936
|
-
*
|
|
55937
|
-
*
|
|
56266
|
+
* and inflate the signed balance. Any verdict disagreement THROWS
|
|
56267
|
+
* (fail-closed) — exclusion on a suppressed proof would deflate the balance
|
|
56268
|
+
* and open a wrongful-liquidation window, so neither direction may proceed
|
|
56269
|
+
* without agreement. A provider that cannot state the chain tip — and only
|
|
56270
|
+
* that failure — is dropped from the quorum rather than aborting the read (it
|
|
56271
|
+
* never counts as agreeing), and falling below `minConsensusProviders`
|
|
56272
|
+
* survivors throws — see `verifyParentIsSelfSpendConsensus`.
|
|
55938
56273
|
*
|
|
55939
56274
|
* The same per-provider `/tx` fetch also returns the parent's outputs, and
|
|
55940
56275
|
* every provider must corroborate each claimed UTXO (index, vault address,
|
|
@@ -56029,10 +56364,26 @@ ${auth.clientId}`;
|
|
|
56029
56364
|
}
|
|
56030
56365
|
/**
|
|
56031
56366
|
* Run the self-spend proof against every configured provider and require
|
|
56032
|
-
* unanimity
|
|
56033
|
-
*
|
|
56367
|
+
* unanimity AMONG THE PROVIDERS THAT ANSWERED. Fail-closed on disagreement:
|
|
56368
|
+
* a verdict mismatch throws and aborts the balance calculation — see
|
|
56034
56369
|
* classifySelfChange for why exclusion is not a safe fallback here.
|
|
56035
56370
|
*
|
|
56371
|
+
* Quorum semantics (2026-09-23, plan C2). ONE failure class is tolerated: a
|
|
56372
|
+
* provider that could not state the chain tip (`BitcoinTipUnreadableError`).
|
|
56373
|
+
* It is ABSENT from the quorum — never counted as agreeing, never allowed to
|
|
56374
|
+
* decide the verdict — and the policy floor, not "at least one", decides when
|
|
56375
|
+
* that absence is fatal: below `minConsensusProviders` surviving readings
|
|
56376
|
+
* there is no cross-check left to trust, and the read fails loudly naming
|
|
56377
|
+
* every provider that dropped out.
|
|
56378
|
+
*
|
|
56379
|
+
* Why only that class. `getTransaction` now throws on an unreadable tip
|
|
56380
|
+
* instead of fabricating `confirmations: 1`; without this carve-out one flaky
|
|
56381
|
+
* `/blocks/tip/height` endpoint would take every balance and spend path down
|
|
56382
|
+
* with it. Every OTHER failure remains fatal, as before: a provider that
|
|
56383
|
+
* answers "I have never seen that transaction" is making a claim about the
|
|
56384
|
+
* chain rather than suffering an outage, and that shape is precisely the
|
|
56385
|
+
* fabricated-UTXO signature the fail-closed rule exists to catch.
|
|
56386
|
+
*
|
|
56036
56387
|
* When the parent IS a unanimous self-spend, every provider's view of the
|
|
56037
56388
|
* parent's OUTPUTS must additionally corroborate the primary's claimed
|
|
56038
56389
|
* UTXOs (index exists, pays the vault, exact value). Without this, a
|
|
@@ -56057,32 +56408,52 @@ ${auth.clientId}`;
|
|
|
56057
56408
|
)
|
|
56058
56409
|
)
|
|
56059
56410
|
);
|
|
56060
|
-
const
|
|
56061
|
-
|
|
56062
|
-
|
|
56063
|
-
|
|
56064
|
-
|
|
56411
|
+
const answered = [];
|
|
56412
|
+
const absences = [];
|
|
56413
|
+
const failures = [];
|
|
56414
|
+
settled.forEach((result, i) => {
|
|
56415
|
+
if (result.status === "fulfilled") {
|
|
56416
|
+
answered.push({ index: i, evaluation: result.value });
|
|
56417
|
+
return;
|
|
56418
|
+
}
|
|
56419
|
+
const described = `${providerName(i)} \u2192 ${result.reason?.message ?? String(result.reason)}`;
|
|
56420
|
+
if (isBitcoinTipUnreadableError(result.reason)) {
|
|
56421
|
+
absences.push(described);
|
|
56422
|
+
return;
|
|
56423
|
+
}
|
|
56424
|
+
failures.push(described);
|
|
56425
|
+
});
|
|
56065
56426
|
if (failures.length > 0) {
|
|
56066
56427
|
throw new Error(
|
|
56067
56428
|
`Self-change classification failed for tx ${parentTxid} on ${failures.length}/${providerConfigs.length} provider(s): ${failures.join("; ")}`
|
|
56068
56429
|
);
|
|
56069
56430
|
}
|
|
56070
|
-
const
|
|
56071
|
-
|
|
56072
|
-
|
|
56073
|
-
|
|
56074
|
-
|
|
56075
|
-
|
|
56431
|
+
const floor = Math.max(1, this.minConsensusProviders);
|
|
56432
|
+
if (answered.length < floor) {
|
|
56433
|
+
throw new Error(
|
|
56434
|
+
`Self-change classification for tx ${parentTxid}: only ${answered.length}/${providerConfigs.length} provider(s) could state a confirmation depth, below this chain's floor of ${floor}. Unreadable tips: ${absences.join("; ")}`
|
|
56435
|
+
);
|
|
56436
|
+
}
|
|
56437
|
+
if (absences.length > 0) {
|
|
56438
|
+
litDebugLog(
|
|
56439
|
+
`[VaultBalance] self-change: tx ${parentTxid} classified on a reduced quorum \u2014 ${answered.length}/${providerConfigs.length} provider(s) answered (floor ${floor}); dropped for an unreadable chain tip: ${absences.join("; ")}`
|
|
56440
|
+
);
|
|
56441
|
+
}
|
|
56442
|
+
const first = answered[0];
|
|
56443
|
+
const disagreements = answered.slice(1).filter((a) => a.evaluation.selfSpend !== first.evaluation.selfSpend).map(
|
|
56444
|
+
(a) => `${providerName(first.index)}=${first.evaluation.selfSpend} vs ${providerName(a.index)}=${a.evaluation.selfSpend}`
|
|
56076
56445
|
);
|
|
56077
56446
|
if (disagreements.length > 0) {
|
|
56078
56447
|
throw new Error(
|
|
56079
56448
|
`Self-change consensus mismatch for tx ${parentTxid}: ${disagreements.join("; ")}. A provider may be compromised or out of sync; refusing to sign.`
|
|
56080
56449
|
);
|
|
56081
56450
|
}
|
|
56082
|
-
if (!
|
|
56451
|
+
if (!first.evaluation.selfSpend) {
|
|
56083
56452
|
return false;
|
|
56084
56453
|
}
|
|
56085
|
-
const outputMismatches =
|
|
56454
|
+
const outputMismatches = answered.map(
|
|
56455
|
+
(a) => a.evaluation.outputMismatch ? `${providerName(a.index)} \u2192 ${a.evaluation.outputMismatch}` : null
|
|
56456
|
+
).filter((m) => m !== null);
|
|
56086
56457
|
if (outputMismatches.length > 0) {
|
|
56087
56458
|
throw new Error(
|
|
56088
56459
|
`Self-change output claim mismatch for tx ${parentTxid}: ${outputMismatches.join("; ")}. The reported UTXO set contradicts the parent transaction; refusing to sign.`
|
|
@@ -56325,16 +56696,6 @@ ${auth.clientId}`;
|
|
|
56325
56696
|
minConfirmations
|
|
56326
56697
|
);
|
|
56327
56698
|
const authorizedSpends = await this.getAuthorizedSpendsFromContract(positionId);
|
|
56328
|
-
for (const spend of authorizedSpends) {
|
|
56329
|
-
const utxoStillExists = utxoSet.utxos.some(
|
|
56330
|
-
(utxo) => utxo.txid === spend.txid && utxo.vout === spend.vout
|
|
56331
|
-
);
|
|
56332
|
-
if (utxoStillExists) {
|
|
56333
|
-
throw new Error(
|
|
56334
|
-
`Authorized UTXO ${spend.txid}:${spend.vout} not yet spent. Transaction was authorized in smart contract but not signed and broadcasted to Bitcoin network. Complete the transaction by signing and broadcasting it.`
|
|
56335
|
-
);
|
|
56336
|
-
}
|
|
56337
|
-
}
|
|
56338
56699
|
const authorizedBalance = authorizedSpends.reduce(
|
|
56339
56700
|
(sum, spend) => sum + spend.satoshis,
|
|
56340
56701
|
0n
|
|
@@ -56630,7 +56991,13 @@ ${auth.clientId}`;
|
|
|
56630
56991
|
allowDevSinglePriceProvider: false,
|
|
56631
56992
|
minBitcoinBalanceConfirmations: 1,
|
|
56632
56993
|
minBitcoinSpendConfirmations: 1,
|
|
56633
|
-
|
|
56994
|
+
// 2 since 2026-09-23. It was 1 because Sepolia ran a single faucet provider
|
|
56995
|
+
// "by design", so the consensus floor was documented as a mainnet-only
|
|
56996
|
+
// guarantee. The registry now holds two, and leaving the floor at 1 meant
|
|
56997
|
+
// Sepolia could never exercise the multi-provider agreement the stale-spend
|
|
56998
|
+
// and balance paths rely on — the one environment where that logic is
|
|
56999
|
+
// supposed to be proved before mainnet.
|
|
57000
|
+
minConsensusProviders: 2
|
|
56634
57001
|
},
|
|
56635
57002
|
[
|
|
56636
57003
|
"ethereum"
|
|
@@ -56939,7 +57306,6 @@ function getSepoliaConfig() {
|
|
|
56939
57306
|
feeRecipientRegistry: SEPOLIA_CONTRACTS.FeeRecipientRegistry || "",
|
|
56940
57307
|
positionDelegateRegistry: SEPOLIA_CONTRACTS.PositionDelegateRegistry || "",
|
|
56941
57308
|
bitcoinWithdrawalAddressRegistry: SEPOLIA_CONTRACTS.BitcoinWithdrawalAddressRegistry || "",
|
|
56942
|
-
carryAgentRegistry: SEPOLIA_CONTRACTS.CarryAgentRegistry || "",
|
|
56943
57309
|
agentDelegationRegistry: SEPOLIA_CONTRACTS.AgentDelegationRegistry || "",
|
|
56944
57310
|
dhAgentDelegate: SEPOLIA_CONTRACTS.DHAgentDelegate || "",
|
|
56945
57311
|
agentModuleFactory: SEPOLIA_CONTRACTS.AgentModuleFactory || ""
|
|
@@ -56993,7 +57359,6 @@ function getMainnetConfig() {
|
|
|
56993
57359
|
feeRecipientRegistry: MAINNET_CONTRACTS.FeeRecipientRegistry || "",
|
|
56994
57360
|
positionDelegateRegistry: MAINNET_CONTRACTS.PositionDelegateRegistry || "",
|
|
56995
57361
|
bitcoinWithdrawalAddressRegistry: MAINNET_CONTRACTS.BitcoinWithdrawalAddressRegistry || "",
|
|
56996
|
-
carryAgentRegistry: MAINNET_CONTRACTS.CarryAgentRegistry || "",
|
|
56997
57362
|
agentDelegationRegistry: MAINNET_CONTRACTS.AgentDelegationRegistry || "",
|
|
56998
57363
|
dhAgentDelegate: MAINNET_CONTRACTS.DHAgentDelegate || "",
|
|
56999
57364
|
// Empty on mainnet until the factory is deployed there — the ceremony is Sepolia-only.
|
|
@@ -58066,6 +58431,51 @@ async function resolveAuthorizationInput(provider, signer, ctx) {
|
|
|
58066
58431
|
}
|
|
58067
58432
|
return { timestamp: result.timestamp, signature: result.signature };
|
|
58068
58433
|
}
|
|
58434
|
+
var BECH32_CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|
|
58435
|
+
function segwitProgramShape(address) {
|
|
58436
|
+
const lower2 = address.trim().toLowerCase();
|
|
58437
|
+
if (!/^(bc1|tb1|bcrt1)/.test(lower2))
|
|
58438
|
+
return null;
|
|
58439
|
+
const sep = lower2.lastIndexOf("1");
|
|
58440
|
+
const data = lower2.slice(sep + 1);
|
|
58441
|
+
if (data.length < 8)
|
|
58442
|
+
return null;
|
|
58443
|
+
const version2 = BECH32_CHARSET.indexOf(data[0]);
|
|
58444
|
+
if (version2 < 0)
|
|
58445
|
+
return null;
|
|
58446
|
+
const programChars = data.length - 1 - 6;
|
|
58447
|
+
return { version: version2, programBytes: Math.floor(programChars * 5 / 8) };
|
|
58448
|
+
}
|
|
58449
|
+
function dustLimitForAddress(address) {
|
|
58450
|
+
const shape = segwitProgramShape(address);
|
|
58451
|
+
if (shape === null)
|
|
58452
|
+
return 546;
|
|
58453
|
+
if (shape.version === 0 && shape.programBytes === 20)
|
|
58454
|
+
return 294;
|
|
58455
|
+
if (shape.version === 0 && shape.programBytes === 32)
|
|
58456
|
+
return 330;
|
|
58457
|
+
if (shape.version === 1 && shape.programBytes === 32)
|
|
58458
|
+
return 330;
|
|
58459
|
+
return 546;
|
|
58460
|
+
}
|
|
58461
|
+
function destinationDustShortfall(targetAmount, networkFee, destination) {
|
|
58462
|
+
const limit = dustLimitForAddress(destination);
|
|
58463
|
+
return targetAmount - networkFee < limit ? limit : null;
|
|
58464
|
+
}
|
|
58465
|
+
function calculateMintFee(params) {
|
|
58466
|
+
const { mintAmount, mintTimestamp, originationFeeBps, previousExpiryAt, selectedTerm, totalTerm } = params;
|
|
58467
|
+
let mintFee = mintAmount * BigInt(originationFeeBps) / 10000n;
|
|
58468
|
+
if (previousExpiryAt > 0 && mintTimestamp < previousExpiryAt) {
|
|
58469
|
+
const tailSeconds = BigInt(previousExpiryAt) - BigInt(mintTimestamp);
|
|
58470
|
+
const originalTermMonths = totalTerm - selectedTerm;
|
|
58471
|
+
const originalTermSeconds = BigInt(
|
|
58472
|
+
originalTermMonths === 12 ? 365 * 86400 : originalTermMonths * 30 * 86400
|
|
58473
|
+
);
|
|
58474
|
+
const tailFee = tailSeconds * BigInt(originationFeeBps) * mintAmount / (10000n * originalTermSeconds);
|
|
58475
|
+
mintFee = mintFee + tailFee;
|
|
58476
|
+
}
|
|
58477
|
+
return mintFee;
|
|
58478
|
+
}
|
|
58069
58479
|
function baseMintFeeWei(mintAmountWei, originationFeeBps) {
|
|
58070
58480
|
if (mintAmountWei < 0n)
|
|
58071
58481
|
throw new Error("baseMintFeeWei: mintAmountWei cannot be negative");
|
|
@@ -58084,20 +58494,34 @@ function debtAfterMintExceedsLoanCap(params) {
|
|
|
58084
58494
|
}
|
|
58085
58495
|
return currentDebtWei + mintAmountWei + mintFeeWei > maxLoanWei;
|
|
58086
58496
|
}
|
|
58087
|
-
function
|
|
58088
|
-
|
|
58089
|
-
|
|
58090
|
-
throw new Error("maxPrincipalWithinLoanCap: amounts cannot be negative");
|
|
58497
|
+
function collateralRatioBps(sats, price8, debtWei) {
|
|
58498
|
+
if (sats < 0n || price8 < 0n) {
|
|
58499
|
+
throw new Error("collateralRatioBps: sats and price cannot be negative");
|
|
58091
58500
|
}
|
|
58092
|
-
if (
|
|
58093
|
-
throw new Error(
|
|
58094
|
-
`maxPrincipalWithinLoanCap: originationFeeBps must be an integer in [0, 10000] (got ${String(originationFeeBps)})`
|
|
58095
|
-
);
|
|
58501
|
+
if (debtWei <= 0n) {
|
|
58502
|
+
throw new Error("collateralRatioBps: debt must be positive");
|
|
58096
58503
|
}
|
|
58097
|
-
|
|
58098
|
-
|
|
58099
|
-
|
|
58100
|
-
|
|
58504
|
+
return sats * price8 * 100n * 10000n / debtWei;
|
|
58505
|
+
}
|
|
58506
|
+
function collateralRatioPercentString(sats, price8, debtWei) {
|
|
58507
|
+
const bps = collateralRatioBps(sats, price8, debtWei);
|
|
58508
|
+
return `${bps / 100n}.${(bps % 100n).toString().padStart(2, "0")}`;
|
|
58509
|
+
}
|
|
58510
|
+
function maxPrincipalForFee(room, fee) {
|
|
58511
|
+
if (room < 0n)
|
|
58512
|
+
throw new Error("maxPrincipalForFee: room cannot be negative");
|
|
58513
|
+
if (fee(0n) !== 0n)
|
|
58514
|
+
throw new Error("maxPrincipalForFee: fee(0) must be 0");
|
|
58515
|
+
let lo = 0n;
|
|
58516
|
+
let hi = room;
|
|
58517
|
+
while (lo < hi) {
|
|
58518
|
+
const mid = (lo + hi + 1n) / 2n;
|
|
58519
|
+
if (mid + fee(mid) <= room)
|
|
58520
|
+
lo = mid;
|
|
58521
|
+
else
|
|
58522
|
+
hi = mid - 1n;
|
|
58523
|
+
}
|
|
58524
|
+
return lo;
|
|
58101
58525
|
}
|
|
58102
58526
|
function buildLoginDomain(chainId) {
|
|
58103
58527
|
return {
|
|
@@ -70260,9 +70684,17 @@ async function mintAgentPkp(params) {
|
|
|
70260
70684
|
}
|
|
70261
70685
|
var AGENT_STATUS = { None: 0, Active: 1, Revoked: 2 };
|
|
70262
70686
|
function planAgentBinding(params) {
|
|
70263
|
-
const { isActive, record, nowSeconds } = params;
|
|
70687
|
+
const { isActive, paused, record, nowSeconds } = params;
|
|
70688
|
+
if (typeof paused !== "boolean") {
|
|
70689
|
+
throw new Error("planAgentBinding: `paused` must be read from the registry (boolean required)");
|
|
70690
|
+
}
|
|
70264
70691
|
if (isActive)
|
|
70265
70692
|
return { kind: "reuse", agent: record.agent };
|
|
70693
|
+
if (paused) {
|
|
70694
|
+
throw new Error(
|
|
70695
|
+
"AgentDelegationRegistry is paused \u2014 agent delegation cannot be changed until it is unpaused."
|
|
70696
|
+
);
|
|
70697
|
+
}
|
|
70266
70698
|
const status = Number(record.status);
|
|
70267
70699
|
if (status === AGENT_STATUS.None || status === AGENT_STATUS.Revoked) {
|
|
70268
70700
|
return { kind: "register" };
|
|
@@ -70272,7 +70704,7 @@ function planAgentBinding(params) {
|
|
|
70272
70704
|
}
|
|
70273
70705
|
if (Number(record.validUntil) > nowSeconds) {
|
|
70274
70706
|
throw new Error(
|
|
70275
|
-
"AgentDelegationRegistry
|
|
70707
|
+
"AgentDelegationRegistry returned an inconsistent read (an unexpired, unpaused Active agent reported inactive); retry."
|
|
70276
70708
|
);
|
|
70277
70709
|
}
|
|
70278
70710
|
return { kind: "rotate" };
|
|
@@ -71441,7 +71873,7 @@ function normalizeBigNumberish(value) {
|
|
|
71441
71873
|
}
|
|
71442
71874
|
return value;
|
|
71443
71875
|
}
|
|
71444
|
-
if (typeof value === "object" && value !== null && "toString" in value && typeof value.toString === "function") {
|
|
71876
|
+
if (typeof value === "object" && value !== null && "toString" in value && typeof value.toString === "function" && value.toString !== Object.prototype.toString) {
|
|
71445
71877
|
const result = value.toString();
|
|
71446
71878
|
if (typeof result === "object" && result !== null && "_hex" in result) {
|
|
71447
71879
|
const resultObj = result;
|
|
@@ -72863,12 +73295,21 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
72863
73295
|
maxLoanWei: maxLoanValueWei
|
|
72864
73296
|
})) {
|
|
72865
73297
|
const debtAfterWei = currentDebtWei + requestAmountWei + baseFeeWei;
|
|
73298
|
+
const suggestionStamp = calculateNextQuantumTimestamp();
|
|
73299
|
+
const room = maxLoanValueWei > currentDebtWei ? maxLoanValueWei - currentDebtWei : 0n;
|
|
72866
73300
|
const maxPrincipalUcd = Number(
|
|
72867
|
-
|
|
72868
|
-
|
|
72869
|
-
|
|
72870
|
-
|
|
72871
|
-
|
|
73301
|
+
maxPrincipalForFee(
|
|
73302
|
+
room,
|
|
73303
|
+
(principal) => calculateMintFee({
|
|
73304
|
+
mintAmount: principal,
|
|
73305
|
+
mintTimestamp: suggestionStamp,
|
|
73306
|
+
originationFeeBps: positionTerm.originationFeeBps,
|
|
73307
|
+
expiryAt: Number(position2.expiryAt),
|
|
73308
|
+
previousExpiryAt: Number(position2.previousExpiryAt),
|
|
73309
|
+
selectedTerm: Number(position2.selectedTerm),
|
|
73310
|
+
totalTerm: Number(position2.totalTerm)
|
|
73311
|
+
})
|
|
73312
|
+
) / BigInt(10 ** 18)
|
|
72872
73313
|
);
|
|
72873
73314
|
return {
|
|
72874
73315
|
success: false,
|
|
@@ -73946,11 +74387,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
73946
74387
|
const debt = positionDetails.debt || positionDetails.ucdDebt || "0";
|
|
73947
74388
|
const btcPrice2 = litActionResult.btcPrice || "0";
|
|
73948
74389
|
const btcVaultBalance = litActionResult.btcAmountSats || positionDetails.btcVaultBalance || "0";
|
|
73949
|
-
const
|
|
73950
|
-
const btcAmount = Number(btcVaultBalance) / 1e8;
|
|
73951
|
-
const btcValueUSD = btcAmount * usdPricePerBTC;
|
|
73952
|
-
const debtUSD = Number(debt) / 1e18;
|
|
73953
|
-
const ratio = debtUSD > 0 ? (btcValueUSD / debtUSD * 100).toFixed(2) : "0.00";
|
|
74390
|
+
const ratio = BigInt(debt) > 0n ? collateralRatioPercentString(BigInt(btcVaultBalance), BigInt(btcPrice2), BigInt(debt)) : "0.00";
|
|
73954
74391
|
const message = formatLiquidationSkippedMessage(
|
|
73955
74392
|
request.positionId,
|
|
73956
74393
|
ratio,
|
|
@@ -74439,14 +74876,15 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
74439
74876
|
}
|
|
74440
74877
|
const debt = positionDetails.debt || positionDetails.ucdDebt || "0";
|
|
74441
74878
|
const btcPrice2 = litActionResult.btcPrice || "0";
|
|
74442
|
-
const
|
|
74879
|
+
const btcVaultBalance = litActionResult.btcAmountSats || positionDetails.btcVaultBalance || "0";
|
|
74880
|
+
const ratio = BigInt(debt) > 0n ? collateralRatioPercentString(BigInt(btcVaultBalance), BigInt(btcPrice2), BigInt(debt)) : "0.00";
|
|
74443
74881
|
const message = formatLiquidationSuccessMessage(
|
|
74444
74882
|
request.positionId,
|
|
74445
74883
|
ratio,
|
|
74446
74884
|
`${liquidationThreshold / 100}`,
|
|
74447
74885
|
// Convert to percentage
|
|
74448
74886
|
positionDetails.btcVault || "unknown",
|
|
74449
|
-
|
|
74887
|
+
btcVaultBalance,
|
|
74450
74888
|
debt,
|
|
74451
74889
|
btcPrice2
|
|
74452
74890
|
);
|
|
@@ -76930,6 +77368,17 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
76930
77368
|
error: `networkFee=${request.networkFee} is \u2265 50% of targetAmount=${request.targetAmount}. Refusing to broadcast \u2014 real Bitcoin fees are typically <1% of value.`
|
|
76931
77369
|
};
|
|
76932
77370
|
}
|
|
77371
|
+
const destinationDustLimit = destinationDustShortfall(
|
|
77372
|
+
request.targetAmount,
|
|
77373
|
+
request.networkFee,
|
|
77374
|
+
request.destination
|
|
77375
|
+
);
|
|
77376
|
+
if (destinationDustLimit !== null) {
|
|
77377
|
+
return {
|
|
77378
|
+
success: false,
|
|
77379
|
+
error: `Destination would receive ${request.targetAmount - request.networkFee} sats (targetAmount=${request.targetAmount} \u2212 networkFee=${request.networkFee}), below the ${destinationDustLimit}-sat dust limit for ${request.destination}; the transaction would not relay.`
|
|
77380
|
+
};
|
|
77381
|
+
}
|
|
76933
77382
|
const [txid, voutStr] = request.utxoIdentifier.split(":");
|
|
76934
77383
|
const vout = parseInt(voutStr || "0", 10);
|
|
76935
77384
|
if (!txid || isNaN(vout)) {
|
|
@@ -78405,8 +78854,9 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
78405
78854
|
const user = await signer.getAddress();
|
|
78406
78855
|
const registry = AgentDelegationRegistry__factory.connect(addr, signer);
|
|
78407
78856
|
let agentAddress;
|
|
78408
|
-
const [isActive, record, latestBlock] = await Promise.all([
|
|
78857
|
+
const [isActive, paused, record, latestBlock] = await Promise.all([
|
|
78409
78858
|
registry.isAgentActive(user),
|
|
78859
|
+
registry.paused(),
|
|
78410
78860
|
registry.agentOf(user),
|
|
78411
78861
|
this.getProviderOrThrow().getBlock("latest")
|
|
78412
78862
|
]);
|
|
@@ -78418,7 +78868,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
78418
78868
|
/* HIGH */
|
|
78419
78869
|
});
|
|
78420
78870
|
}
|
|
78421
|
-
const plan = planAgentBinding({ isActive, record, nowSeconds: latestBlock.timestamp });
|
|
78871
|
+
const plan = planAgentBinding({ isActive, paused, record, nowSeconds: latestBlock.timestamp });
|
|
78422
78872
|
if (plan.kind === "reuse") {
|
|
78423
78873
|
agentAddress = plan.agent;
|
|
78424
78874
|
} else {
|
|
@@ -81883,11 +82333,16 @@ var RealUpstreamPlugin = class {
|
|
|
81883
82333
|
this.src("subgraph")
|
|
81884
82334
|
);
|
|
81885
82335
|
},
|
|
81886
|
-
getPositionEvents: async () =>
|
|
81887
|
-
|
|
81888
|
-
|
|
81889
|
-
|
|
81890
|
-
|
|
82336
|
+
getPositionEvents: async () => (
|
|
82337
|
+
// PERMANENT capability gap, not a transient outage: the real adapter has no indexer
|
|
82338
|
+
// projection for event history, and this build never will. `unsupported` →
|
|
82339
|
+
// NOT_IMPLEMENTED so the guide does not tell the model to retry it (C-44).
|
|
82340
|
+
upFail({
|
|
82341
|
+
kind: "unsupported",
|
|
82342
|
+
source: "subgraph",
|
|
82343
|
+
message: "event history is not implemented on the real adapter in this build (no indexer projection) \u2014 this is a permanent capability gap, not a transient outage; do not retry"
|
|
82344
|
+
})
|
|
82345
|
+
)
|
|
81891
82346
|
};
|
|
81892
82347
|
this.chain = {
|
|
81893
82348
|
getPositionDetails: (id) => this.chainRead(() => this.readPositionDetails(id)),
|
|
@@ -82233,7 +82688,7 @@ var RealUpstreamPlugin = class {
|
|
|
82233
82688
|
}
|
|
82234
82689
|
if (mode === "external") {
|
|
82235
82690
|
const borrower = await rt.manager.resolveBorrowerForWrite();
|
|
82236
|
-
if (!borrower) {
|
|
82691
|
+
if (!borrower || this.pinnedWalletUnreachable(borrower, { allowCachedLogin: false })) {
|
|
82237
82692
|
return {
|
|
82238
82693
|
ok: false,
|
|
82239
82694
|
failure: {
|
|
@@ -82283,6 +82738,20 @@ var RealUpstreamPlugin = class {
|
|
|
82283
82738
|
}
|
|
82284
82739
|
};
|
|
82285
82740
|
}
|
|
82741
|
+
/** Hosted tier: the SIWE borrower is bound from boot, so "bound" no longer implies a
|
|
82742
|
+
* wallet can sign. Refuse as "no wallet is connected" instead of starting a ceremony
|
|
82743
|
+
* nobody can answer.
|
|
82744
|
+
*
|
|
82745
|
+
* `allowCachedLogin` is for `connectExternal` ONLY: a still-valid lit-ops login lets it
|
|
82746
|
+
* succeed without a wallet (it signs nothing). A WRITE always needs a fresh wallet
|
|
82747
|
+
* signature (ExternalEoaDHSigner), so a cached JWT must not admit it — that would queue
|
|
82748
|
+
* an approval with no wallet attached to sign it. */
|
|
82749
|
+
pinnedWalletUnreachable(borrower, opts) {
|
|
82750
|
+
if (!this.runtime?.manager.identityPinned()) return false;
|
|
82751
|
+
if (this.runtime.bridge.walletState() !== null) return false;
|
|
82752
|
+
if (!opts.allowCachedLogin) return true;
|
|
82753
|
+
return !this.sessionCache.get(`external:${borrower.toLowerCase()}`)?.hasValidToken();
|
|
82754
|
+
}
|
|
82286
82755
|
/** The EXPLICIT login action (plan 10 OV-10 / A0.7): the ONLY path that may summon the
|
|
82287
82756
|
* wallet for a lit-ops login outside a write ceremony. Binds the borrower on success —
|
|
82288
82757
|
* the first verified ceremony fixes the identity. */
|
|
@@ -82293,7 +82762,7 @@ var RealUpstreamPlugin = class {
|
|
|
82293
82762
|
return { ok: false, reason: `the active mode is '${manager.mode()}' \u2014 run signer_setup action 'use' mode 'external' first` };
|
|
82294
82763
|
}
|
|
82295
82764
|
const borrower = manager.borrowerForWrite();
|
|
82296
|
-
if (!borrower) {
|
|
82765
|
+
if (!borrower || this.pinnedWalletUnreachable(borrower, { allowCachedLogin: true })) {
|
|
82297
82766
|
return { ok: false, reason: "no wallet is connected \u2014 open the approval page (signer_setup action 'status') and connect your wallet first" };
|
|
82298
82767
|
}
|
|
82299
82768
|
const key = `external:${borrower.toLowerCase()}`;
|
|
@@ -82830,6 +83299,81 @@ var RealUpstreamPlugin = class {
|
|
|
82830
83299
|
var fs4 = __toESM(require("fs"));
|
|
82831
83300
|
var http3 = __toESM(require("http"));
|
|
82832
83301
|
var import_node_crypto7 = require("crypto");
|
|
83302
|
+
var import_ethers50 = require("ethers");
|
|
83303
|
+
|
|
83304
|
+
// src/util/brand-assets.ts
|
|
83305
|
+
var FAVICON_SVG = `<svg width="512" height="512" viewBox="-6 -11 88 88" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Diamond Hands"><path d="M1.08325 20.7041L37.9038 64.4967L74.2886 20.7041L61.8699 0.877686H13.502L1.08325 20.7041Z" fill="#C9F284" stroke="#34440E" stroke-width="1.75559"/><path d="M13.9385 0.877441L37.9045 64.2785" stroke="#34440E" stroke-width="1.75559"/><path d="M61.6553 0.877441L37.9071 64.4964" stroke="#34440E" stroke-width="1.75559"/><path d="M1.08276 20.7029H74.2882" stroke="#34440E" stroke-width="1.75559"/></svg>`;
|
|
83306
|
+
var FAVICON_DATA_URI = `data:image/svg+xml,${encodeURIComponent(FAVICON_SVG).replace(/'/g, "%27")}`;
|
|
83307
|
+
var GVNR_PILL_LOGO_DATA_URI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAACXCAYAAABjhOMoAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAAJTxJREFUeAHtnV92E0myxiMyS6bhPrRmBS0e5xzbWCtArKDdK2izgoZz7pjpOw+Yh+kem3sOsALcKwBWgFmB/zHnPqJewbgfhmmsysybUZLcwkiWZGVUZaXid4axLasNlqoyv4z4IgJhAQ57P3eUUhsIeAcRNvxDLf+nCYIgCIIghOTM/+kCuK518M5ae9Ru/HgAC4AwJ4dup5nZmz8A4gOQzV4QBEEQKsF5MQAOD8y5edK++WMX5mRmAUAbv7I3nyvE70EQBEEQhGhwDvbnFQIzCYBjs/vAb/yP4YsTP55ZZ9+gwgMFcNQDc9bG+VWIIAiCIAiTKaLv8F8bzrgWoOv4Pfmu66fdP8e5nTX96MksPxOn/oXu1iv/aeeznw/wDhF31vAvByAIgiAIQumcuP/dBGcf+I387qVvHeSfzP1p0YCJAuDQ/dzSTr1FwNbIw0c+9/9QNn5BEARBiINT97SDzr0cjQiQP8B8sveuEgFjBcC4zd+H+l/c0X99AIIgCIIgRMep2d2Bfrq+YJoI+EIAjNv8nTX317Mf90EQBEEQhGg5yXc3UeFLGHj2ChGA/2m3cefs8nPV5Qcyp5+Nbv6YQ1s2f0EQBEGIn/Xs0Wu/b9+Dft8AoP184OX7gs8EALn9/YfN4dc+p/BwdWX7CARBEARBqAW0bzvr7o881Dk2P32Rwr9IAVwO/VtnntzRP+6AIAiCIAi149TsPfe7/A+DL8/yT6Y96ge4iAAoq3aGm79XBV3Z/AVBEAShvqzpbTr1D6P4Tb2iH49+vxAAdPof7fBnrXsIgiAIgiDUG4MX+zkibB3+5+fW8OtCA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308
|
+
|
|
83309
|
+
// src/util/house-style.ts
|
|
83310
|
+
var APP_BACKGROUND_ORIGIN = "https://images.diamondhands.credit";
|
|
83311
|
+
var APP_BACKGROUND_URL = `${APP_BACKGROUND_ORIGIN}/bg-diamond-hands.png`;
|
|
83312
|
+
var FONT_ORIGIN = "https://images.gvnr.xyz";
|
|
83313
|
+
var MANROPE_BASE = `${FONT_ORIGIN}/fonts/manrope`;
|
|
83314
|
+
var HOUSE_CSP_EXTRA = {
|
|
83315
|
+
"img-src": [APP_BACKGROUND_ORIGIN, "data:"],
|
|
83316
|
+
"font-src": [FONT_ORIGIN]
|
|
83317
|
+
};
|
|
83318
|
+
var HOUSE_HEAD_LINKS = `<link rel="icon" type="image/svg+xml" href="${FAVICON_DATA_URI}">
|
|
83319
|
+
<link rel="apple-touch-icon" href="${FAVICON_DATA_URI}">`;
|
|
83320
|
+
var MANROPE_WEIGHTS = [
|
|
83321
|
+
[300, "Light"],
|
|
83322
|
+
[400, "Regular"],
|
|
83323
|
+
[500, "Medium"],
|
|
83324
|
+
[600, "SemiBold"],
|
|
83325
|
+
[700, "Bold"]
|
|
83326
|
+
];
|
|
83327
|
+
var HOUSE_BASE_CSS = `
|
|
83328
|
+
${MANROPE_WEIGHTS.map(([w, n]) => `@font-face { font-family: "Manrope"; font-weight: ${w}; font-display: swap; src: url("${MANROPE_BASE}/Manrope-${n}.ttf") format("truetype"); }`).join("\n")}
|
|
83329
|
+
* { box-sizing: border-box; }
|
|
83330
|
+
html { min-height: 100%; background: #000006; }
|
|
83331
|
+
body { margin: 0; min-height: 100vh; color: #fff; font: 14px/1.5 "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
83332
|
+
background: #000006 url("${APP_BACKGROUND_URL}") center / cover no-repeat fixed; }
|
|
83333
|
+
.house-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; }
|
|
83334
|
+
@media (min-width: 768px) { .house-header { padding: 1rem 2.5rem; } }
|
|
83335
|
+
.house-header > img { height: 1.92rem; width: auto; display: block; flex: none; }
|
|
83336
|
+
/* Narrow viewports: the chip may shrink (its label ellipsises), and below 400px the label
|
|
83337
|
+
is dropped so logo + chip icon always fit a 320px phone with no horizontal page scroll. */
|
|
83338
|
+
.house-header .chip { min-width: 0; }
|
|
83339
|
+
.chip-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
83340
|
+
/* ".house-header .chip", not ".chip": the base .chip rule below declares padding too, and at
|
|
83341
|
+
equal specificity the LATER rule wins regardless of the media query; this selector outranks it. */
|
|
83342
|
+
@media (max-width: 400px) { .chip-label { display: none; } .house-header .chip { padding: 0.4rem 0.6rem; } }
|
|
83343
|
+
.chip { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.4rem 0.85rem; border-radius: 999px;
|
|
83344
|
+
background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(255, 255, 255, 0.1); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
|
|
83345
|
+
font-size: 0.8rem; font-weight: 600; color: #dbff91; white-space: nowrap; }
|
|
83346
|
+
.chip img { height: 1rem; }
|
|
83347
|
+
main { max-width: 34rem; margin: 2.5rem auto 3rem; padding: 0 1rem; }
|
|
83348
|
+
.panel { background: #121212; border: 1px solid rgba(255, 255, 255, 0.06); border-radius: 12px; padding: 1rem;
|
|
83349
|
+
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05); }
|
|
83350
|
+
@media (min-width: 768px) { .panel { padding: 1.25rem; } }
|
|
83351
|
+
h1 { font-size: 1.25rem; font-weight: 600; line-height: 1.375; color: #fafafa; margin: 0 0 1rem; }
|
|
83352
|
+
@media (min-width: 768px) { h1 { font-size: 1.5rem; margin-bottom: 1.25rem; } }
|
|
83353
|
+
h2 { font-size: 1rem; font-weight: 600; line-height: 1.375; color: #fafafa; margin: 0 0 0.75rem; }
|
|
83354
|
+
p { margin: 0 0 1rem; color: #e5e5e5; font-size: 0.875rem; font-weight: 300; line-height: 1.5; }
|
|
83355
|
+
button { font: inherit; font-size: 0.875rem; cursor: pointer; border: 0; display: inline-flex; align-items: center; justify-content: center;
|
|
83356
|
+
min-height: 2.75rem; padding: 0.65rem 1.25rem; transition: opacity 0.2s, background-color 0.2s; }
|
|
83357
|
+
button:focus-visible { outline: 2px solid #84cc16; outline-offset: 2px; }
|
|
83358
|
+
button:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
83359
|
+
/* Primary = lime-700 (#4d7c0f): white 14px text on it is 4.99:1 (WCAG AA needs 4.5:1; the
|
|
83360
|
+
brighter #65a30d was 3.09:1). Hover = lime-800 (#3f6212), 7.08:1. A test recomputes both. */
|
|
83361
|
+
.btn-primary { background: #4d7c0f; color: #fff; font-weight: 700; letter-spacing: 0.025em; border-radius: 12px; box-shadow: 0 4px 18px rgba(74, 222, 128, 0.2); }
|
|
83362
|
+
.btn-primary:hover:not(:disabled) { background: #3f6212; }
|
|
83363
|
+
.btn-secondary { background: #34440e; color: #dbff91; font-weight: 500; border-radius: 20px; }
|
|
83364
|
+
.btn-secondary:hover:not(:disabled) { background: #3d5210; }
|
|
83365
|
+
.btn-danger { background: transparent; color: #fca5a5; font-weight: 600; border-radius: 12px; border: 1px solid rgba(248, 113, 113, 0.45); }
|
|
83366
|
+
.btn-danger:hover:not(:disabled) { background: rgba(220, 38, 38, 0.15); }
|
|
83367
|
+
/* A QR needs dark-on-light to scan: it keeps a white plate on the dark page. */
|
|
83368
|
+
.qr-plate { max-width: 16rem; margin-top: 1rem; background: #fff; border-radius: 12px; padding: 0.5rem; }
|
|
83369
|
+
.qr-plate svg { width: 100%; height: auto; display: block; }
|
|
83370
|
+
`;
|
|
83371
|
+
function houseHeader(label) {
|
|
83372
|
+
return `<header class="house-header">
|
|
83373
|
+
<img src="${GVNR_PILL_LOGO_DATA_URI}" alt="GVNR">
|
|
83374
|
+
<span class="chip"><img src="${FAVICON_DATA_URI}" alt=""><span class="chip-label">${label}</span></span>
|
|
83375
|
+
</header>`;
|
|
83376
|
+
}
|
|
82833
83377
|
|
|
82834
83378
|
// src/boundary/upstream/shared/external-bridge/approval-page.ts
|
|
82835
83379
|
function renderApprovalPage(sessionId, nonce) {
|
|
@@ -82839,46 +83383,47 @@ function renderApprovalPage(sessionId, nonce) {
|
|
|
82839
83383
|
<meta charset="utf-8">
|
|
82840
83384
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
82841
83385
|
<title>Diamond Hands \u2014 signature approval</title>
|
|
83386
|
+
${HOUSE_HEAD_LINKS}
|
|
82842
83387
|
<style>
|
|
82843
|
-
|
|
82844
|
-
|
|
82845
|
-
|
|
82846
|
-
|
|
82847
|
-
|
|
82848
|
-
|
|
82849
|
-
|
|
82850
|
-
|
|
82851
|
-
|
|
82852
|
-
.
|
|
82853
|
-
|
|
82854
|
-
|
|
82855
|
-
|
|
82856
|
-
|
|
82857
|
-
#
|
|
82858
|
-
#
|
|
82859
|
-
#wallet { font-family:ui-monospace,monospace; font-size:12px; color:var(--dim); margin-top:10px; }
|
|
83388
|
+
${HOUSE_BASE_CSS}
|
|
83389
|
+
/* \u2500\u2500 approval page only \u2500\u2500 */
|
|
83390
|
+
main { max-width: 36rem; }
|
|
83391
|
+
.status { color:#a1a1a1; font-size:0.875rem; }
|
|
83392
|
+
.action { text-transform:uppercase; letter-spacing:.08em; font-size:0.75rem; font-weight:600; color:#dbff91; margin-top:0.25rem; }
|
|
83393
|
+
/* The decoded card IS the operation (decode-equivalence): kept monospace and pre-wrapped
|
|
83394
|
+
exactly as the server rendered it, on an inset well darker than the panel. */
|
|
83395
|
+
.card { white-space:pre-wrap; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:0.875rem; color:#fafafa;
|
|
83396
|
+
background:#0a0a0a; border:1px solid rgba(255,255,255,0.1); border-radius:10px; padding:14px; margin:0.75rem 0 1rem; }
|
|
83397
|
+
.actions { display:flex; flex-wrap:wrap; gap:0.75rem; }
|
|
83398
|
+
#deadline { margin-bottom:1rem; }
|
|
83399
|
+
#wallet { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:0.75rem; color:#a1a1a1; margin-top:1rem; }
|
|
83400
|
+
#wallet:empty { display:none; }
|
|
83401
|
+
#wc { margin-top:1.25rem; border-top:1px solid rgba(255,255,255,0.06); padding-top:1rem; }
|
|
83402
|
+
#wc-uri { user-select:all; word-break:break-all; font-size:0.75rem; }
|
|
83403
|
+
#wc-hint { margin-top:0.75rem; }
|
|
82860
83404
|
.hidden { display:none; }
|
|
82861
83405
|
</style>
|
|
82862
83406
|
</head>
|
|
82863
83407
|
<body>
|
|
83408
|
+
${houseHeader("Diamond Hands \xB7 signature approval")}
|
|
82864
83409
|
<main>
|
|
82865
|
-
<h1
|
|
83410
|
+
<h1>Signature approval</h1>
|
|
82866
83411
|
<div class="panel">
|
|
82867
83412
|
<div id="status" class="status">Connecting to your wallet\u2026</div>
|
|
82868
83413
|
<div id="request" class="hidden">
|
|
82869
83414
|
<div id="action" class="action"></div>
|
|
82870
83415
|
<div id="card" class="card"></div>
|
|
82871
83416
|
<div id="deadline" class="status hidden"></div>
|
|
82872
|
-
<
|
|
82873
|
-
|
|
83417
|
+
<div class="actions">
|
|
83418
|
+
<button id="approve" class="btn-primary">Approve in wallet</button>
|
|
83419
|
+
<button id="reject" class="btn-danger">Reject</button>
|
|
83420
|
+
</div>
|
|
82874
83421
|
</div>
|
|
82875
83422
|
<div id="wallet"></div>
|
|
82876
|
-
<div id="wc"
|
|
82877
|
-
<button id="wc-connect"
|
|
82878
|
-
|
|
82879
|
-
|
|
82880
|
-
<div id="wc-qr" class="hidden" style="background:#fff; border-radius:8px; padding:8px; margin-top:10px; max-width:280px;"></div>
|
|
82881
|
-
<div id="wc-uri" class="card hidden" style="user-select:all; word-break:break-all; font-size:12px;"></div>
|
|
83423
|
+
<div id="wc">
|
|
83424
|
+
<button id="wc-connect" class="btn-secondary">Use a mobile wallet instead (WalletConnect)</button>
|
|
83425
|
+
<div id="wc-qr" class="qr-plate hidden"></div>
|
|
83426
|
+
<div id="wc-uri" class="card hidden"></div>
|
|
82882
83427
|
<div id="wc-hint" class="status hidden">Scan the QR with your wallet app (or open the app \u2192 WalletConnect \u2192 paste the pairing code). Approvals then happen on your phone.</div>
|
|
82883
83428
|
</div>
|
|
82884
83429
|
</div>
|
|
@@ -82953,21 +83498,63 @@ async function healChain() {
|
|
|
82953
83498
|
}).catch(() => undefined);
|
|
82954
83499
|
}
|
|
82955
83500
|
await readWallet();
|
|
82956
|
-
await
|
|
83501
|
+
await sayHello();
|
|
82957
83502
|
showWallet();
|
|
82958
83503
|
}
|
|
82959
83504
|
|
|
83505
|
+
function utf8Hex(text) {
|
|
83506
|
+
return "0x" + Array.from(new TextEncoder().encode(text)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
83507
|
+
}
|
|
83508
|
+
|
|
83509
|
+
// Presence proof: the bridge only believes a wallet is at this page once the wallet has
|
|
83510
|
+
// SIGNED a short statement naming this page's origin, the chain and a per-page nonce. Saying
|
|
83511
|
+
// an address proves nothing (it is public); signing proves the key is here. One prompt per
|
|
83512
|
+
// page session: once this account has proven itself the bridge accepts later hellos for it
|
|
83513
|
+
// (a chain switch) without asking the wallet again.
|
|
83514
|
+
let provenFor = null;
|
|
83515
|
+
async function sayHello() {
|
|
83516
|
+
let signature;
|
|
83517
|
+
if (provenFor === null || provenFor.toLowerCase() !== String(account).toLowerCase()) {
|
|
83518
|
+
const ch = await fetch(BASE + "challenge?s=" + SESSION + "&chainId=" + chainId).then((r) => r.json());
|
|
83519
|
+
showIdleStatus("Sign the short statement in your wallet to prove it is yours \u2014 it moves no funds.");
|
|
83520
|
+
signature = await window.ethereum.request({ method: "personal_sign", params: [utf8Hex(ch.statement), account] });
|
|
83521
|
+
}
|
|
83522
|
+
const r = await post(BASE + "hello", { account: account, chainId: chainId, signature: signature });
|
|
83523
|
+
if (!r.ok) {
|
|
83524
|
+
const b = await r.json().catch(() => ({}));
|
|
83525
|
+
showStatus("This wallet was not accepted: " + (b.error || "HTTP " + r.status));
|
|
83526
|
+
return false;
|
|
83527
|
+
}
|
|
83528
|
+
provenFor = account;
|
|
83529
|
+
return true;
|
|
83530
|
+
}
|
|
83531
|
+
|
|
83532
|
+
// The stream opens at load, so a card can be on screen BEFORE connect() finishes. The status
|
|
83533
|
+
// line then belongs to that card (its review / mobile-wallet guidance), and connection
|
|
83534
|
+
// progress must not overwrite it. Connection progress lines (idle / "sign the statement", whose
|
|
83535
|
+
// wallet popup is self-explanatory) go through here; failures (a refused hello, a lost
|
|
83536
|
+
// stream, a wrong network) still show unconditionally.
|
|
83537
|
+
function showIdleStatus(text) {
|
|
83538
|
+
if (current !== null) return;
|
|
83539
|
+
showStatus(text);
|
|
83540
|
+
}
|
|
83541
|
+
|
|
82960
83542
|
async function connect() {
|
|
82961
|
-
if (!window.ethereum) {
|
|
83543
|
+
if (!window.ethereum) {
|
|
83544
|
+
// The event stream is already open (see the bottom of this script) \u2014 a phone paired
|
|
83545
|
+
// below still mirrors its cards here.
|
|
83546
|
+
showIdleStatus("No browser wallet detected \u2014 use the mobile wallet option below, or install MetaMask (or open this page in a wallet browser).");
|
|
83547
|
+
return;
|
|
83548
|
+
}
|
|
82962
83549
|
await window.ethereum.request({ method: "eth_requestAccounts" });
|
|
82963
83550
|
await readWallet();
|
|
82964
|
-
|
|
83551
|
+
const accepted = await sayHello();
|
|
82965
83552
|
showWallet();
|
|
82966
83553
|
window.ethereum.on("accountsChanged", onAccountsChanged);
|
|
82967
83554
|
window.ethereum.on("chainChanged", onChainChanged);
|
|
83555
|
+
if (!accepted) return;
|
|
82968
83556
|
await healChain();
|
|
82969
|
-
|
|
82970
|
-
listen();
|
|
83557
|
+
showIdleStatus("Connected. Waiting for a signature request\u2026");
|
|
82971
83558
|
}
|
|
82972
83559
|
|
|
82973
83560
|
// Handlers trust the EVENT payloads \u2014 re-reading eth_accounts/eth_chainId here races the
|
|
@@ -82977,6 +83564,8 @@ async function onAccountsChanged(accounts) {
|
|
|
82977
83564
|
await post(BASE + "wallet-event", { account: account, chainId: chainId });
|
|
82978
83565
|
showWallet();
|
|
82979
83566
|
invalidatePageRequests("Wallet changed \u2014 pending request invalidated.");
|
|
83567
|
+
// The bridge adopts no account from an event alone \u2014 a different account proves itself.
|
|
83568
|
+
if (account) await sayHello();
|
|
82980
83569
|
}
|
|
82981
83570
|
|
|
82982
83571
|
async function onChainChanged(cid) {
|
|
@@ -82986,8 +83575,14 @@ async function onChainChanged(cid) {
|
|
|
82986
83575
|
invalidatePageRequests("Network changed \u2014 pending request invalidated.");
|
|
82987
83576
|
}
|
|
82988
83577
|
|
|
83578
|
+
// ONE stream per page, opened at load whatever wallet this browser has: a phone paired
|
|
83579
|
+
// through WalletConnect needs no injected wallet, and its read-only mirror arrives on this
|
|
83580
|
+
// stream. Opening it proves nothing \u2014 the bridge sends this page NOTHING until a person is
|
|
83581
|
+
// proven (a signed hello, or a pairing a phone answered).
|
|
83582
|
+
let es = null;
|
|
82989
83583
|
function listen() {
|
|
82990
|
-
|
|
83584
|
+
if (es !== null) return;
|
|
83585
|
+
es = new EventSource(BASE + "events?s=" + SESSION);
|
|
82991
83586
|
es.onmessage = (ev) => {
|
|
82992
83587
|
const next = JSON.parse(ev.data);
|
|
82993
83588
|
// A later frame for an id REPLACES the earlier one: driveWc re-stamps a personal-sign
|
|
@@ -83179,6 +83774,7 @@ document.getElementById("wc-connect").onclick = async () => {
|
|
|
83179
83774
|
showStatus("Scan the QR (or paste the code) in your mobile wallet \u2014 it becomes the signing wallet.");
|
|
83180
83775
|
};
|
|
83181
83776
|
|
|
83777
|
+
listen();
|
|
83182
83778
|
connect();
|
|
83183
83779
|
</script>
|
|
83184
83780
|
</body>
|
|
@@ -83287,6 +83883,16 @@ function htmlPageSecurityHeaders(extra) {
|
|
|
83287
83883
|
|
|
83288
83884
|
// src/boundary/upstream/shared/external-bridge/bridge.ts
|
|
83289
83885
|
var MAX_SESSIONS = 16;
|
|
83886
|
+
var MAX_PENDING_PAIRINGS = 64;
|
|
83887
|
+
function presenceStatement(origin2, chainId, nonce) {
|
|
83888
|
+
return [
|
|
83889
|
+
"Diamond Hands approval page",
|
|
83890
|
+
"Sign to prove this wallet is yours. This moves no funds and approves no operation.",
|
|
83891
|
+
`Origin: ${origin2}`,
|
|
83892
|
+
`Chain ID: ${chainId}`,
|
|
83893
|
+
`Session nonce: ${nonce}`
|
|
83894
|
+
].join("\n");
|
|
83895
|
+
}
|
|
83290
83896
|
var DEFAULT_EXPIRY_MS = 5 * 60 * 1e3;
|
|
83291
83897
|
var DEFAULT_ATTACH_GRACE_MS = 60 * 1e3;
|
|
83292
83898
|
var DEFAULT_HOSTED_ATTACH_GRACE_MS = 180 * 1e3;
|
|
@@ -83300,6 +83906,7 @@ function wcDeclineOrFault(e) {
|
|
|
83300
83906
|
}
|
|
83301
83907
|
var SignatureBridge = class {
|
|
83302
83908
|
clock;
|
|
83909
|
+
sweepIntervalMs;
|
|
83303
83910
|
/** Lowercased at construction so every comparison is case-flat — EIP-55 checksum casing
|
|
83304
83911
|
* differs between what SIWE signs and what a wallet reports for the SAME address. */
|
|
83305
83912
|
boundAccount;
|
|
@@ -83330,11 +83937,20 @@ var SignatureBridge = class {
|
|
|
83330
83937
|
wcTransport = null;
|
|
83331
83938
|
/** True while a WalletConnect session is THE wallet — ceremonies route over WC. */
|
|
83332
83939
|
wcActive = false;
|
|
83940
|
+
/** Which page session asked for which pairing (pairing id → session id). The transport's
|
|
83941
|
+
* `onSession` says WHICH PAIRING a phone answered; this says whose it was. The previous
|
|
83942
|
+
* "most recent asker" guess let a second session claim the credit for a QR the user's
|
|
83943
|
+
* phone scanned (Sentinel 2 PoC-B). */
|
|
83944
|
+
pairingOwners = /* @__PURE__ */ new Map();
|
|
83333
83945
|
keystoreUnlock;
|
|
83334
83946
|
unlockToken = null;
|
|
83335
83947
|
unlockSession = null;
|
|
83336
83948
|
constructor(opts) {
|
|
83337
83949
|
this.clock = opts?.clock ?? Date.now;
|
|
83950
|
+
this.sweepIntervalMs = opts?.sweepIntervalMs ?? 1e3;
|
|
83951
|
+
if (!Number.isInteger(this.sweepIntervalMs) || this.sweepIntervalMs < 0) {
|
|
83952
|
+
throw new Error(`bridge sweepIntervalMs must be a non-negative integer (got ${String(opts?.sweepIntervalMs)})`);
|
|
83953
|
+
}
|
|
83338
83954
|
this.boundAccount = opts?.boundAccount?.toLowerCase();
|
|
83339
83955
|
this.expiryMs = opts?.expiryMs ?? DEFAULT_EXPIRY_MS;
|
|
83340
83956
|
this.maxPending = opts?.maxPending ?? null;
|
|
@@ -83370,8 +83986,10 @@ var SignatureBridge = class {
|
|
|
83370
83986
|
this.server = server;
|
|
83371
83987
|
}
|
|
83372
83988
|
this.started = true;
|
|
83373
|
-
this.
|
|
83374
|
-
|
|
83989
|
+
if (this.sweepIntervalMs > 0) {
|
|
83990
|
+
this.sweepTimer = setInterval(() => this.sweep(), this.sweepIntervalMs);
|
|
83991
|
+
this.sweepTimer.unref();
|
|
83992
|
+
}
|
|
83375
83993
|
if (this.urlFile) fs4.writeFileSync(this.urlFile, this.url());
|
|
83376
83994
|
}
|
|
83377
83995
|
/** Plan 12 C1: the outer server's dispatch entry for a MOUNTED bridge — `req.url`
|
|
@@ -83431,6 +84049,16 @@ var SignatureBridge = class {
|
|
|
83431
84049
|
pendingCount() {
|
|
83432
84050
|
return this.pending.size;
|
|
83433
84051
|
}
|
|
84052
|
+
/** A request lives for the bridge's expiry OR until its payload dies, whichever is first.
|
|
84053
|
+
* The BTC-withdraw execute leg's payload dies inside a sub-minute quantum window; holding
|
|
84054
|
+
* the ceremony open for the full five minutes kept a dead card on screen and let the phone
|
|
84055
|
+
* be asked to sign something the protocol would refuse. */
|
|
84056
|
+
deadlineFor(request, nowMs) {
|
|
84057
|
+
const bridgeDeadline = nowMs + this.expiryMs;
|
|
84058
|
+
if (request.expiresAtSec === void 0) return bridgeDeadline;
|
|
84059
|
+
if (!Number.isFinite(request.expiresAtSec)) throw new Error(`request ${request.id} carries a non-finite expiresAtSec`);
|
|
84060
|
+
return Math.min(bridgeDeadline, request.expiresAtSec * 1e3);
|
|
84061
|
+
}
|
|
83434
84062
|
/**
|
|
83435
84063
|
* Enqueue a request and resolve on the human's decision (or expiry/invalidation).
|
|
83436
84064
|
* Chain-id mismatch with an already-connected wallet refuses BEFORE the wallet is asked.
|
|
@@ -83453,14 +84081,15 @@ var SignatureBridge = class {
|
|
|
83453
84081
|
const now = this.clock();
|
|
83454
84082
|
const entry = {
|
|
83455
84083
|
request,
|
|
83456
|
-
deadlineMs:
|
|
84084
|
+
deadlineMs: this.deadlineFor(request, now),
|
|
83457
84085
|
enqueuedMs: now,
|
|
83458
84086
|
resolve,
|
|
83459
84087
|
settled: false,
|
|
83460
84088
|
...handlers?.finalize ? { finalize: handlers.finalize } : {},
|
|
83461
84089
|
owner: this.wcActive ? "wc" : "page",
|
|
83462
84090
|
dispatched: false,
|
|
83463
|
-
lastAttachedMs: now
|
|
84091
|
+
lastAttachedMs: now,
|
|
84092
|
+
finalizedBy: null
|
|
83464
84093
|
};
|
|
83465
84094
|
this.pending.set(request.id, entry);
|
|
83466
84095
|
if (entry.owner === "wc") {
|
|
@@ -83483,7 +84112,7 @@ var SignatureBridge = class {
|
|
|
83483
84112
|
const now = this.clock();
|
|
83484
84113
|
const entry = {
|
|
83485
84114
|
request,
|
|
83486
|
-
deadlineMs:
|
|
84115
|
+
deadlineMs: this.deadlineFor(request, now),
|
|
83487
84116
|
enqueuedMs: now,
|
|
83488
84117
|
resolve,
|
|
83489
84118
|
settled: false,
|
|
@@ -83493,7 +84122,8 @@ var SignatureBridge = class {
|
|
|
83493
84122
|
// ceremony could not reach quorum through the very pages it is broadcast to.
|
|
83494
84123
|
owner: "both",
|
|
83495
84124
|
dispatched: false,
|
|
83496
|
-
lastAttachedMs: now
|
|
84125
|
+
lastAttachedMs: now,
|
|
84126
|
+
finalizedBy: null
|
|
83497
84127
|
};
|
|
83498
84128
|
this.pending.set(request.id, entry);
|
|
83499
84129
|
this.pushEntry(entry);
|
|
@@ -83534,6 +84164,7 @@ var SignatureBridge = class {
|
|
|
83534
84164
|
return;
|
|
83535
84165
|
}
|
|
83536
84166
|
try {
|
|
84167
|
+
if (this.expireIfOverdue(entry)) return;
|
|
83537
84168
|
if (req.kind === "transaction") {
|
|
83538
84169
|
this.pushEntry(entry);
|
|
83539
84170
|
const tx2 = req.tx;
|
|
@@ -83545,15 +84176,23 @@ var SignatureBridge = class {
|
|
|
83545
84176
|
} else if (req.kind === "personal-sign") {
|
|
83546
84177
|
if (entry.finalize) {
|
|
83547
84178
|
const fresh = await entry.finalize();
|
|
84179
|
+
if (entry.settled) return;
|
|
84180
|
+
if (entry.owner !== "wc") return;
|
|
84181
|
+
const live = transport.active();
|
|
84182
|
+
if (!this.wcActive || !live || live.account.toLowerCase() !== account.toLowerCase()) {
|
|
84183
|
+
this.settle(entry, {
|
|
84184
|
+
status: "invalidated",
|
|
84185
|
+
reason: "the WalletConnect wallet changed while this payload was being prepared \u2014 the phone was not asked. Reconnect your wallet and retry the operation."
|
|
84186
|
+
});
|
|
84187
|
+
return;
|
|
84188
|
+
}
|
|
83548
84189
|
req.personalSign = fresh.personalSign;
|
|
83549
84190
|
req.card = fresh.card;
|
|
83550
84191
|
}
|
|
84192
|
+
if (this.expireIfOverdue(entry)) return;
|
|
83551
84193
|
const ps = req.personalSign;
|
|
83552
|
-
if (
|
|
83553
|
-
this.settle(entry, {
|
|
83554
|
-
status: "invalidated",
|
|
83555
|
-
reason: `this step signs a 32-byte hash your wallet cannot decode, and no approval page is open to show you what it authorizes \u2014 open ${this.url()} and re-run the withdrawal with loan_withdraw_retry (it re-signs with a fresh stamp; your coins stay in the vault meanwhile)`
|
|
83556
|
-
});
|
|
84194
|
+
if (!this.pageAttached()) {
|
|
84195
|
+
this.settle(entry, { status: "invalidated", reason: this.noPageReason(ps.layout === RAW_HASH_LAYOUT) });
|
|
83557
84196
|
return;
|
|
83558
84197
|
}
|
|
83559
84198
|
this.pushEntry(entry);
|
|
@@ -83578,6 +84217,16 @@ var SignatureBridge = class {
|
|
|
83578
84217
|
}
|
|
83579
84218
|
}
|
|
83580
84219
|
}
|
|
84220
|
+
/** Refusal for a WalletConnect personal_sign with no proven approval page attached.
|
|
84221
|
+
*
|
|
84222
|
+
* The remedy names BOTH halves, because opening the link alone does not fix it: a freshly
|
|
84223
|
+
* opened page is a stranger until a phone answers a pairing it showed (or its wallet signs
|
|
84224
|
+
* the presence statement), so it receives no card. Following "just reopen the URL" looped
|
|
84225
|
+
* (Sentinel 2 PoC-C). */
|
|
84226
|
+
noPageReason(blindHash) {
|
|
84227
|
+
const what = blindHash ? "this step signs a 32-byte hash your wallet cannot decode" : "this step asks your wallet to sign a message your phone shows only as a hash";
|
|
84228
|
+
return `${what}, and no approval page linked to your wallet is open to show you what it authorizes \u2014 open ${this.url()} in a browser AND, on that page, re-scan the WalletConnect QR with your phone (or reconnect your wallet there) so the page is tied to your wallet, then retry with loan_withdraw_retry for a withdrawal or re-run the operation (it re-signs with a fresh stamp; your coins stay in the vault meanwhile)`;
|
|
84229
|
+
}
|
|
83581
84230
|
/** A live attachment that could still decide a request: an open approval-page SSE
|
|
83582
84231
|
* stream (real page or headless driver) or an active WalletConnect session. PUBLIC
|
|
83583
84232
|
* (plan 17 E1): the connector's idle-eviction predicate reads it — a tenant world
|
|
@@ -83591,7 +84240,7 @@ var SignatureBridge = class {
|
|
|
83591
84240
|
* receives nothing cannot show anything. Distinct from `attachedNow()`, which counts
|
|
83592
84241
|
* WalletConnect and must stay global for the connector's eviction predicate. */
|
|
83593
84242
|
pageAttached() {
|
|
83594
|
-
for (const s of this.sessions.values()) if (
|
|
84243
|
+
for (const s of this.sessions.values()) if (s.sse && this.authorized(s)) return true;
|
|
83595
84244
|
return false;
|
|
83596
84245
|
}
|
|
83597
84246
|
/** Attachment for ONE entry — the wallet that entry is actually waiting on. The global
|
|
@@ -83608,6 +84257,7 @@ var SignatureBridge = class {
|
|
|
83608
84257
|
* the deadline is checked first so expiry semantics stay pinned (T-EXT-03). */
|
|
83609
84258
|
sweep() {
|
|
83610
84259
|
const now = this.clock();
|
|
84260
|
+
this.evictDeadSessions();
|
|
83611
84261
|
for (const entry of this.pending.values()) {
|
|
83612
84262
|
if (entry.settled) continue;
|
|
83613
84263
|
if (now >= entry.deadlineMs) {
|
|
@@ -83660,6 +84310,7 @@ var SignatureBridge = class {
|
|
|
83660
84310
|
void this.wcTransport?.close().catch(() => void 0);
|
|
83661
84311
|
this.wcTransport = null;
|
|
83662
84312
|
this.wcActive = false;
|
|
84313
|
+
this.pairingOwners.clear();
|
|
83663
84314
|
}
|
|
83664
84315
|
// ---- HTTP plumbing ----
|
|
83665
84316
|
route(req, res) {
|
|
@@ -83667,6 +84318,7 @@ var SignatureBridge = class {
|
|
|
83667
84318
|
const url2 = new URL(req.url ?? "/", this.mount ? this.mount.origin : `http://127.0.0.1:${this.port}`);
|
|
83668
84319
|
if (req.method === "GET" && url2.pathname === "/") return this.servePage(url2, res);
|
|
83669
84320
|
if (req.method === "GET" && url2.pathname === "/config") return this.serveConfig(url2, res);
|
|
84321
|
+
if (req.method === "GET" && url2.pathname === "/challenge") return this.serveChallenge(url2, res);
|
|
83670
84322
|
if (req.method === "GET" && url2.pathname === "/wc-pairing") return void this.serveWcPairing(url2, res);
|
|
83671
84323
|
if (req.method === "GET" && url2.pathname === "/unlock") return this.serveUnlockPage(url2, res);
|
|
83672
84324
|
if (req.method === "POST" && url2.pathname === "/unlock-submit")
|
|
@@ -83720,13 +84372,22 @@ var SignatureBridge = class {
|
|
|
83720
84372
|
this.deny(res, 403, "this approval link has expired \u2014 ask for a fresh one (signer_setup status) and reopen");
|
|
83721
84373
|
return;
|
|
83722
84374
|
}
|
|
84375
|
+
this.makeRoomForSession();
|
|
83723
84376
|
if (this.sessions.size >= MAX_SESSIONS) {
|
|
83724
84377
|
this.deny(res, 429, `too many open approval pages (${MAX_SESSIONS}) \u2014 close one and retry`);
|
|
83725
84378
|
return;
|
|
83726
84379
|
}
|
|
83727
84380
|
const sessionId = (0, import_node_crypto7.randomBytes)(24).toString("hex");
|
|
83728
|
-
this.sessions.set(sessionId, {
|
|
83729
|
-
|
|
84381
|
+
this.sessions.set(sessionId, {
|
|
84382
|
+
wallet: null,
|
|
84383
|
+
sse: null,
|
|
84384
|
+
refused: null,
|
|
84385
|
+
lastSeenMs: this.clock(),
|
|
84386
|
+
wcPaired: false,
|
|
84387
|
+
presenceNonce: (0, import_node_crypto7.randomBytes)(16).toString("hex"),
|
|
84388
|
+
provenAccount: null
|
|
84389
|
+
});
|
|
84390
|
+
const page = htmlPageSecurityHeaders(HOUSE_CSP_EXTRA);
|
|
83730
84391
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store", ...page.headers });
|
|
83731
84392
|
res.end(renderApprovalPage(sessionId, page.nonce));
|
|
83732
84393
|
}
|
|
@@ -83736,10 +84397,29 @@ var SignatureBridge = class {
|
|
|
83736
84397
|
res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store" });
|
|
83737
84398
|
res.end(JSON.stringify({ network: this.network ?? null }));
|
|
83738
84399
|
}
|
|
84400
|
+
/** The origin this bridge is served from — what a presence statement names. */
|
|
84401
|
+
publicOrigin() {
|
|
84402
|
+
return this.mount ? this.mount.origin : `http://127.0.0.1:${this.port}`;
|
|
84403
|
+
}
|
|
84404
|
+
/** The presence statement for this session + chain (session-gated). The page signs exactly
|
|
84405
|
+
* this text in its wallet; the bridge rebuilds it on `hello` rather than trusting any text
|
|
84406
|
+
* the client sends back. */
|
|
84407
|
+
serveChallenge(url2, res) {
|
|
84408
|
+
const session = this.sessionOf(url2.searchParams.get("s"), res);
|
|
84409
|
+
if (!session) return;
|
|
84410
|
+
const chainId = Number(url2.searchParams.get("chainId"));
|
|
84411
|
+
if (!Number.isInteger(chainId)) {
|
|
84412
|
+
this.deny(res, 400, "challenge requires an integer chainId");
|
|
84413
|
+
return;
|
|
84414
|
+
}
|
|
84415
|
+
res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store" });
|
|
84416
|
+
res.end(JSON.stringify({ statement: presenceStatement(this.publicOrigin(), chainId, session.presenceNonce) }));
|
|
84417
|
+
}
|
|
83739
84418
|
/** WalletConnect pairing (D2, session-gated): lazily boots the WC transport and serves a
|
|
83740
84419
|
* fresh pairing URI. A wallet approving the pairing becomes THE wallet. */
|
|
83741
84420
|
async serveWcPairing(url2, res) {
|
|
83742
84421
|
if (!this.checkSession(url2.searchParams.get("s"), res)) return;
|
|
84422
|
+
const askingSession = url2.searchParams.get("s");
|
|
83743
84423
|
if (!this.wcConfig) {
|
|
83744
84424
|
this.deny(res, 404, "WalletConnect is not configured (set DH_WC_PROJECT_ID)");
|
|
83745
84425
|
return;
|
|
@@ -83754,15 +84434,22 @@ var SignatureBridge = class {
|
|
|
83754
84434
|
this.wcTransport.onSession((info) => {
|
|
83755
84435
|
const refusal = info ? this.accountRefusal(info.account) : null;
|
|
83756
84436
|
if (info && refusal) {
|
|
83757
|
-
this.wcActive
|
|
83758
|
-
|
|
83759
|
-
|
|
84437
|
+
if (!this.wcActive) {
|
|
84438
|
+
this.rebuildSharedWallet();
|
|
84439
|
+
this.demoteWcEntries();
|
|
84440
|
+
}
|
|
83760
84441
|
process.stderr.write(`[bridge] WalletConnect session refused \u2014 ${refusal}
|
|
83761
84442
|
`);
|
|
83762
|
-
return;
|
|
84443
|
+
return false;
|
|
83763
84444
|
}
|
|
83764
84445
|
this.wcActive = info !== null;
|
|
83765
84446
|
this.wallet = info ? { account: info.account, chainId: info.chainId } : null;
|
|
84447
|
+
if (info?.pairingId) {
|
|
84448
|
+
const owner = this.pairingOwners.get(info.pairingId);
|
|
84449
|
+
this.pairingOwners.delete(info.pairingId);
|
|
84450
|
+
const paired = owner ? this.sessions.get(owner) : void 0;
|
|
84451
|
+
if (paired) paired.wcPaired = true;
|
|
84452
|
+
}
|
|
83766
84453
|
if (info === null) {
|
|
83767
84454
|
for (const entry of this.pending.values()) {
|
|
83768
84455
|
if (!entry.settled && !entry.collect) {
|
|
@@ -83775,7 +84462,15 @@ var SignatureBridge = class {
|
|
|
83775
84462
|
}
|
|
83776
84463
|
});
|
|
83777
84464
|
}
|
|
83778
|
-
const { uri } = await this.wcTransport.createPairing();
|
|
84465
|
+
const { uri, pairingId } = await this.wcTransport.createPairing();
|
|
84466
|
+
if (pairingId) {
|
|
84467
|
+
this.pairingOwners.set(pairingId, askingSession);
|
|
84468
|
+
while (this.pairingOwners.size > MAX_PENDING_PAIRINGS) {
|
|
84469
|
+
const oldest = this.pairingOwners.keys().next();
|
|
84470
|
+
if (oldest.done) break;
|
|
84471
|
+
this.pairingOwners.delete(oldest.value);
|
|
84472
|
+
}
|
|
84473
|
+
}
|
|
83779
84474
|
const { default: qrcode } = await import("qrcode-generator");
|
|
83780
84475
|
const qr = qrcode(0, "M");
|
|
83781
84476
|
qr.addData(uri);
|
|
@@ -83840,9 +84535,7 @@ var SignatureBridge = class {
|
|
|
83840
84535
|
res.write(":connected\n\n");
|
|
83841
84536
|
session.sse?.end();
|
|
83842
84537
|
session.sse = res;
|
|
83843
|
-
|
|
83844
|
-
if (!entry.settled) res.write(this.wireFor(entry));
|
|
83845
|
-
}
|
|
84538
|
+
this.replayPending(session);
|
|
83846
84539
|
const keepAlive = setInterval(() => res.write(":ka\n\n"), 2e4);
|
|
83847
84540
|
keepAlive.unref();
|
|
83848
84541
|
res.on("close", () => {
|
|
@@ -83865,8 +84558,37 @@ var SignatureBridge = class {
|
|
|
83865
84558
|
this.deny(res, 403, refusal);
|
|
83866
84559
|
return;
|
|
83867
84560
|
}
|
|
84561
|
+
const alreadyProven = session.provenAccount !== null && session.provenAccount.toLowerCase() === account.toLowerCase();
|
|
84562
|
+
if (!alreadyProven) {
|
|
84563
|
+
const signature = body["signature"];
|
|
84564
|
+
if (typeof signature !== "string" || signature === "") {
|
|
84565
|
+
this.deny(
|
|
84566
|
+
res,
|
|
84567
|
+
403,
|
|
84568
|
+
`hello requires a signature proving this page controls ${account} \u2014 an address alone proves nothing. Approve the short signing prompt in your wallet (the approval page asks for it on connect); reload the page if it did not appear.`
|
|
84569
|
+
);
|
|
84570
|
+
return;
|
|
84571
|
+
}
|
|
84572
|
+
const statement = presenceStatement(this.publicOrigin(), chainId, session.presenceNonce);
|
|
84573
|
+
let recovered = null;
|
|
84574
|
+
try {
|
|
84575
|
+
recovered = import_ethers50.ethers.verifyMessage(statement, signature);
|
|
84576
|
+
} catch {
|
|
84577
|
+
recovered = null;
|
|
84578
|
+
}
|
|
84579
|
+
if (recovered === null || recovered.toLowerCase() !== account.toLowerCase()) {
|
|
84580
|
+
this.deny(
|
|
84581
|
+
res,
|
|
84582
|
+
403,
|
|
84583
|
+
`the presence signature was not made by ${account} for this page's statement \u2014 sign the statement the approval page shows with that account (EOA wallets only; contract wallets cannot prove presence here).`
|
|
84584
|
+
);
|
|
84585
|
+
return;
|
|
84586
|
+
}
|
|
84587
|
+
session.provenAccount = account;
|
|
84588
|
+
}
|
|
83868
84589
|
session.wallet = { account, chainId };
|
|
83869
84590
|
this.wallet = { account, chainId };
|
|
84591
|
+
this.replayPending(session);
|
|
83870
84592
|
this.ok(res);
|
|
83871
84593
|
}
|
|
83872
84594
|
/** C-47: the single predicate every wallet account is admitted through. There are THREE
|
|
@@ -83905,17 +84627,21 @@ var SignatureBridge = class {
|
|
|
83905
84627
|
if (refusedSwitch) {
|
|
83906
84628
|
this.quarantine(session, switchRefusal);
|
|
83907
84629
|
} else {
|
|
83908
|
-
session.
|
|
84630
|
+
const sameProven = offered !== null && session.provenAccount !== null && offered.account.toLowerCase() === session.provenAccount.toLowerCase();
|
|
84631
|
+
session.wallet = sameProven ? offered : null;
|
|
83909
84632
|
if (this.wallet !== null && prev !== null && this.wallet.account.toLowerCase() === prev.account.toLowerCase()) {
|
|
83910
84633
|
this.wallet = session.wallet;
|
|
84634
|
+
} else if (this.wallet === null && prev === null && session.wallet !== null) {
|
|
84635
|
+
this.wallet = session.wallet;
|
|
83911
84636
|
}
|
|
83912
84637
|
}
|
|
83913
|
-
const
|
|
83914
|
-
|
|
84638
|
+
const reported = refusedSwitch ? null : offered;
|
|
84639
|
+
const unchanged = prev !== null && reported !== null && prev.account.toLowerCase() === reported.account.toLowerCase() && prev.chainId === reported.chainId;
|
|
84640
|
+
if (unchanged || prev === null) {
|
|
83915
84641
|
this.ok(res);
|
|
83916
84642
|
return;
|
|
83917
84643
|
}
|
|
83918
|
-
const reason = refusedSwitch ? "the wallet switched to an account this session is not signed in as" : prev &&
|
|
84644
|
+
const reason = refusedSwitch ? "the wallet switched to an account this session is not signed in as" : prev && reported && prev.account.toLowerCase() !== reported.account.toLowerCase() ? "the wallet account changed while approval was pending" : prev && reported && prev.chainId !== reported.chainId ? "the wallet network changed while approval was pending" : "the wallet disconnected while approval was pending";
|
|
83919
84645
|
for (const entry of this.pending.values()) {
|
|
83920
84646
|
if (entry.settled || entry.collect) continue;
|
|
83921
84647
|
if (this.ownedByWc(entry)) continue;
|
|
@@ -83950,12 +84676,18 @@ var SignatureBridge = class {
|
|
|
83950
84676
|
/** Click-time re-stamp (A0.9): returns the FRESH personal-sign payload for a pending
|
|
83951
84677
|
* request. Idempotent for requests without a finalize handler (payload as enqueued). */
|
|
83952
84678
|
async onFinalize(body, res) {
|
|
83953
|
-
|
|
84679
|
+
const sessionId = String(body["sessionId"] ?? "");
|
|
84680
|
+
const session = this.decidingSessionOf(body["sessionId"], res);
|
|
84681
|
+
if (!session) return;
|
|
83954
84682
|
const entry = this.pending.get(String(body["requestId"] ?? ""));
|
|
83955
84683
|
if (!entry || entry.settled) {
|
|
83956
84684
|
this.deny(res, 404, "unknown or already-settled requestId");
|
|
83957
84685
|
return;
|
|
83958
84686
|
}
|
|
84687
|
+
if (this.expireIfOverdue(entry)) {
|
|
84688
|
+
this.deny(res, 410, "this request has expired \u2014 retry the operation");
|
|
84689
|
+
return;
|
|
84690
|
+
}
|
|
83959
84691
|
if (entry.request.kind !== "personal-sign") {
|
|
83960
84692
|
this.deny(res, 400, "finalize applies only to personal-sign requests");
|
|
83961
84693
|
return;
|
|
@@ -83964,6 +84696,12 @@ var SignatureBridge = class {
|
|
|
83964
84696
|
this.deny(res, 409, "a mobile wallet is holding this approval \u2014 it is read-only here; approve or decline it in the wallet");
|
|
83965
84697
|
return;
|
|
83966
84698
|
}
|
|
84699
|
+
const holder = entry.finalizedBy ? this.sessions.get(entry.finalizedBy) : void 0;
|
|
84700
|
+
if (entry.finalizedBy && entry.finalizedBy !== sessionId && holder?.sse) {
|
|
84701
|
+
this.deny(res, 409, "another approval page is signing this request \u2014 approve it there, or close that page and retry");
|
|
84702
|
+
return;
|
|
84703
|
+
}
|
|
84704
|
+
entry.finalizedBy = sessionId;
|
|
83967
84705
|
if (entry.finalize) {
|
|
83968
84706
|
let fresh;
|
|
83969
84707
|
try {
|
|
@@ -83976,6 +84714,10 @@ var SignatureBridge = class {
|
|
|
83976
84714
|
this.deny(res, 404, "request settled while finalizing");
|
|
83977
84715
|
return;
|
|
83978
84716
|
}
|
|
84717
|
+
if (this.expireIfOverdue(entry)) {
|
|
84718
|
+
this.deny(res, 410, "this request expired while its payload was being prepared \u2014 retry the operation");
|
|
84719
|
+
return;
|
|
84720
|
+
}
|
|
83979
84721
|
entry.request.personalSign = fresh.personalSign;
|
|
83980
84722
|
entry.request.card = fresh.card;
|
|
83981
84723
|
}
|
|
@@ -83983,12 +84725,16 @@ var SignatureBridge = class {
|
|
|
83983
84725
|
res.end(JSON.stringify({ request: entry.request }));
|
|
83984
84726
|
}
|
|
83985
84727
|
onResult(body, res) {
|
|
83986
|
-
if (!this.
|
|
84728
|
+
if (!this.decidingSessionOf(body["sessionId"], res)) return;
|
|
83987
84729
|
const entry = this.pending.get(String(body["requestId"] ?? ""));
|
|
83988
84730
|
if (!entry || entry.settled) {
|
|
83989
84731
|
this.deny(res, 404, "unknown or already-settled requestId");
|
|
83990
84732
|
return;
|
|
83991
84733
|
}
|
|
84734
|
+
if (this.expireIfOverdue(entry)) {
|
|
84735
|
+
this.deny(res, 410, "this request has expired \u2014 retry the operation");
|
|
84736
|
+
return;
|
|
84737
|
+
}
|
|
83992
84738
|
if (body["approved"] !== true) {
|
|
83993
84739
|
if (this.ownedByWc(entry) && entry.request.kind === "transaction") {
|
|
83994
84740
|
this.settle(entry, {
|
|
@@ -84037,6 +84783,16 @@ var SignatureBridge = class {
|
|
|
84037
84783
|
this.ok(res);
|
|
84038
84784
|
}
|
|
84039
84785
|
// ---- helpers ----
|
|
84786
|
+
/** Accept-time deadline check. The 1 s sweep is only the backstop: between the deadline and
|
|
84787
|
+
* the next tick a late click on /finalize or /result — or a WalletConnect dispatch — would
|
|
84788
|
+
* otherwise still ask for or accept a signature over a payload the protocol will refuse.
|
|
84789
|
+
* Settles the entry `expired` (the same outcome the sweep gives) and reports it. */
|
|
84790
|
+
expireIfOverdue(entry) {
|
|
84791
|
+
if (entry.settled) return true;
|
|
84792
|
+
if (this.clock() < entry.deadlineMs) return false;
|
|
84793
|
+
this.settle(entry, { status: "expired" });
|
|
84794
|
+
return true;
|
|
84795
|
+
}
|
|
84040
84796
|
settle(entry, outcome) {
|
|
84041
84797
|
entry.settled = true;
|
|
84042
84798
|
this.pending.delete(entry.request.id);
|
|
@@ -84056,7 +84812,7 @@ var SignatureBridge = class {
|
|
|
84056
84812
|
/** Broadcast a pending entry to EVERY open page (multi-owner links — plan 06 §1.5). */
|
|
84057
84813
|
pushEntry(entry) {
|
|
84058
84814
|
const data = this.wireFor(entry);
|
|
84059
|
-
for (const s of this.sessions.values()) if (
|
|
84815
|
+
for (const s of this.sessions.values()) if (this.authorized(s)) s.sse?.write(data);
|
|
84060
84816
|
}
|
|
84061
84817
|
/** Progress goes out as a NAMED event so `es.onmessage` request handling never sees it. */
|
|
84062
84818
|
pushProgress(payload) {
|
|
@@ -84064,7 +84820,51 @@ var SignatureBridge = class {
|
|
|
84064
84820
|
data: ${JSON.stringify(payload)}
|
|
84065
84821
|
|
|
84066
84822
|
`;
|
|
84067
|
-
for (const s of this.sessions.values()) if (
|
|
84823
|
+
for (const s of this.sessions.values()) if (this.authorized(s)) s.sse?.write(data);
|
|
84824
|
+
}
|
|
84825
|
+
/** Replay every undecided card to ONE session — used when a session becomes authorized
|
|
84826
|
+
* (hello) after its stream was already open, which is the ordinary page order: the page
|
|
84827
|
+
* attaches its EventSource, then the wallet prompt resolves. Without this the newly
|
|
84828
|
+
* connected page would sit blank until the next push. */
|
|
84829
|
+
replayPending(session) {
|
|
84830
|
+
if (!session.sse || !this.authorized(session)) return;
|
|
84831
|
+
for (const entry of this.pending.values()) {
|
|
84832
|
+
if (!entry.settled) session.sse.write(this.wireFor(entry));
|
|
84833
|
+
}
|
|
84834
|
+
}
|
|
84835
|
+
/** Retire quarantined sessions that hold no stream. Always safe: a refused session is
|
|
84836
|
+
* denied on every route anyway, so keeping it costs a slot and buys nothing. */
|
|
84837
|
+
evictDeadSessions() {
|
|
84838
|
+
for (const [id, s] of this.sessions) if (s.refused && !s.sse) this.sessions.delete(id);
|
|
84839
|
+
}
|
|
84840
|
+
/**
|
|
84841
|
+
* Free a slot for an incoming page load when the ceiling is reached.
|
|
84842
|
+
*
|
|
84843
|
+
* MAX_SESSIONS was a ceiling with NO eviction — nothing but `close()` ever removed a
|
|
84844
|
+
* session — and every page load mints one (a reload is a new session). A long-lived
|
|
84845
|
+
* hosted bridge therefore reached 16 through ordinary use and 429'd the user out of
|
|
84846
|
+
* approving their own ceremonies, permanently, with "close one and retry" as the advice
|
|
84847
|
+
* for pages that were already closed.
|
|
84848
|
+
*
|
|
84849
|
+
* Eviction is ON DEMAND and never touches a session with a live SSE stream: that stream
|
|
84850
|
+
* is a page open in a browser right now, and the C1 contract is that live sessions
|
|
84851
|
+
* survive. Among the streamless it takes the least recently seen — the closed tab.
|
|
84852
|
+
*/
|
|
84853
|
+
makeRoomForSession() {
|
|
84854
|
+
this.evictDeadSessions();
|
|
84855
|
+
while (this.sessions.size >= MAX_SESSIONS) {
|
|
84856
|
+
let oldestId = null;
|
|
84857
|
+
let oldestSeen = Infinity;
|
|
84858
|
+
for (const [id, s] of this.sessions) {
|
|
84859
|
+
if (s.sse) continue;
|
|
84860
|
+
if (s.lastSeenMs < oldestSeen) {
|
|
84861
|
+
oldestSeen = s.lastSeenMs;
|
|
84862
|
+
oldestId = id;
|
|
84863
|
+
}
|
|
84864
|
+
}
|
|
84865
|
+
if (oldestId === null) return;
|
|
84866
|
+
this.sessions.delete(oldestId);
|
|
84867
|
+
}
|
|
84068
84868
|
}
|
|
84069
84869
|
/**
|
|
84070
84870
|
* C-47: `this.wallet` is DERIVED, never guessed.
|
|
@@ -84107,12 +84907,46 @@ data: ${JSON.stringify(payload)}
|
|
|
84107
84907
|
}
|
|
84108
84908
|
this.rebuildSharedWallet();
|
|
84109
84909
|
}
|
|
84910
|
+
/**
|
|
84911
|
+
* A session that may SEE cards and DECIDE them — one where a PERSON has proven to be at
|
|
84912
|
+
* the page: `hello` with an admissible account, or a WalletConnect pairing a wallet
|
|
84913
|
+
* actually answered (`wcPaired`).
|
|
84914
|
+
*
|
|
84915
|
+
* `sessionOf` only ever asked "does this session id exist and is it un-quarantined". A
|
|
84916
|
+
* session id is minted by LOADING the page, and on the hosted tier the mount URL travels
|
|
84917
|
+
* through the conversation by design — so anyone holding it could mint a session, never
|
|
84918
|
+
* connect a wallet, and still receive every approval card on /events (the card is the
|
|
84919
|
+
* operation in readable form: position, destination, amounts) and still POST /result to
|
|
84920
|
+
* decline, or /finalize to re-stamp, someone else's ceremony. Quarantine never caught
|
|
84921
|
+
* them: it fires on an OFFERED account, and they offered none.
|
|
84922
|
+
*
|
|
84923
|
+
* Opening the stream without a wallet stays legal — that is how the real page bootstraps
|
|
84924
|
+
* before the user connects. It simply receives nothing and decides nothing until it has
|
|
84925
|
+
* connected. Requesting a pairing is likewise not enough: anyone with the link can ask
|
|
84926
|
+
* for a QR, so only a pairing a WALLET ANSWERED counts.
|
|
84927
|
+
*/
|
|
84928
|
+
authorized(session) {
|
|
84929
|
+
if (session.refused) return false;
|
|
84930
|
+
if (session.wallet) return this.accountRefusal(session.wallet.account) === null;
|
|
84931
|
+
return session.wcPaired;
|
|
84932
|
+
}
|
|
84933
|
+
/** `sessionOf`, plus the wallet binding above — for the routes that decide a ceremony. */
|
|
84934
|
+
decidingSessionOf(candidate, res) {
|
|
84935
|
+
const session = this.sessionOf(candidate, res);
|
|
84936
|
+
if (!session) return null;
|
|
84937
|
+
if (!this.authorized(session)) {
|
|
84938
|
+
this.deny(res, 403, "connect your wallet on this page before approving, declining or finalizing a request");
|
|
84939
|
+
return null;
|
|
84940
|
+
}
|
|
84941
|
+
return session;
|
|
84942
|
+
}
|
|
84110
84943
|
sessionOf(candidate, res) {
|
|
84111
84944
|
const session = typeof candidate === "string" ? this.sessions.get(candidate) ?? null : null;
|
|
84112
84945
|
if (!session) {
|
|
84113
84946
|
this.deny(res, 403, "missing or wrong session");
|
|
84114
84947
|
return null;
|
|
84115
84948
|
}
|
|
84949
|
+
session.lastSeenMs = this.clock();
|
|
84116
84950
|
if (session.refused) {
|
|
84117
84951
|
this.deny(res, 403, session.refused);
|
|
84118
84952
|
return null;
|
|
@@ -84550,6 +85384,7 @@ async function createRealBoundary(config, wallet, overrides) {
|
|
|
84550
85384
|
const manager = new SignerManager({
|
|
84551
85385
|
persistence: overrides?.signerPersistence?.(config.network) ?? fileSignerPersistence(stateFile),
|
|
84552
85386
|
initialMode,
|
|
85387
|
+
...overrides?.boundBorrower ? { authenticatedBorrower: import_ethers51.ethers.getAddress(overrides.boundBorrower) } : {},
|
|
84553
85388
|
candidate: () => bridge.walletState()?.account ?? null,
|
|
84554
85389
|
pendingCeremonies: () => bridge.pendingCount(),
|
|
84555
85390
|
keystore
|