@gvnrdao/dh-sdk 0.0.114 → 0.0.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +240 -7
- package/dist/index.mjs +240 -7
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -42394,6 +42394,18 @@ var PKPAuthorization = class {
|
|
|
42394
42394
|
constructor(config) {
|
|
42395
42395
|
this.config = config;
|
|
42396
42396
|
this.timeoutMs = config.timeoutMs || 6e4;
|
|
42397
|
+
console.log("[PKP-AUTH] Constructor - contractAddresses received", {
|
|
42398
|
+
hasContractAddresses: !!this.config.contractAddresses,
|
|
42399
|
+
keys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
42400
|
+
hasPositionManager: !!this.config.contractAddresses?.positionManager,
|
|
42401
|
+
hasLoanOperationsManager: !!this.config.contractAddresses?.loanOperationsManager,
|
|
42402
|
+
hasTermManager: !!this.config.contractAddresses?.termManager,
|
|
42403
|
+
hasUcdController: !!this.config.contractAddresses?.ucdController,
|
|
42404
|
+
positionManager: this.config.contractAddresses?.positionManager || "MISSING",
|
|
42405
|
+
loanOperationsManager: this.config.contractAddresses?.loanOperationsManager || "MISSING",
|
|
42406
|
+
termManager: this.config.contractAddresses?.termManager || "MISSING",
|
|
42407
|
+
ucdController: this.config.contractAddresses?.ucdController || "MISSING"
|
|
42408
|
+
});
|
|
42397
42409
|
this.validateConfig();
|
|
42398
42410
|
this.configureCapacityDelegation();
|
|
42399
42411
|
}
|
|
@@ -42567,6 +42579,12 @@ var PKPAuthorization = class {
|
|
|
42567
42579
|
* @returns Mint authorization response
|
|
42568
42580
|
*/
|
|
42569
42581
|
async authorizeMintUCD(params, pkpPublicKey, auth, pkpTokenId, pkpEthAddress) {
|
|
42582
|
+
console.log("[PKP-AUTH] authorizeMintUCD called", {
|
|
42583
|
+
positionId: params.positionId,
|
|
42584
|
+
hasConfig: !!this.config,
|
|
42585
|
+
hasContractAddresses: !!this.config?.contractAddresses,
|
|
42586
|
+
debug: this.config?.debug
|
|
42587
|
+
});
|
|
42570
42588
|
if (this.config.debug) {
|
|
42571
42589
|
log.info("\u{1F510} Authorizing mint UCD", {
|
|
42572
42590
|
positionId: params.positionId,
|
|
@@ -42680,6 +42698,14 @@ var PKPAuthorization = class {
|
|
|
42680
42698
|
"final chainStr": chainStr
|
|
42681
42699
|
});
|
|
42682
42700
|
}
|
|
42701
|
+
console.log("[PKP-AUTH] Contract addresses check (BEFORE mapping):", {
|
|
42702
|
+
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
42703
|
+
configContractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
42704
|
+
positionManager: this.config.contractAddresses?.positionManager || "MISSING",
|
|
42705
|
+
loanOperationsManager: this.config.contractAddresses?.loanOperationsManager || "MISSING",
|
|
42706
|
+
termManager: this.config.contractAddresses?.termManager || "MISSING",
|
|
42707
|
+
ucdController: this.config.contractAddresses?.ucdController || "MISSING"
|
|
42708
|
+
});
|
|
42683
42709
|
if (this.config.debug) {
|
|
42684
42710
|
log.info("\u{1F50D} PKPAuthorization contract addresses check:", {
|
|
42685
42711
|
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
@@ -42691,6 +42717,14 @@ var PKPAuthorization = class {
|
|
|
42691
42717
|
});
|
|
42692
42718
|
}
|
|
42693
42719
|
const contractAddresses = this.mapContractAddressesToLitActionFormat(this.config.contractAddresses);
|
|
42720
|
+
console.log("[PKP-AUTH] Contract addresses check (AFTER mapping):", {
|
|
42721
|
+
hasMappedAddresses: !!contractAddresses,
|
|
42722
|
+
mappedKeys: contractAddresses ? Object.keys(contractAddresses) : [],
|
|
42723
|
+
PositionManager: contractAddresses?.PositionManager || "MISSING",
|
|
42724
|
+
LoanOperationsManagerModule: contractAddresses?.LoanOperationsManagerModule || "MISSING",
|
|
42725
|
+
TermManagerModule: contractAddresses?.TermManagerModule || "MISSING",
|
|
42726
|
+
UCDController: contractAddresses?.UCDController || "MISSING"
|
|
42727
|
+
});
|
|
42694
42728
|
const requiredContracts = ["PositionManager", "LoanOperationsManagerModule", "TermManagerModule", "UCDController"];
|
|
42695
42729
|
if (contractAddresses) {
|
|
42696
42730
|
const missingContracts = requiredContracts.filter((contract) => !contractAddresses[contract]);
|
|
@@ -42750,6 +42784,14 @@ var PKPAuthorization = class {
|
|
|
42750
42784
|
if (hasRequiredContracts) {
|
|
42751
42785
|
jsParams["contracts"] = contractAddresses;
|
|
42752
42786
|
jsParams["contractAddresses"] = contractAddresses;
|
|
42787
|
+
console.log("[PKP-AUTH] \u2705 Contract addresses INCLUDED in jsParams:", {
|
|
42788
|
+
contracts: Object.keys(contractAddresses),
|
|
42789
|
+
contractCount: Object.keys(contractAddresses).length,
|
|
42790
|
+
PositionManager: contractAddresses.PositionManager || "MISSING",
|
|
42791
|
+
LoanOperationsManagerModule: contractAddresses.LoanOperationsManagerModule || "MISSING",
|
|
42792
|
+
TermManagerModule: contractAddresses.TermManagerModule || "MISSING",
|
|
42793
|
+
UCDController: contractAddresses.UCDController || "MISSING"
|
|
42794
|
+
});
|
|
42753
42795
|
if (this.config.debug) {
|
|
42754
42796
|
log.info("\u{1F4CB} Contract addresses included in jsParams:", {
|
|
42755
42797
|
contracts: Object.keys(contractAddresses),
|
|
@@ -42766,6 +42808,13 @@ var PKPAuthorization = class {
|
|
|
42766
42808
|
}
|
|
42767
42809
|
} else {
|
|
42768
42810
|
const missingRequired = contractAddresses ? requiredContractsForLIT.filter((contract) => !contractAddresses[contract] || contractAddresses[contract].trim() === "") : requiredContractsForLIT;
|
|
42811
|
+
console.error("[PKP-AUTH] \u274C CRITICAL: Required contract addresses MISSING!", {
|
|
42812
|
+
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
42813
|
+
configContractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
42814
|
+
mappedResult: contractAddresses,
|
|
42815
|
+
missingRequiredContracts: missingRequired,
|
|
42816
|
+
availableContracts: contractAddresses ? Object.keys(contractAddresses) : []
|
|
42817
|
+
});
|
|
42769
42818
|
log.error("\u274C CRITICAL: Required contract addresses missing - LIT Action will fail!", {
|
|
42770
42819
|
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
42771
42820
|
configContractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
@@ -42776,11 +42825,79 @@ var PKPAuthorization = class {
|
|
|
42776
42825
|
if (contractAddresses && Object.keys(contractAddresses).length > 0) {
|
|
42777
42826
|
jsParams["contracts"] = contractAddresses;
|
|
42778
42827
|
jsParams["contractAddresses"] = contractAddresses;
|
|
42828
|
+
console.warn("[PKP-AUTH] \u26A0\uFE0F Passing incomplete contract addresses - LIT Action may fail");
|
|
42779
42829
|
log.warn("\u26A0\uFE0F Passing incomplete contract addresses - LIT Action may fail");
|
|
42780
42830
|
} else {
|
|
42831
|
+
console.error("[PKP-AUTH] \u274C No contract addresses to pass - LIT Action will definitely fail with toLowerCase error");
|
|
42781
42832
|
log.error("\u274C No contract addresses to pass - LIT Action will definitely fail with toLowerCase error");
|
|
42782
42833
|
}
|
|
42783
42834
|
}
|
|
42835
|
+
if (this.config.debug) {
|
|
42836
|
+
log.info("\u{1F4E4} Complete jsParams being sent to LIT Action:", {
|
|
42837
|
+
jsParamsKeys: Object.keys(jsParams),
|
|
42838
|
+
jsParamsCount: Object.keys(jsParams).length,
|
|
42839
|
+
// Log all params with sanitized sensitive data
|
|
42840
|
+
chain: jsParams["chain"],
|
|
42841
|
+
bitcoinProviderUrl: jsParams["bitcoinProviderUrl"] ? "PROVIDED" : "NOT PROVIDED",
|
|
42842
|
+
amount: jsParams["amount"],
|
|
42843
|
+
publicKey: jsParams["publicKey"] ? `${jsParams["publicKey"].substring(0, 20)}...` : "NOT PROVIDED",
|
|
42844
|
+
ipfsId: jsParams["ipfsId"],
|
|
42845
|
+
pkpTokenId: jsParams["pkpTokenId"] || "NOT PROVIDED",
|
|
42846
|
+
rpcUrl: jsParams["rpcUrl"] ? "PROVIDED" : "NOT PROVIDED",
|
|
42847
|
+
contracts: jsParams["contracts"] ? {
|
|
42848
|
+
keys: Object.keys(jsParams["contracts"]),
|
|
42849
|
+
count: Object.keys(jsParams["contracts"]).length,
|
|
42850
|
+
PositionManager: jsParams["contracts"]?.PositionManager || "MISSING",
|
|
42851
|
+
LoanOperationsManagerModule: jsParams["contracts"]?.LoanOperationsManagerModule || "MISSING",
|
|
42852
|
+
TermManagerModule: jsParams["contracts"]?.TermManagerModule || "MISSING",
|
|
42853
|
+
UCDController: jsParams["contracts"]?.UCDController || "MISSING"
|
|
42854
|
+
} : "NOT PROVIDED",
|
|
42855
|
+
contractAddresses: jsParams["contractAddresses"] ? {
|
|
42856
|
+
keys: Object.keys(jsParams["contractAddresses"]),
|
|
42857
|
+
count: Object.keys(jsParams["contractAddresses"]).length
|
|
42858
|
+
} : "NOT PROVIDED",
|
|
42859
|
+
// Log full auth object structure (without signature value)
|
|
42860
|
+
auth: jsParams["auth"] ? {
|
|
42861
|
+
positionId: jsParams["auth"]?.positionId,
|
|
42862
|
+
timestamp: jsParams["auth"]?.timestamp,
|
|
42863
|
+
chainId: jsParams["auth"]?.chainId,
|
|
42864
|
+
amount: jsParams["auth"]?.amount,
|
|
42865
|
+
action: jsParams["auth"]?.action,
|
|
42866
|
+
mode: jsParams["auth"]?.mode,
|
|
42867
|
+
hasSignature: !!jsParams["auth"]?.signature
|
|
42868
|
+
} : "NOT PROVIDED"
|
|
42869
|
+
});
|
|
42870
|
+
const sanitizedParams = { ...jsParams };
|
|
42871
|
+
if (sanitizedParams["auth"] && typeof sanitizedParams["auth"] === "object") {
|
|
42872
|
+
const auth2 = sanitizedParams["auth"];
|
|
42873
|
+
sanitizedParams["auth"] = {
|
|
42874
|
+
...auth2,
|
|
42875
|
+
signature: auth2.signature ? `${auth2.signature.substring(0, 20)}...` : void 0
|
|
42876
|
+
};
|
|
42877
|
+
}
|
|
42878
|
+
if (typeof sanitizedParams["publicKey"] === "string") {
|
|
42879
|
+
sanitizedParams["publicKey"] = `${sanitizedParams["publicKey"].substring(0, 20)}...`;
|
|
42880
|
+
}
|
|
42881
|
+
log.info("\u{1F4E4} Complete jsParams (sanitized JSON):", JSON.stringify(sanitizedParams, null, 2));
|
|
42882
|
+
}
|
|
42883
|
+
console.log("[PKP-AUTH] FINAL jsParams being sent to LIT Action", {
|
|
42884
|
+
hasContracts: !!jsParams.contracts,
|
|
42885
|
+
hasContractAddresses: !!jsParams.contractAddresses,
|
|
42886
|
+
contractsKeys: jsParams.contracts ? Object.keys(jsParams.contracts) : [],
|
|
42887
|
+
contractAddressesKeys: jsParams.contractAddresses ? Object.keys(jsParams.contractAddresses) : [],
|
|
42888
|
+
contractsPositionManager: jsParams.contracts ? jsParams.contracts?.PositionManager || "MISSING" : "NOT PROVIDED",
|
|
42889
|
+
contractsLoanOps: jsParams.contracts ? jsParams.contracts?.LoanOperationsManagerModule || "MISSING" : "NOT PROVIDED",
|
|
42890
|
+
contractsTermManager: jsParams.contracts ? jsParams.contracts?.TermManagerModule || "MISSING" : "NOT PROVIDED",
|
|
42891
|
+
contractsUcdController: jsParams.contracts ? jsParams.contracts?.UCDController || "MISSING" : "NOT PROVIDED",
|
|
42892
|
+
contractAddressesPositionManager: jsParams.contractAddresses ? jsParams.contractAddresses?.PositionManager || "MISSING" : "NOT PROVIDED",
|
|
42893
|
+
contractAddressesLoanOps: jsParams.contractAddresses ? jsParams.contractAddresses?.LoanOperationsManagerModule || "MISSING" : "NOT PROVIDED",
|
|
42894
|
+
contractAddressesTermManager: jsParams.contractAddresses ? jsParams.contractAddresses?.TermManagerModule || "MISSING" : "NOT PROVIDED",
|
|
42895
|
+
contractAddressesUcdController: jsParams.contractAddresses ? jsParams.contractAddresses?.UCDController || "MISSING" : "NOT PROVIDED",
|
|
42896
|
+
hasChain: !!jsParams.chain,
|
|
42897
|
+
hasAuth: !!jsParams.auth,
|
|
42898
|
+
hasPublicKey: !!jsParams.publicKey,
|
|
42899
|
+
hasRpcUrl: !!jsParams.rpcUrl
|
|
42900
|
+
});
|
|
42784
42901
|
const litResult = await this.executeLitAction(pkpPublicKey, jsParams, pkpTokenId, pkpEthAddress);
|
|
42785
42902
|
if (!litResult.success) {
|
|
42786
42903
|
return litResult;
|
|
@@ -43479,14 +43596,59 @@ var PKPAuthorization = class {
|
|
|
43479
43596
|
...formattedPkpTokenId ? { pkpTokenId: formattedPkpTokenId } : {}
|
|
43480
43597
|
};
|
|
43481
43598
|
if (this.config.debug) {
|
|
43482
|
-
log.info("\u{1F4E4} Service request body:", {
|
|
43599
|
+
log.info("\u{1F4E4} Service request body (summary):", {
|
|
43483
43600
|
ipfsId: requestBody.ipfsId,
|
|
43484
43601
|
pkpPublicKey: formattedPkpPublicKey.substring(0, 20) + "...",
|
|
43485
43602
|
pkpTokenId: formattedPkpTokenId || "NOT PROVIDED",
|
|
43486
43603
|
pkpTokenIdOriginal: pkpTokenId || "NOT PROVIDED",
|
|
43487
43604
|
pkpTokenIdFormatted: formattedPkpTokenId ? `${formattedPkpTokenId.length} chars (hex)` : "NOT PROVIDED",
|
|
43488
|
-
paramsKeys: Object.keys(jsParams)
|
|
43605
|
+
paramsKeys: Object.keys(jsParams),
|
|
43606
|
+
paramsCount: Object.keys(jsParams).length
|
|
43489
43607
|
});
|
|
43608
|
+
log.info("\u{1F4E4} Complete jsParams being sent to service (for LIT Action):", {
|
|
43609
|
+
jsParamsKeys: Object.keys(jsParams),
|
|
43610
|
+
jsParamsCount: Object.keys(jsParams).length,
|
|
43611
|
+
chain: jsParams["chain"],
|
|
43612
|
+
bitcoinProviderUrl: jsParams["bitcoinProviderUrl"] ? "PROVIDED" : "NOT PROVIDED",
|
|
43613
|
+
amount: jsParams["amount"],
|
|
43614
|
+
publicKey: jsParams["publicKey"] ? `${jsParams["publicKey"].substring(0, 20)}...` : "NOT PROVIDED",
|
|
43615
|
+
ipfsId: jsParams["ipfsId"],
|
|
43616
|
+
pkpTokenId: jsParams["pkpTokenId"] || "NOT PROVIDED",
|
|
43617
|
+
rpcUrl: jsParams["rpcUrl"] ? "PROVIDED" : "NOT PROVIDED",
|
|
43618
|
+
contracts: jsParams["contracts"] ? {
|
|
43619
|
+
keys: Object.keys(jsParams["contracts"]),
|
|
43620
|
+
count: Object.keys(jsParams["contracts"]).length,
|
|
43621
|
+
PositionManager: jsParams["contracts"]?.PositionManager || "MISSING",
|
|
43622
|
+
LoanOperationsManagerModule: jsParams["contracts"]?.LoanOperationsManagerModule || "MISSING",
|
|
43623
|
+
TermManagerModule: jsParams["contracts"]?.TermManagerModule || "MISSING",
|
|
43624
|
+
UCDController: jsParams["contracts"]?.UCDController || "MISSING"
|
|
43625
|
+
} : "NOT PROVIDED",
|
|
43626
|
+
contractAddresses: jsParams["contractAddresses"] ? {
|
|
43627
|
+
keys: Object.keys(jsParams["contractAddresses"]),
|
|
43628
|
+
count: Object.keys(jsParams["contractAddresses"]).length
|
|
43629
|
+
} : "NOT PROVIDED",
|
|
43630
|
+
auth: jsParams["auth"] ? {
|
|
43631
|
+
positionId: jsParams["auth"]?.positionId,
|
|
43632
|
+
timestamp: jsParams["auth"]?.timestamp,
|
|
43633
|
+
chainId: jsParams["auth"]?.chainId,
|
|
43634
|
+
amount: jsParams["auth"]?.amount,
|
|
43635
|
+
action: jsParams["auth"]?.action,
|
|
43636
|
+
mode: jsParams["auth"]?.mode,
|
|
43637
|
+
hasSignature: !!jsParams["auth"]?.signature
|
|
43638
|
+
} : "NOT PROVIDED"
|
|
43639
|
+
});
|
|
43640
|
+
const sanitizedParams = { ...jsParams };
|
|
43641
|
+
if (sanitizedParams["auth"] && typeof sanitizedParams["auth"] === "object") {
|
|
43642
|
+
const auth = sanitizedParams["auth"];
|
|
43643
|
+
sanitizedParams["auth"] = {
|
|
43644
|
+
...auth,
|
|
43645
|
+
signature: auth.signature ? `${auth.signature.substring(0, 20)}...` : void 0
|
|
43646
|
+
};
|
|
43647
|
+
}
|
|
43648
|
+
if (typeof sanitizedParams["publicKey"] === "string") {
|
|
43649
|
+
sanitizedParams["publicKey"] = `${sanitizedParams["publicKey"].substring(0, 20)}...`;
|
|
43650
|
+
}
|
|
43651
|
+
log.info("\u{1F4E4} Complete jsParams (sanitized JSON):", JSON.stringify(sanitizedParams, null, 2));
|
|
43490
43652
|
}
|
|
43491
43653
|
const response = await fetch(url, {
|
|
43492
43654
|
method: "POST",
|
|
@@ -43703,16 +43865,39 @@ var PKPAuthorization = class {
|
|
|
43703
43865
|
);
|
|
43704
43866
|
}
|
|
43705
43867
|
const formattedPkpPublicKey = pkpPublicKey?.startsWith("0x") ? pkpPublicKey.slice(2) : pkpPublicKey;
|
|
43868
|
+
const finalJsParams = {
|
|
43869
|
+
...jsParams,
|
|
43870
|
+
publicKey: formattedPkpPublicKey,
|
|
43871
|
+
ipfsId: cid
|
|
43872
|
+
};
|
|
43873
|
+
if (this.config.debug) {
|
|
43874
|
+
log.info("\u{1F680} Final jsParams being sent to LIT Protocol (IPFS execution):", {
|
|
43875
|
+
ipfsId: cid,
|
|
43876
|
+
jsParamsKeys: Object.keys(finalJsParams),
|
|
43877
|
+
jsParamsCount: Object.keys(finalJsParams).length,
|
|
43878
|
+
contracts: finalJsParams["contracts"] ? {
|
|
43879
|
+
keys: Object.keys(finalJsParams["contracts"]),
|
|
43880
|
+
PositionManager: finalJsParams["contracts"]?.PositionManager || "MISSING",
|
|
43881
|
+
LoanOperationsManagerModule: finalJsParams["contracts"]?.LoanOperationsManagerModule || "MISSING",
|
|
43882
|
+
TermManagerModule: finalJsParams["contracts"]?.TermManagerModule || "MISSING",
|
|
43883
|
+
UCDController: finalJsParams["contracts"]?.UCDController || "MISSING"
|
|
43884
|
+
} : "NOT PROVIDED",
|
|
43885
|
+
contractAddresses: finalJsParams["contractAddresses"] ? {
|
|
43886
|
+
keys: Object.keys(finalJsParams["contractAddresses"])
|
|
43887
|
+
} : "NOT PROVIDED",
|
|
43888
|
+
hasPublicKey: !!finalJsParams["publicKey"],
|
|
43889
|
+
publicKeyPreview: finalJsParams["publicKey"] ? `${finalJsParams["publicKey"].substring(0, 20)}...` : "MISSING",
|
|
43890
|
+
hasAuth: !!finalJsParams["auth"],
|
|
43891
|
+
chain: finalJsParams["chain"],
|
|
43892
|
+
amount: finalJsParams["amount"]
|
|
43893
|
+
});
|
|
43894
|
+
}
|
|
43706
43895
|
const result = await executeLitAction(
|
|
43707
43896
|
litClient,
|
|
43708
43897
|
{
|
|
43709
43898
|
ipfsId: cid,
|
|
43710
43899
|
sessionSigs: sessionSigsResult.sessionSigs,
|
|
43711
|
-
jsParams:
|
|
43712
|
-
...jsParams,
|
|
43713
|
-
publicKey: formattedPkpPublicKey,
|
|
43714
|
-
ipfsId: cid
|
|
43715
|
-
}
|
|
43900
|
+
jsParams: finalJsParams
|
|
43716
43901
|
},
|
|
43717
43902
|
{
|
|
43718
43903
|
maxAttempts: 1,
|
|
@@ -43828,6 +44013,18 @@ var PKPAuthorization = class {
|
|
|
43828
44013
|
}
|
|
43829
44014
|
};
|
|
43830
44015
|
function createPKPAuthorization(config) {
|
|
44016
|
+
console.log("[PKP-AUTH] createPKPAuthorization called", {
|
|
44017
|
+
hasContractAddresses: !!config.contractAddresses,
|
|
44018
|
+
contractAddressKeys: config.contractAddresses ? Object.keys(config.contractAddresses) : [],
|
|
44019
|
+
hasPositionManager: !!config.contractAddresses?.positionManager,
|
|
44020
|
+
hasLoanOperationsManager: !!config.contractAddresses?.loanOperationsManager,
|
|
44021
|
+
hasTermManager: !!config.contractAddresses?.termManager,
|
|
44022
|
+
hasUcdController: !!config.contractAddresses?.ucdController,
|
|
44023
|
+
positionManager: config.contractAddresses?.positionManager || "MISSING",
|
|
44024
|
+
loanOperationsManager: config.contractAddresses?.loanOperationsManager || "MISSING",
|
|
44025
|
+
termManager: config.contractAddresses?.termManager || "MISSING",
|
|
44026
|
+
ucdController: config.contractAddresses?.ucdController || "MISSING"
|
|
44027
|
+
});
|
|
43831
44028
|
try {
|
|
43832
44029
|
const authorization = new PKPAuthorization(config);
|
|
43833
44030
|
return success(authorization);
|
|
@@ -47632,6 +47829,17 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
47632
47829
|
timeoutMs: config.pkpServiceTimeoutMs || 48e4
|
|
47633
47830
|
// Use PKP service timeout (default 8 minutes)
|
|
47634
47831
|
});
|
|
47832
|
+
console.log("[SDK] Passing contractAddresses to createPKPAuthorization", {
|
|
47833
|
+
keys: Object.keys(config.contractAddresses || {}),
|
|
47834
|
+
hasPositionManager: !!config.contractAddresses?.positionManager,
|
|
47835
|
+
hasLoanOperationsManager: !!config.contractAddresses?.loanOperationsManager,
|
|
47836
|
+
hasTermManager: !!config.contractAddresses?.termManager,
|
|
47837
|
+
hasUcdController: !!config.contractAddresses?.ucdController,
|
|
47838
|
+
positionManager: config.contractAddresses?.positionManager || "MISSING",
|
|
47839
|
+
loanOperationsManager: config.contractAddresses?.loanOperationsManager || "MISSING",
|
|
47840
|
+
termManager: config.contractAddresses?.termManager || "MISSING",
|
|
47841
|
+
ucdController: config.contractAddresses?.ucdController || "MISSING"
|
|
47842
|
+
});
|
|
47635
47843
|
if (!pkpAuthResult.success) {
|
|
47636
47844
|
const errorDetails = pkpAuthResult.error.originalError ? ` (${pkpAuthResult.error.originalError.message})` : "";
|
|
47637
47845
|
throw new Error(
|
|
@@ -47860,6 +48068,17 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
47860
48068
|
...config.contractAddresses || {}
|
|
47861
48069
|
// User-provided individual overrides (only specified fields)
|
|
47862
48070
|
};
|
|
48071
|
+
console.log("[SDK] enrichConfigWithNetworkDefaults - contractAddresses after merge", {
|
|
48072
|
+
keys: Object.keys(enrichedConfig.contractAddresses || {}),
|
|
48073
|
+
hasPositionManager: !!enrichedConfig.contractAddresses?.positionManager,
|
|
48074
|
+
hasLoanOperationsManager: !!enrichedConfig.contractAddresses?.loanOperationsManager,
|
|
48075
|
+
hasTermManager: !!enrichedConfig.contractAddresses?.termManager,
|
|
48076
|
+
hasUcdController: !!enrichedConfig.contractAddresses?.ucdController,
|
|
48077
|
+
positionManager: enrichedConfig.contractAddresses?.positionManager || "MISSING",
|
|
48078
|
+
loanOperationsManager: enrichedConfig.contractAddresses?.loanOperationsManager || "MISSING",
|
|
48079
|
+
termManager: enrichedConfig.contractAddresses?.termManager || "MISSING",
|
|
48080
|
+
ucdController: enrichedConfig.contractAddresses?.ucdController || "MISSING"
|
|
48081
|
+
});
|
|
47863
48082
|
if (config.debug) {
|
|
47864
48083
|
log.info("\u2705 Contract addresses loaded from network config", {
|
|
47865
48084
|
overridden: Object.keys(config.contractAddresses || {}).length,
|
|
@@ -48330,6 +48549,12 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
48330
48549
|
*/
|
|
48331
48550
|
async requestMintUCD(request) {
|
|
48332
48551
|
this.ensureInitialized();
|
|
48552
|
+
console.log("[SDK] requestMintUCD called", {
|
|
48553
|
+
hasContractAddresses: !!this.config.contractAddresses,
|
|
48554
|
+
contractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
48555
|
+
positionId: request.positionId,
|
|
48556
|
+
amount: request.amount
|
|
48557
|
+
});
|
|
48333
48558
|
const MAX_RETRIES = 3;
|
|
48334
48559
|
let lastError;
|
|
48335
48560
|
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
|
|
@@ -48833,6 +49058,14 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
48833
49058
|
if (this.config.debug) {
|
|
48834
49059
|
log.info(`\u{1F550} Using fresh timestamp for authorization: ${mintAuthParams.timestamp}`);
|
|
48835
49060
|
}
|
|
49061
|
+
console.log("[SDK] About to call authorizeMintUCD", {
|
|
49062
|
+
hasPkpAuth: !!this.pkpAuthorization,
|
|
49063
|
+
configContractAddresses: Object.keys(this.config.contractAddresses || {}),
|
|
49064
|
+
hasPositionManager: !!this.config.contractAddresses?.positionManager,
|
|
49065
|
+
hasLoanOperationsManager: !!this.config.contractAddresses?.loanOperationsManager,
|
|
49066
|
+
hasTermManager: !!this.config.contractAddresses?.termManager,
|
|
49067
|
+
hasUcdController: !!this.config.contractAddresses?.ucdController
|
|
49068
|
+
});
|
|
48836
49069
|
const authResult = await this.pkpAuthorization.authorizeMintUCD(
|
|
48837
49070
|
mintAuthParams,
|
|
48838
49071
|
ucdMintValidatorPkp,
|
package/dist/index.mjs
CHANGED
|
@@ -42299,6 +42299,18 @@ var PKPAuthorization = class {
|
|
|
42299
42299
|
constructor(config) {
|
|
42300
42300
|
this.config = config;
|
|
42301
42301
|
this.timeoutMs = config.timeoutMs || 6e4;
|
|
42302
|
+
console.log("[PKP-AUTH] Constructor - contractAddresses received", {
|
|
42303
|
+
hasContractAddresses: !!this.config.contractAddresses,
|
|
42304
|
+
keys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
42305
|
+
hasPositionManager: !!this.config.contractAddresses?.positionManager,
|
|
42306
|
+
hasLoanOperationsManager: !!this.config.contractAddresses?.loanOperationsManager,
|
|
42307
|
+
hasTermManager: !!this.config.contractAddresses?.termManager,
|
|
42308
|
+
hasUcdController: !!this.config.contractAddresses?.ucdController,
|
|
42309
|
+
positionManager: this.config.contractAddresses?.positionManager || "MISSING",
|
|
42310
|
+
loanOperationsManager: this.config.contractAddresses?.loanOperationsManager || "MISSING",
|
|
42311
|
+
termManager: this.config.contractAddresses?.termManager || "MISSING",
|
|
42312
|
+
ucdController: this.config.contractAddresses?.ucdController || "MISSING"
|
|
42313
|
+
});
|
|
42302
42314
|
this.validateConfig();
|
|
42303
42315
|
this.configureCapacityDelegation();
|
|
42304
42316
|
}
|
|
@@ -42472,6 +42484,12 @@ var PKPAuthorization = class {
|
|
|
42472
42484
|
* @returns Mint authorization response
|
|
42473
42485
|
*/
|
|
42474
42486
|
async authorizeMintUCD(params, pkpPublicKey, auth, pkpTokenId, pkpEthAddress) {
|
|
42487
|
+
console.log("[PKP-AUTH] authorizeMintUCD called", {
|
|
42488
|
+
positionId: params.positionId,
|
|
42489
|
+
hasConfig: !!this.config,
|
|
42490
|
+
hasContractAddresses: !!this.config?.contractAddresses,
|
|
42491
|
+
debug: this.config?.debug
|
|
42492
|
+
});
|
|
42475
42493
|
if (this.config.debug) {
|
|
42476
42494
|
log.info("\u{1F510} Authorizing mint UCD", {
|
|
42477
42495
|
positionId: params.positionId,
|
|
@@ -42585,6 +42603,14 @@ var PKPAuthorization = class {
|
|
|
42585
42603
|
"final chainStr": chainStr
|
|
42586
42604
|
});
|
|
42587
42605
|
}
|
|
42606
|
+
console.log("[PKP-AUTH] Contract addresses check (BEFORE mapping):", {
|
|
42607
|
+
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
42608
|
+
configContractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
42609
|
+
positionManager: this.config.contractAddresses?.positionManager || "MISSING",
|
|
42610
|
+
loanOperationsManager: this.config.contractAddresses?.loanOperationsManager || "MISSING",
|
|
42611
|
+
termManager: this.config.contractAddresses?.termManager || "MISSING",
|
|
42612
|
+
ucdController: this.config.contractAddresses?.ucdController || "MISSING"
|
|
42613
|
+
});
|
|
42588
42614
|
if (this.config.debug) {
|
|
42589
42615
|
log.info("\u{1F50D} PKPAuthorization contract addresses check:", {
|
|
42590
42616
|
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
@@ -42596,6 +42622,14 @@ var PKPAuthorization = class {
|
|
|
42596
42622
|
});
|
|
42597
42623
|
}
|
|
42598
42624
|
const contractAddresses = this.mapContractAddressesToLitActionFormat(this.config.contractAddresses);
|
|
42625
|
+
console.log("[PKP-AUTH] Contract addresses check (AFTER mapping):", {
|
|
42626
|
+
hasMappedAddresses: !!contractAddresses,
|
|
42627
|
+
mappedKeys: contractAddresses ? Object.keys(contractAddresses) : [],
|
|
42628
|
+
PositionManager: contractAddresses?.PositionManager || "MISSING",
|
|
42629
|
+
LoanOperationsManagerModule: contractAddresses?.LoanOperationsManagerModule || "MISSING",
|
|
42630
|
+
TermManagerModule: contractAddresses?.TermManagerModule || "MISSING",
|
|
42631
|
+
UCDController: contractAddresses?.UCDController || "MISSING"
|
|
42632
|
+
});
|
|
42599
42633
|
const requiredContracts = ["PositionManager", "LoanOperationsManagerModule", "TermManagerModule", "UCDController"];
|
|
42600
42634
|
if (contractAddresses) {
|
|
42601
42635
|
const missingContracts = requiredContracts.filter((contract) => !contractAddresses[contract]);
|
|
@@ -42655,6 +42689,14 @@ var PKPAuthorization = class {
|
|
|
42655
42689
|
if (hasRequiredContracts) {
|
|
42656
42690
|
jsParams["contracts"] = contractAddresses;
|
|
42657
42691
|
jsParams["contractAddresses"] = contractAddresses;
|
|
42692
|
+
console.log("[PKP-AUTH] \u2705 Contract addresses INCLUDED in jsParams:", {
|
|
42693
|
+
contracts: Object.keys(contractAddresses),
|
|
42694
|
+
contractCount: Object.keys(contractAddresses).length,
|
|
42695
|
+
PositionManager: contractAddresses.PositionManager || "MISSING",
|
|
42696
|
+
LoanOperationsManagerModule: contractAddresses.LoanOperationsManagerModule || "MISSING",
|
|
42697
|
+
TermManagerModule: contractAddresses.TermManagerModule || "MISSING",
|
|
42698
|
+
UCDController: contractAddresses.UCDController || "MISSING"
|
|
42699
|
+
});
|
|
42658
42700
|
if (this.config.debug) {
|
|
42659
42701
|
log.info("\u{1F4CB} Contract addresses included in jsParams:", {
|
|
42660
42702
|
contracts: Object.keys(contractAddresses),
|
|
@@ -42671,6 +42713,13 @@ var PKPAuthorization = class {
|
|
|
42671
42713
|
}
|
|
42672
42714
|
} else {
|
|
42673
42715
|
const missingRequired = contractAddresses ? requiredContractsForLIT.filter((contract) => !contractAddresses[contract] || contractAddresses[contract].trim() === "") : requiredContractsForLIT;
|
|
42716
|
+
console.error("[PKP-AUTH] \u274C CRITICAL: Required contract addresses MISSING!", {
|
|
42717
|
+
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
42718
|
+
configContractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
42719
|
+
mappedResult: contractAddresses,
|
|
42720
|
+
missingRequiredContracts: missingRequired,
|
|
42721
|
+
availableContracts: contractAddresses ? Object.keys(contractAddresses) : []
|
|
42722
|
+
});
|
|
42674
42723
|
log.error("\u274C CRITICAL: Required contract addresses missing - LIT Action will fail!", {
|
|
42675
42724
|
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
42676
42725
|
configContractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
@@ -42681,11 +42730,79 @@ var PKPAuthorization = class {
|
|
|
42681
42730
|
if (contractAddresses && Object.keys(contractAddresses).length > 0) {
|
|
42682
42731
|
jsParams["contracts"] = contractAddresses;
|
|
42683
42732
|
jsParams["contractAddresses"] = contractAddresses;
|
|
42733
|
+
console.warn("[PKP-AUTH] \u26A0\uFE0F Passing incomplete contract addresses - LIT Action may fail");
|
|
42684
42734
|
log.warn("\u26A0\uFE0F Passing incomplete contract addresses - LIT Action may fail");
|
|
42685
42735
|
} else {
|
|
42736
|
+
console.error("[PKP-AUTH] \u274C No contract addresses to pass - LIT Action will definitely fail with toLowerCase error");
|
|
42686
42737
|
log.error("\u274C No contract addresses to pass - LIT Action will definitely fail with toLowerCase error");
|
|
42687
42738
|
}
|
|
42688
42739
|
}
|
|
42740
|
+
if (this.config.debug) {
|
|
42741
|
+
log.info("\u{1F4E4} Complete jsParams being sent to LIT Action:", {
|
|
42742
|
+
jsParamsKeys: Object.keys(jsParams),
|
|
42743
|
+
jsParamsCount: Object.keys(jsParams).length,
|
|
42744
|
+
// Log all params with sanitized sensitive data
|
|
42745
|
+
chain: jsParams["chain"],
|
|
42746
|
+
bitcoinProviderUrl: jsParams["bitcoinProviderUrl"] ? "PROVIDED" : "NOT PROVIDED",
|
|
42747
|
+
amount: jsParams["amount"],
|
|
42748
|
+
publicKey: jsParams["publicKey"] ? `${jsParams["publicKey"].substring(0, 20)}...` : "NOT PROVIDED",
|
|
42749
|
+
ipfsId: jsParams["ipfsId"],
|
|
42750
|
+
pkpTokenId: jsParams["pkpTokenId"] || "NOT PROVIDED",
|
|
42751
|
+
rpcUrl: jsParams["rpcUrl"] ? "PROVIDED" : "NOT PROVIDED",
|
|
42752
|
+
contracts: jsParams["contracts"] ? {
|
|
42753
|
+
keys: Object.keys(jsParams["contracts"]),
|
|
42754
|
+
count: Object.keys(jsParams["contracts"]).length,
|
|
42755
|
+
PositionManager: jsParams["contracts"]?.PositionManager || "MISSING",
|
|
42756
|
+
LoanOperationsManagerModule: jsParams["contracts"]?.LoanOperationsManagerModule || "MISSING",
|
|
42757
|
+
TermManagerModule: jsParams["contracts"]?.TermManagerModule || "MISSING",
|
|
42758
|
+
UCDController: jsParams["contracts"]?.UCDController || "MISSING"
|
|
42759
|
+
} : "NOT PROVIDED",
|
|
42760
|
+
contractAddresses: jsParams["contractAddresses"] ? {
|
|
42761
|
+
keys: Object.keys(jsParams["contractAddresses"]),
|
|
42762
|
+
count: Object.keys(jsParams["contractAddresses"]).length
|
|
42763
|
+
} : "NOT PROVIDED",
|
|
42764
|
+
// Log full auth object structure (without signature value)
|
|
42765
|
+
auth: jsParams["auth"] ? {
|
|
42766
|
+
positionId: jsParams["auth"]?.positionId,
|
|
42767
|
+
timestamp: jsParams["auth"]?.timestamp,
|
|
42768
|
+
chainId: jsParams["auth"]?.chainId,
|
|
42769
|
+
amount: jsParams["auth"]?.amount,
|
|
42770
|
+
action: jsParams["auth"]?.action,
|
|
42771
|
+
mode: jsParams["auth"]?.mode,
|
|
42772
|
+
hasSignature: !!jsParams["auth"]?.signature
|
|
42773
|
+
} : "NOT PROVIDED"
|
|
42774
|
+
});
|
|
42775
|
+
const sanitizedParams = { ...jsParams };
|
|
42776
|
+
if (sanitizedParams["auth"] && typeof sanitizedParams["auth"] === "object") {
|
|
42777
|
+
const auth2 = sanitizedParams["auth"];
|
|
42778
|
+
sanitizedParams["auth"] = {
|
|
42779
|
+
...auth2,
|
|
42780
|
+
signature: auth2.signature ? `${auth2.signature.substring(0, 20)}...` : void 0
|
|
42781
|
+
};
|
|
42782
|
+
}
|
|
42783
|
+
if (typeof sanitizedParams["publicKey"] === "string") {
|
|
42784
|
+
sanitizedParams["publicKey"] = `${sanitizedParams["publicKey"].substring(0, 20)}...`;
|
|
42785
|
+
}
|
|
42786
|
+
log.info("\u{1F4E4} Complete jsParams (sanitized JSON):", JSON.stringify(sanitizedParams, null, 2));
|
|
42787
|
+
}
|
|
42788
|
+
console.log("[PKP-AUTH] FINAL jsParams being sent to LIT Action", {
|
|
42789
|
+
hasContracts: !!jsParams.contracts,
|
|
42790
|
+
hasContractAddresses: !!jsParams.contractAddresses,
|
|
42791
|
+
contractsKeys: jsParams.contracts ? Object.keys(jsParams.contracts) : [],
|
|
42792
|
+
contractAddressesKeys: jsParams.contractAddresses ? Object.keys(jsParams.contractAddresses) : [],
|
|
42793
|
+
contractsPositionManager: jsParams.contracts ? jsParams.contracts?.PositionManager || "MISSING" : "NOT PROVIDED",
|
|
42794
|
+
contractsLoanOps: jsParams.contracts ? jsParams.contracts?.LoanOperationsManagerModule || "MISSING" : "NOT PROVIDED",
|
|
42795
|
+
contractsTermManager: jsParams.contracts ? jsParams.contracts?.TermManagerModule || "MISSING" : "NOT PROVIDED",
|
|
42796
|
+
contractsUcdController: jsParams.contracts ? jsParams.contracts?.UCDController || "MISSING" : "NOT PROVIDED",
|
|
42797
|
+
contractAddressesPositionManager: jsParams.contractAddresses ? jsParams.contractAddresses?.PositionManager || "MISSING" : "NOT PROVIDED",
|
|
42798
|
+
contractAddressesLoanOps: jsParams.contractAddresses ? jsParams.contractAddresses?.LoanOperationsManagerModule || "MISSING" : "NOT PROVIDED",
|
|
42799
|
+
contractAddressesTermManager: jsParams.contractAddresses ? jsParams.contractAddresses?.TermManagerModule || "MISSING" : "NOT PROVIDED",
|
|
42800
|
+
contractAddressesUcdController: jsParams.contractAddresses ? jsParams.contractAddresses?.UCDController || "MISSING" : "NOT PROVIDED",
|
|
42801
|
+
hasChain: !!jsParams.chain,
|
|
42802
|
+
hasAuth: !!jsParams.auth,
|
|
42803
|
+
hasPublicKey: !!jsParams.publicKey,
|
|
42804
|
+
hasRpcUrl: !!jsParams.rpcUrl
|
|
42805
|
+
});
|
|
42689
42806
|
const litResult = await this.executeLitAction(pkpPublicKey, jsParams, pkpTokenId, pkpEthAddress);
|
|
42690
42807
|
if (!litResult.success) {
|
|
42691
42808
|
return litResult;
|
|
@@ -43384,14 +43501,59 @@ var PKPAuthorization = class {
|
|
|
43384
43501
|
...formattedPkpTokenId ? { pkpTokenId: formattedPkpTokenId } : {}
|
|
43385
43502
|
};
|
|
43386
43503
|
if (this.config.debug) {
|
|
43387
|
-
log.info("\u{1F4E4} Service request body:", {
|
|
43504
|
+
log.info("\u{1F4E4} Service request body (summary):", {
|
|
43388
43505
|
ipfsId: requestBody.ipfsId,
|
|
43389
43506
|
pkpPublicKey: formattedPkpPublicKey.substring(0, 20) + "...",
|
|
43390
43507
|
pkpTokenId: formattedPkpTokenId || "NOT PROVIDED",
|
|
43391
43508
|
pkpTokenIdOriginal: pkpTokenId || "NOT PROVIDED",
|
|
43392
43509
|
pkpTokenIdFormatted: formattedPkpTokenId ? `${formattedPkpTokenId.length} chars (hex)` : "NOT PROVIDED",
|
|
43393
|
-
paramsKeys: Object.keys(jsParams)
|
|
43510
|
+
paramsKeys: Object.keys(jsParams),
|
|
43511
|
+
paramsCount: Object.keys(jsParams).length
|
|
43394
43512
|
});
|
|
43513
|
+
log.info("\u{1F4E4} Complete jsParams being sent to service (for LIT Action):", {
|
|
43514
|
+
jsParamsKeys: Object.keys(jsParams),
|
|
43515
|
+
jsParamsCount: Object.keys(jsParams).length,
|
|
43516
|
+
chain: jsParams["chain"],
|
|
43517
|
+
bitcoinProviderUrl: jsParams["bitcoinProviderUrl"] ? "PROVIDED" : "NOT PROVIDED",
|
|
43518
|
+
amount: jsParams["amount"],
|
|
43519
|
+
publicKey: jsParams["publicKey"] ? `${jsParams["publicKey"].substring(0, 20)}...` : "NOT PROVIDED",
|
|
43520
|
+
ipfsId: jsParams["ipfsId"],
|
|
43521
|
+
pkpTokenId: jsParams["pkpTokenId"] || "NOT PROVIDED",
|
|
43522
|
+
rpcUrl: jsParams["rpcUrl"] ? "PROVIDED" : "NOT PROVIDED",
|
|
43523
|
+
contracts: jsParams["contracts"] ? {
|
|
43524
|
+
keys: Object.keys(jsParams["contracts"]),
|
|
43525
|
+
count: Object.keys(jsParams["contracts"]).length,
|
|
43526
|
+
PositionManager: jsParams["contracts"]?.PositionManager || "MISSING",
|
|
43527
|
+
LoanOperationsManagerModule: jsParams["contracts"]?.LoanOperationsManagerModule || "MISSING",
|
|
43528
|
+
TermManagerModule: jsParams["contracts"]?.TermManagerModule || "MISSING",
|
|
43529
|
+
UCDController: jsParams["contracts"]?.UCDController || "MISSING"
|
|
43530
|
+
} : "NOT PROVIDED",
|
|
43531
|
+
contractAddresses: jsParams["contractAddresses"] ? {
|
|
43532
|
+
keys: Object.keys(jsParams["contractAddresses"]),
|
|
43533
|
+
count: Object.keys(jsParams["contractAddresses"]).length
|
|
43534
|
+
} : "NOT PROVIDED",
|
|
43535
|
+
auth: jsParams["auth"] ? {
|
|
43536
|
+
positionId: jsParams["auth"]?.positionId,
|
|
43537
|
+
timestamp: jsParams["auth"]?.timestamp,
|
|
43538
|
+
chainId: jsParams["auth"]?.chainId,
|
|
43539
|
+
amount: jsParams["auth"]?.amount,
|
|
43540
|
+
action: jsParams["auth"]?.action,
|
|
43541
|
+
mode: jsParams["auth"]?.mode,
|
|
43542
|
+
hasSignature: !!jsParams["auth"]?.signature
|
|
43543
|
+
} : "NOT PROVIDED"
|
|
43544
|
+
});
|
|
43545
|
+
const sanitizedParams = { ...jsParams };
|
|
43546
|
+
if (sanitizedParams["auth"] && typeof sanitizedParams["auth"] === "object") {
|
|
43547
|
+
const auth = sanitizedParams["auth"];
|
|
43548
|
+
sanitizedParams["auth"] = {
|
|
43549
|
+
...auth,
|
|
43550
|
+
signature: auth.signature ? `${auth.signature.substring(0, 20)}...` : void 0
|
|
43551
|
+
};
|
|
43552
|
+
}
|
|
43553
|
+
if (typeof sanitizedParams["publicKey"] === "string") {
|
|
43554
|
+
sanitizedParams["publicKey"] = `${sanitizedParams["publicKey"].substring(0, 20)}...`;
|
|
43555
|
+
}
|
|
43556
|
+
log.info("\u{1F4E4} Complete jsParams (sanitized JSON):", JSON.stringify(sanitizedParams, null, 2));
|
|
43395
43557
|
}
|
|
43396
43558
|
const response = await fetch(url, {
|
|
43397
43559
|
method: "POST",
|
|
@@ -43608,16 +43770,39 @@ var PKPAuthorization = class {
|
|
|
43608
43770
|
);
|
|
43609
43771
|
}
|
|
43610
43772
|
const formattedPkpPublicKey = pkpPublicKey?.startsWith("0x") ? pkpPublicKey.slice(2) : pkpPublicKey;
|
|
43773
|
+
const finalJsParams = {
|
|
43774
|
+
...jsParams,
|
|
43775
|
+
publicKey: formattedPkpPublicKey,
|
|
43776
|
+
ipfsId: cid
|
|
43777
|
+
};
|
|
43778
|
+
if (this.config.debug) {
|
|
43779
|
+
log.info("\u{1F680} Final jsParams being sent to LIT Protocol (IPFS execution):", {
|
|
43780
|
+
ipfsId: cid,
|
|
43781
|
+
jsParamsKeys: Object.keys(finalJsParams),
|
|
43782
|
+
jsParamsCount: Object.keys(finalJsParams).length,
|
|
43783
|
+
contracts: finalJsParams["contracts"] ? {
|
|
43784
|
+
keys: Object.keys(finalJsParams["contracts"]),
|
|
43785
|
+
PositionManager: finalJsParams["contracts"]?.PositionManager || "MISSING",
|
|
43786
|
+
LoanOperationsManagerModule: finalJsParams["contracts"]?.LoanOperationsManagerModule || "MISSING",
|
|
43787
|
+
TermManagerModule: finalJsParams["contracts"]?.TermManagerModule || "MISSING",
|
|
43788
|
+
UCDController: finalJsParams["contracts"]?.UCDController || "MISSING"
|
|
43789
|
+
} : "NOT PROVIDED",
|
|
43790
|
+
contractAddresses: finalJsParams["contractAddresses"] ? {
|
|
43791
|
+
keys: Object.keys(finalJsParams["contractAddresses"])
|
|
43792
|
+
} : "NOT PROVIDED",
|
|
43793
|
+
hasPublicKey: !!finalJsParams["publicKey"],
|
|
43794
|
+
publicKeyPreview: finalJsParams["publicKey"] ? `${finalJsParams["publicKey"].substring(0, 20)}...` : "MISSING",
|
|
43795
|
+
hasAuth: !!finalJsParams["auth"],
|
|
43796
|
+
chain: finalJsParams["chain"],
|
|
43797
|
+
amount: finalJsParams["amount"]
|
|
43798
|
+
});
|
|
43799
|
+
}
|
|
43611
43800
|
const result = await executeLitAction(
|
|
43612
43801
|
litClient,
|
|
43613
43802
|
{
|
|
43614
43803
|
ipfsId: cid,
|
|
43615
43804
|
sessionSigs: sessionSigsResult.sessionSigs,
|
|
43616
|
-
jsParams:
|
|
43617
|
-
...jsParams,
|
|
43618
|
-
publicKey: formattedPkpPublicKey,
|
|
43619
|
-
ipfsId: cid
|
|
43620
|
-
}
|
|
43805
|
+
jsParams: finalJsParams
|
|
43621
43806
|
},
|
|
43622
43807
|
{
|
|
43623
43808
|
maxAttempts: 1,
|
|
@@ -43733,6 +43918,18 @@ var PKPAuthorization = class {
|
|
|
43733
43918
|
}
|
|
43734
43919
|
};
|
|
43735
43920
|
function createPKPAuthorization(config) {
|
|
43921
|
+
console.log("[PKP-AUTH] createPKPAuthorization called", {
|
|
43922
|
+
hasContractAddresses: !!config.contractAddresses,
|
|
43923
|
+
contractAddressKeys: config.contractAddresses ? Object.keys(config.contractAddresses) : [],
|
|
43924
|
+
hasPositionManager: !!config.contractAddresses?.positionManager,
|
|
43925
|
+
hasLoanOperationsManager: !!config.contractAddresses?.loanOperationsManager,
|
|
43926
|
+
hasTermManager: !!config.contractAddresses?.termManager,
|
|
43927
|
+
hasUcdController: !!config.contractAddresses?.ucdController,
|
|
43928
|
+
positionManager: config.contractAddresses?.positionManager || "MISSING",
|
|
43929
|
+
loanOperationsManager: config.contractAddresses?.loanOperationsManager || "MISSING",
|
|
43930
|
+
termManager: config.contractAddresses?.termManager || "MISSING",
|
|
43931
|
+
ucdController: config.contractAddresses?.ucdController || "MISSING"
|
|
43932
|
+
});
|
|
43736
43933
|
try {
|
|
43737
43934
|
const authorization = new PKPAuthorization(config);
|
|
43738
43935
|
return success(authorization);
|
|
@@ -47537,6 +47734,17 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
47537
47734
|
timeoutMs: config.pkpServiceTimeoutMs || 48e4
|
|
47538
47735
|
// Use PKP service timeout (default 8 minutes)
|
|
47539
47736
|
});
|
|
47737
|
+
console.log("[SDK] Passing contractAddresses to createPKPAuthorization", {
|
|
47738
|
+
keys: Object.keys(config.contractAddresses || {}),
|
|
47739
|
+
hasPositionManager: !!config.contractAddresses?.positionManager,
|
|
47740
|
+
hasLoanOperationsManager: !!config.contractAddresses?.loanOperationsManager,
|
|
47741
|
+
hasTermManager: !!config.contractAddresses?.termManager,
|
|
47742
|
+
hasUcdController: !!config.contractAddresses?.ucdController,
|
|
47743
|
+
positionManager: config.contractAddresses?.positionManager || "MISSING",
|
|
47744
|
+
loanOperationsManager: config.contractAddresses?.loanOperationsManager || "MISSING",
|
|
47745
|
+
termManager: config.contractAddresses?.termManager || "MISSING",
|
|
47746
|
+
ucdController: config.contractAddresses?.ucdController || "MISSING"
|
|
47747
|
+
});
|
|
47540
47748
|
if (!pkpAuthResult.success) {
|
|
47541
47749
|
const errorDetails = pkpAuthResult.error.originalError ? ` (${pkpAuthResult.error.originalError.message})` : "";
|
|
47542
47750
|
throw new Error(
|
|
@@ -47765,6 +47973,17 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
47765
47973
|
...config.contractAddresses || {}
|
|
47766
47974
|
// User-provided individual overrides (only specified fields)
|
|
47767
47975
|
};
|
|
47976
|
+
console.log("[SDK] enrichConfigWithNetworkDefaults - contractAddresses after merge", {
|
|
47977
|
+
keys: Object.keys(enrichedConfig.contractAddresses || {}),
|
|
47978
|
+
hasPositionManager: !!enrichedConfig.contractAddresses?.positionManager,
|
|
47979
|
+
hasLoanOperationsManager: !!enrichedConfig.contractAddresses?.loanOperationsManager,
|
|
47980
|
+
hasTermManager: !!enrichedConfig.contractAddresses?.termManager,
|
|
47981
|
+
hasUcdController: !!enrichedConfig.contractAddresses?.ucdController,
|
|
47982
|
+
positionManager: enrichedConfig.contractAddresses?.positionManager || "MISSING",
|
|
47983
|
+
loanOperationsManager: enrichedConfig.contractAddresses?.loanOperationsManager || "MISSING",
|
|
47984
|
+
termManager: enrichedConfig.contractAddresses?.termManager || "MISSING",
|
|
47985
|
+
ucdController: enrichedConfig.contractAddresses?.ucdController || "MISSING"
|
|
47986
|
+
});
|
|
47768
47987
|
if (config.debug) {
|
|
47769
47988
|
log.info("\u2705 Contract addresses loaded from network config", {
|
|
47770
47989
|
overridden: Object.keys(config.contractAddresses || {}).length,
|
|
@@ -48235,6 +48454,12 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
48235
48454
|
*/
|
|
48236
48455
|
async requestMintUCD(request) {
|
|
48237
48456
|
this.ensureInitialized();
|
|
48457
|
+
console.log("[SDK] requestMintUCD called", {
|
|
48458
|
+
hasContractAddresses: !!this.config.contractAddresses,
|
|
48459
|
+
contractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
48460
|
+
positionId: request.positionId,
|
|
48461
|
+
amount: request.amount
|
|
48462
|
+
});
|
|
48238
48463
|
const MAX_RETRIES = 3;
|
|
48239
48464
|
let lastError;
|
|
48240
48465
|
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
|
|
@@ -48738,6 +48963,14 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
48738
48963
|
if (this.config.debug) {
|
|
48739
48964
|
log.info(`\u{1F550} Using fresh timestamp for authorization: ${mintAuthParams.timestamp}`);
|
|
48740
48965
|
}
|
|
48966
|
+
console.log("[SDK] About to call authorizeMintUCD", {
|
|
48967
|
+
hasPkpAuth: !!this.pkpAuthorization,
|
|
48968
|
+
configContractAddresses: Object.keys(this.config.contractAddresses || {}),
|
|
48969
|
+
hasPositionManager: !!this.config.contractAddresses?.positionManager,
|
|
48970
|
+
hasLoanOperationsManager: !!this.config.contractAddresses?.loanOperationsManager,
|
|
48971
|
+
hasTermManager: !!this.config.contractAddresses?.termManager,
|
|
48972
|
+
hasUcdController: !!this.config.contractAddresses?.ucdController
|
|
48973
|
+
});
|
|
48741
48974
|
const authResult = await this.pkpAuthorization.authorizeMintUCD(
|
|
48742
48975
|
mintAuthParams,
|
|
48743
48976
|
ucdMintValidatorPkp,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gvnrdao/dh-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.116",
|
|
4
4
|
"description": "TypeScript SDK for Diamond Hands Protocol - Bitcoin-backed lending with LIT Protocol PKPs",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"author": "Diamond Hands Protocol",
|
|
50
50
|
"license": "MIT",
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@gvnrdao/dh-lit-actions": "^0.0.
|
|
53
|
-
"@gvnrdao/dh-lit-ops": "^0.0.
|
|
52
|
+
"@gvnrdao/dh-lit-actions": "^0.0.63",
|
|
53
|
+
"@gvnrdao/dh-lit-ops": "^0.0.55",
|
|
54
54
|
"@lit-protocol/lit-node-client": "^7.3.1",
|
|
55
55
|
"@noble/hashes": "^1.5.0",
|
|
56
56
|
"axios": "^1.5.0",
|