@gvnrdao/dh-sdk 0.0.113 → 0.0.115
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 +216 -15
- package/dist/index.mjs +216 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -42411,16 +42411,16 @@ var PKPAuthorization = class {
|
|
|
42411
42411
|
return void 0;
|
|
42412
42412
|
}
|
|
42413
42413
|
const mapped = {};
|
|
42414
|
-
if (sdkContracts.positionManager) {
|
|
42414
|
+
if (sdkContracts.positionManager && sdkContracts.positionManager.trim() !== "") {
|
|
42415
42415
|
mapped["PositionManager"] = sdkContracts.positionManager;
|
|
42416
42416
|
}
|
|
42417
|
-
if (sdkContracts.loanOperationsManager) {
|
|
42417
|
+
if (sdkContracts.loanOperationsManager && sdkContracts.loanOperationsManager.trim() !== "") {
|
|
42418
42418
|
mapped["LoanOperationsManagerModule"] = sdkContracts.loanOperationsManager;
|
|
42419
42419
|
}
|
|
42420
|
-
if (sdkContracts.termManager) {
|
|
42420
|
+
if (sdkContracts.termManager && sdkContracts.termManager.trim() !== "") {
|
|
42421
42421
|
mapped["TermManagerModule"] = sdkContracts.termManager;
|
|
42422
42422
|
}
|
|
42423
|
-
if (sdkContracts.ucdController) {
|
|
42423
|
+
if (sdkContracts.ucdController && sdkContracts.ucdController.trim() !== "") {
|
|
42424
42424
|
mapped["UCDController"] = sdkContracts.ucdController;
|
|
42425
42425
|
}
|
|
42426
42426
|
if (sdkContracts.ucdToken) {
|
|
@@ -42567,6 +42567,12 @@ var PKPAuthorization = class {
|
|
|
42567
42567
|
* @returns Mint authorization response
|
|
42568
42568
|
*/
|
|
42569
42569
|
async authorizeMintUCD(params, pkpPublicKey, auth, pkpTokenId, pkpEthAddress) {
|
|
42570
|
+
console.log("[PKP-AUTH] authorizeMintUCD called", {
|
|
42571
|
+
positionId: params.positionId,
|
|
42572
|
+
hasConfig: !!this.config,
|
|
42573
|
+
hasContractAddresses: !!this.config?.contractAddresses,
|
|
42574
|
+
debug: this.config?.debug
|
|
42575
|
+
});
|
|
42570
42576
|
if (this.config.debug) {
|
|
42571
42577
|
log.info("\u{1F510} Authorizing mint UCD", {
|
|
42572
42578
|
positionId: params.positionId,
|
|
@@ -42680,7 +42686,33 @@ var PKPAuthorization = class {
|
|
|
42680
42686
|
"final chainStr": chainStr
|
|
42681
42687
|
});
|
|
42682
42688
|
}
|
|
42689
|
+
console.log("[PKP-AUTH] Contract addresses check (BEFORE mapping):", {
|
|
42690
|
+
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
42691
|
+
configContractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
42692
|
+
positionManager: this.config.contractAddresses?.positionManager || "MISSING",
|
|
42693
|
+
loanOperationsManager: this.config.contractAddresses?.loanOperationsManager || "MISSING",
|
|
42694
|
+
termManager: this.config.contractAddresses?.termManager || "MISSING",
|
|
42695
|
+
ucdController: this.config.contractAddresses?.ucdController || "MISSING"
|
|
42696
|
+
});
|
|
42697
|
+
if (this.config.debug) {
|
|
42698
|
+
log.info("\u{1F50D} PKPAuthorization contract addresses check:", {
|
|
42699
|
+
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
42700
|
+
configContractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
42701
|
+
positionManager: this.config.contractAddresses?.positionManager || "MISSING",
|
|
42702
|
+
loanOperationsManager: this.config.contractAddresses?.loanOperationsManager || "MISSING",
|
|
42703
|
+
termManager: this.config.contractAddresses?.termManager || "MISSING",
|
|
42704
|
+
ucdController: this.config.contractAddresses?.ucdController || "MISSING"
|
|
42705
|
+
});
|
|
42706
|
+
}
|
|
42683
42707
|
const contractAddresses = this.mapContractAddressesToLitActionFormat(this.config.contractAddresses);
|
|
42708
|
+
console.log("[PKP-AUTH] Contract addresses check (AFTER mapping):", {
|
|
42709
|
+
hasMappedAddresses: !!contractAddresses,
|
|
42710
|
+
mappedKeys: contractAddresses ? Object.keys(contractAddresses) : [],
|
|
42711
|
+
PositionManager: contractAddresses?.PositionManager || "MISSING",
|
|
42712
|
+
LoanOperationsManagerModule: contractAddresses?.LoanOperationsManagerModule || "MISSING",
|
|
42713
|
+
TermManagerModule: contractAddresses?.TermManagerModule || "MISSING",
|
|
42714
|
+
UCDController: contractAddresses?.UCDController || "MISSING"
|
|
42715
|
+
});
|
|
42684
42716
|
const requiredContracts = ["PositionManager", "LoanOperationsManagerModule", "TermManagerModule", "UCDController"];
|
|
42685
42717
|
if (contractAddresses) {
|
|
42686
42718
|
const missingContracts = requiredContracts.filter((contract) => !contractAddresses[contract]);
|
|
@@ -42690,8 +42722,15 @@ var PKPAuthorization = class {
|
|
|
42690
42722
|
available: Object.keys(contractAddresses)
|
|
42691
42723
|
});
|
|
42692
42724
|
}
|
|
42693
|
-
} else
|
|
42694
|
-
|
|
42725
|
+
} else {
|
|
42726
|
+
if (this.config.debug) {
|
|
42727
|
+
log.error("\u274C CRITICAL: No contract addresses mapped for LIT Action!", {
|
|
42728
|
+
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
42729
|
+
configContractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
42730
|
+
mappedResult: contractAddresses
|
|
42731
|
+
});
|
|
42732
|
+
}
|
|
42733
|
+
log.error("\u26A0\uFE0F No contract addresses provided - Lit Action will fail with toLowerCase error");
|
|
42695
42734
|
}
|
|
42696
42735
|
const jsParams = {
|
|
42697
42736
|
chain: chainStr,
|
|
@@ -42726,14 +42765,108 @@ var PKPAuthorization = class {
|
|
|
42726
42765
|
note: "PKP must be authorized for Lit Action CID with scope [1] (SignAnything)"
|
|
42727
42766
|
});
|
|
42728
42767
|
}
|
|
42729
|
-
|
|
42768
|
+
const requiredContractsForLIT = ["PositionManager", "LoanOperationsManagerModule", "TermManagerModule", "UCDController"];
|
|
42769
|
+
const hasRequiredContracts = contractAddresses && requiredContractsForLIT.every(
|
|
42770
|
+
(contract) => contractAddresses[contract] && contractAddresses[contract].trim() !== ""
|
|
42771
|
+
);
|
|
42772
|
+
if (hasRequiredContracts) {
|
|
42730
42773
|
jsParams["contracts"] = contractAddresses;
|
|
42731
42774
|
jsParams["contractAddresses"] = contractAddresses;
|
|
42775
|
+
console.log("[PKP-AUTH] \u2705 Contract addresses INCLUDED in jsParams:", {
|
|
42776
|
+
contracts: Object.keys(contractAddresses),
|
|
42777
|
+
contractCount: Object.keys(contractAddresses).length,
|
|
42778
|
+
PositionManager: contractAddresses.PositionManager || "MISSING",
|
|
42779
|
+
LoanOperationsManagerModule: contractAddresses.LoanOperationsManagerModule || "MISSING",
|
|
42780
|
+
TermManagerModule: contractAddresses.TermManagerModule || "MISSING",
|
|
42781
|
+
UCDController: contractAddresses.UCDController || "MISSING"
|
|
42782
|
+
});
|
|
42732
42783
|
if (this.config.debug) {
|
|
42733
42784
|
log.info("\u{1F4CB} Contract addresses included in jsParams:", {
|
|
42734
|
-
contracts: Object.keys(contractAddresses)
|
|
42785
|
+
contracts: Object.keys(contractAddresses),
|
|
42786
|
+
contractCount: Object.keys(contractAddresses).length,
|
|
42787
|
+
hasPositionManager: !!contractAddresses.PositionManager,
|
|
42788
|
+
hasLoanOps: !!contractAddresses.LoanOperationsManagerModule
|
|
42789
|
+
});
|
|
42790
|
+
log.info("\u{1F4CB} Contract address values being sent:", {
|
|
42791
|
+
PositionManager: contractAddresses.PositionManager || "MISSING",
|
|
42792
|
+
LoanOperationsManagerModule: contractAddresses.LoanOperationsManagerModule || "MISSING",
|
|
42793
|
+
TermManagerModule: contractAddresses.TermManagerModule || "MISSING",
|
|
42794
|
+
UCDController: contractAddresses.UCDController || "MISSING"
|
|
42735
42795
|
});
|
|
42736
42796
|
}
|
|
42797
|
+
} else {
|
|
42798
|
+
const missingRequired = contractAddresses ? requiredContractsForLIT.filter((contract) => !contractAddresses[contract] || contractAddresses[contract].trim() === "") : requiredContractsForLIT;
|
|
42799
|
+
console.error("[PKP-AUTH] \u274C CRITICAL: Required contract addresses MISSING!", {
|
|
42800
|
+
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
42801
|
+
configContractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
42802
|
+
mappedResult: contractAddresses,
|
|
42803
|
+
missingRequiredContracts: missingRequired,
|
|
42804
|
+
availableContracts: contractAddresses ? Object.keys(contractAddresses) : []
|
|
42805
|
+
});
|
|
42806
|
+
log.error("\u274C CRITICAL: Required contract addresses missing - LIT Action will fail!", {
|
|
42807
|
+
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
42808
|
+
configContractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
42809
|
+
mappedResult: contractAddresses,
|
|
42810
|
+
missingRequiredContracts: missingRequired,
|
|
42811
|
+
availableContracts: contractAddresses ? Object.keys(contractAddresses) : []
|
|
42812
|
+
});
|
|
42813
|
+
if (contractAddresses && Object.keys(contractAddresses).length > 0) {
|
|
42814
|
+
jsParams["contracts"] = contractAddresses;
|
|
42815
|
+
jsParams["contractAddresses"] = contractAddresses;
|
|
42816
|
+
console.warn("[PKP-AUTH] \u26A0\uFE0F Passing incomplete contract addresses - LIT Action may fail");
|
|
42817
|
+
log.warn("\u26A0\uFE0F Passing incomplete contract addresses - LIT Action may fail");
|
|
42818
|
+
} else {
|
|
42819
|
+
console.error("[PKP-AUTH] \u274C No contract addresses to pass - LIT Action will definitely fail with toLowerCase error");
|
|
42820
|
+
log.error("\u274C No contract addresses to pass - LIT Action will definitely fail with toLowerCase error");
|
|
42821
|
+
}
|
|
42822
|
+
}
|
|
42823
|
+
if (this.config.debug) {
|
|
42824
|
+
log.info("\u{1F4E4} Complete jsParams being sent to LIT Action:", {
|
|
42825
|
+
jsParamsKeys: Object.keys(jsParams),
|
|
42826
|
+
jsParamsCount: Object.keys(jsParams).length,
|
|
42827
|
+
// Log all params with sanitized sensitive data
|
|
42828
|
+
chain: jsParams["chain"],
|
|
42829
|
+
bitcoinProviderUrl: jsParams["bitcoinProviderUrl"] ? "PROVIDED" : "NOT PROVIDED",
|
|
42830
|
+
amount: jsParams["amount"],
|
|
42831
|
+
publicKey: jsParams["publicKey"] ? `${jsParams["publicKey"].substring(0, 20)}...` : "NOT PROVIDED",
|
|
42832
|
+
ipfsId: jsParams["ipfsId"],
|
|
42833
|
+
pkpTokenId: jsParams["pkpTokenId"] || "NOT PROVIDED",
|
|
42834
|
+
rpcUrl: jsParams["rpcUrl"] ? "PROVIDED" : "NOT PROVIDED",
|
|
42835
|
+
contracts: jsParams["contracts"] ? {
|
|
42836
|
+
keys: Object.keys(jsParams["contracts"]),
|
|
42837
|
+
count: Object.keys(jsParams["contracts"]).length,
|
|
42838
|
+
PositionManager: jsParams["contracts"]?.PositionManager || "MISSING",
|
|
42839
|
+
LoanOperationsManagerModule: jsParams["contracts"]?.LoanOperationsManagerModule || "MISSING",
|
|
42840
|
+
TermManagerModule: jsParams["contracts"]?.TermManagerModule || "MISSING",
|
|
42841
|
+
UCDController: jsParams["contracts"]?.UCDController || "MISSING"
|
|
42842
|
+
} : "NOT PROVIDED",
|
|
42843
|
+
contractAddresses: jsParams["contractAddresses"] ? {
|
|
42844
|
+
keys: Object.keys(jsParams["contractAddresses"]),
|
|
42845
|
+
count: Object.keys(jsParams["contractAddresses"]).length
|
|
42846
|
+
} : "NOT PROVIDED",
|
|
42847
|
+
// Log full auth object structure (without signature value)
|
|
42848
|
+
auth: jsParams["auth"] ? {
|
|
42849
|
+
positionId: jsParams["auth"]?.positionId,
|
|
42850
|
+
timestamp: jsParams["auth"]?.timestamp,
|
|
42851
|
+
chainId: jsParams["auth"]?.chainId,
|
|
42852
|
+
amount: jsParams["auth"]?.amount,
|
|
42853
|
+
action: jsParams["auth"]?.action,
|
|
42854
|
+
mode: jsParams["auth"]?.mode,
|
|
42855
|
+
hasSignature: !!jsParams["auth"]?.signature
|
|
42856
|
+
} : "NOT PROVIDED"
|
|
42857
|
+
});
|
|
42858
|
+
const sanitizedParams = { ...jsParams };
|
|
42859
|
+
if (sanitizedParams["auth"] && typeof sanitizedParams["auth"] === "object") {
|
|
42860
|
+
const auth2 = sanitizedParams["auth"];
|
|
42861
|
+
sanitizedParams["auth"] = {
|
|
42862
|
+
...auth2,
|
|
42863
|
+
signature: auth2.signature ? `${auth2.signature.substring(0, 20)}...` : void 0
|
|
42864
|
+
};
|
|
42865
|
+
}
|
|
42866
|
+
if (typeof sanitizedParams["publicKey"] === "string") {
|
|
42867
|
+
sanitizedParams["publicKey"] = `${sanitizedParams["publicKey"].substring(0, 20)}...`;
|
|
42868
|
+
}
|
|
42869
|
+
log.info("\u{1F4E4} Complete jsParams (sanitized JSON):", JSON.stringify(sanitizedParams, null, 2));
|
|
42737
42870
|
}
|
|
42738
42871
|
const litResult = await this.executeLitAction(pkpPublicKey, jsParams, pkpTokenId, pkpEthAddress);
|
|
42739
42872
|
if (!litResult.success) {
|
|
@@ -43433,14 +43566,59 @@ var PKPAuthorization = class {
|
|
|
43433
43566
|
...formattedPkpTokenId ? { pkpTokenId: formattedPkpTokenId } : {}
|
|
43434
43567
|
};
|
|
43435
43568
|
if (this.config.debug) {
|
|
43436
|
-
log.info("\u{1F4E4} Service request body:", {
|
|
43569
|
+
log.info("\u{1F4E4} Service request body (summary):", {
|
|
43437
43570
|
ipfsId: requestBody.ipfsId,
|
|
43438
43571
|
pkpPublicKey: formattedPkpPublicKey.substring(0, 20) + "...",
|
|
43439
43572
|
pkpTokenId: formattedPkpTokenId || "NOT PROVIDED",
|
|
43440
43573
|
pkpTokenIdOriginal: pkpTokenId || "NOT PROVIDED",
|
|
43441
43574
|
pkpTokenIdFormatted: formattedPkpTokenId ? `${formattedPkpTokenId.length} chars (hex)` : "NOT PROVIDED",
|
|
43442
|
-
paramsKeys: Object.keys(jsParams)
|
|
43575
|
+
paramsKeys: Object.keys(jsParams),
|
|
43576
|
+
paramsCount: Object.keys(jsParams).length
|
|
43577
|
+
});
|
|
43578
|
+
log.info("\u{1F4E4} Complete jsParams being sent to service (for LIT Action):", {
|
|
43579
|
+
jsParamsKeys: Object.keys(jsParams),
|
|
43580
|
+
jsParamsCount: Object.keys(jsParams).length,
|
|
43581
|
+
chain: jsParams["chain"],
|
|
43582
|
+
bitcoinProviderUrl: jsParams["bitcoinProviderUrl"] ? "PROVIDED" : "NOT PROVIDED",
|
|
43583
|
+
amount: jsParams["amount"],
|
|
43584
|
+
publicKey: jsParams["publicKey"] ? `${jsParams["publicKey"].substring(0, 20)}...` : "NOT PROVIDED",
|
|
43585
|
+
ipfsId: jsParams["ipfsId"],
|
|
43586
|
+
pkpTokenId: jsParams["pkpTokenId"] || "NOT PROVIDED",
|
|
43587
|
+
rpcUrl: jsParams["rpcUrl"] ? "PROVIDED" : "NOT PROVIDED",
|
|
43588
|
+
contracts: jsParams["contracts"] ? {
|
|
43589
|
+
keys: Object.keys(jsParams["contracts"]),
|
|
43590
|
+
count: Object.keys(jsParams["contracts"]).length,
|
|
43591
|
+
PositionManager: jsParams["contracts"]?.PositionManager || "MISSING",
|
|
43592
|
+
LoanOperationsManagerModule: jsParams["contracts"]?.LoanOperationsManagerModule || "MISSING",
|
|
43593
|
+
TermManagerModule: jsParams["contracts"]?.TermManagerModule || "MISSING",
|
|
43594
|
+
UCDController: jsParams["contracts"]?.UCDController || "MISSING"
|
|
43595
|
+
} : "NOT PROVIDED",
|
|
43596
|
+
contractAddresses: jsParams["contractAddresses"] ? {
|
|
43597
|
+
keys: Object.keys(jsParams["contractAddresses"]),
|
|
43598
|
+
count: Object.keys(jsParams["contractAddresses"]).length
|
|
43599
|
+
} : "NOT PROVIDED",
|
|
43600
|
+
auth: jsParams["auth"] ? {
|
|
43601
|
+
positionId: jsParams["auth"]?.positionId,
|
|
43602
|
+
timestamp: jsParams["auth"]?.timestamp,
|
|
43603
|
+
chainId: jsParams["auth"]?.chainId,
|
|
43604
|
+
amount: jsParams["auth"]?.amount,
|
|
43605
|
+
action: jsParams["auth"]?.action,
|
|
43606
|
+
mode: jsParams["auth"]?.mode,
|
|
43607
|
+
hasSignature: !!jsParams["auth"]?.signature
|
|
43608
|
+
} : "NOT PROVIDED"
|
|
43443
43609
|
});
|
|
43610
|
+
const sanitizedParams = { ...jsParams };
|
|
43611
|
+
if (sanitizedParams["auth"] && typeof sanitizedParams["auth"] === "object") {
|
|
43612
|
+
const auth = sanitizedParams["auth"];
|
|
43613
|
+
sanitizedParams["auth"] = {
|
|
43614
|
+
...auth,
|
|
43615
|
+
signature: auth.signature ? `${auth.signature.substring(0, 20)}...` : void 0
|
|
43616
|
+
};
|
|
43617
|
+
}
|
|
43618
|
+
if (typeof sanitizedParams["publicKey"] === "string") {
|
|
43619
|
+
sanitizedParams["publicKey"] = `${sanitizedParams["publicKey"].substring(0, 20)}...`;
|
|
43620
|
+
}
|
|
43621
|
+
log.info("\u{1F4E4} Complete jsParams (sanitized JSON):", JSON.stringify(sanitizedParams, null, 2));
|
|
43444
43622
|
}
|
|
43445
43623
|
const response = await fetch(url, {
|
|
43446
43624
|
method: "POST",
|
|
@@ -43657,16 +43835,39 @@ var PKPAuthorization = class {
|
|
|
43657
43835
|
);
|
|
43658
43836
|
}
|
|
43659
43837
|
const formattedPkpPublicKey = pkpPublicKey?.startsWith("0x") ? pkpPublicKey.slice(2) : pkpPublicKey;
|
|
43838
|
+
const finalJsParams = {
|
|
43839
|
+
...jsParams,
|
|
43840
|
+
publicKey: formattedPkpPublicKey,
|
|
43841
|
+
ipfsId: cid
|
|
43842
|
+
};
|
|
43843
|
+
if (this.config.debug) {
|
|
43844
|
+
log.info("\u{1F680} Final jsParams being sent to LIT Protocol (IPFS execution):", {
|
|
43845
|
+
ipfsId: cid,
|
|
43846
|
+
jsParamsKeys: Object.keys(finalJsParams),
|
|
43847
|
+
jsParamsCount: Object.keys(finalJsParams).length,
|
|
43848
|
+
contracts: finalJsParams["contracts"] ? {
|
|
43849
|
+
keys: Object.keys(finalJsParams["contracts"]),
|
|
43850
|
+
PositionManager: finalJsParams["contracts"]?.PositionManager || "MISSING",
|
|
43851
|
+
LoanOperationsManagerModule: finalJsParams["contracts"]?.LoanOperationsManagerModule || "MISSING",
|
|
43852
|
+
TermManagerModule: finalJsParams["contracts"]?.TermManagerModule || "MISSING",
|
|
43853
|
+
UCDController: finalJsParams["contracts"]?.UCDController || "MISSING"
|
|
43854
|
+
} : "NOT PROVIDED",
|
|
43855
|
+
contractAddresses: finalJsParams["contractAddresses"] ? {
|
|
43856
|
+
keys: Object.keys(finalJsParams["contractAddresses"])
|
|
43857
|
+
} : "NOT PROVIDED",
|
|
43858
|
+
hasPublicKey: !!finalJsParams["publicKey"],
|
|
43859
|
+
publicKeyPreview: finalJsParams["publicKey"] ? `${finalJsParams["publicKey"].substring(0, 20)}...` : "MISSING",
|
|
43860
|
+
hasAuth: !!finalJsParams["auth"],
|
|
43861
|
+
chain: finalJsParams["chain"],
|
|
43862
|
+
amount: finalJsParams["amount"]
|
|
43863
|
+
});
|
|
43864
|
+
}
|
|
43660
43865
|
const result = await executeLitAction(
|
|
43661
43866
|
litClient,
|
|
43662
43867
|
{
|
|
43663
43868
|
ipfsId: cid,
|
|
43664
43869
|
sessionSigs: sessionSigsResult.sessionSigs,
|
|
43665
|
-
jsParams:
|
|
43666
|
-
...jsParams,
|
|
43667
|
-
publicKey: formattedPkpPublicKey,
|
|
43668
|
-
ipfsId: cid
|
|
43669
|
-
}
|
|
43870
|
+
jsParams: finalJsParams
|
|
43670
43871
|
},
|
|
43671
43872
|
{
|
|
43672
43873
|
maxAttempts: 1,
|
package/dist/index.mjs
CHANGED
|
@@ -42316,16 +42316,16 @@ var PKPAuthorization = class {
|
|
|
42316
42316
|
return void 0;
|
|
42317
42317
|
}
|
|
42318
42318
|
const mapped = {};
|
|
42319
|
-
if (sdkContracts.positionManager) {
|
|
42319
|
+
if (sdkContracts.positionManager && sdkContracts.positionManager.trim() !== "") {
|
|
42320
42320
|
mapped["PositionManager"] = sdkContracts.positionManager;
|
|
42321
42321
|
}
|
|
42322
|
-
if (sdkContracts.loanOperationsManager) {
|
|
42322
|
+
if (sdkContracts.loanOperationsManager && sdkContracts.loanOperationsManager.trim() !== "") {
|
|
42323
42323
|
mapped["LoanOperationsManagerModule"] = sdkContracts.loanOperationsManager;
|
|
42324
42324
|
}
|
|
42325
|
-
if (sdkContracts.termManager) {
|
|
42325
|
+
if (sdkContracts.termManager && sdkContracts.termManager.trim() !== "") {
|
|
42326
42326
|
mapped["TermManagerModule"] = sdkContracts.termManager;
|
|
42327
42327
|
}
|
|
42328
|
-
if (sdkContracts.ucdController) {
|
|
42328
|
+
if (sdkContracts.ucdController && sdkContracts.ucdController.trim() !== "") {
|
|
42329
42329
|
mapped["UCDController"] = sdkContracts.ucdController;
|
|
42330
42330
|
}
|
|
42331
42331
|
if (sdkContracts.ucdToken) {
|
|
@@ -42472,6 +42472,12 @@ var PKPAuthorization = class {
|
|
|
42472
42472
|
* @returns Mint authorization response
|
|
42473
42473
|
*/
|
|
42474
42474
|
async authorizeMintUCD(params, pkpPublicKey, auth, pkpTokenId, pkpEthAddress) {
|
|
42475
|
+
console.log("[PKP-AUTH] authorizeMintUCD called", {
|
|
42476
|
+
positionId: params.positionId,
|
|
42477
|
+
hasConfig: !!this.config,
|
|
42478
|
+
hasContractAddresses: !!this.config?.contractAddresses,
|
|
42479
|
+
debug: this.config?.debug
|
|
42480
|
+
});
|
|
42475
42481
|
if (this.config.debug) {
|
|
42476
42482
|
log.info("\u{1F510} Authorizing mint UCD", {
|
|
42477
42483
|
positionId: params.positionId,
|
|
@@ -42585,7 +42591,33 @@ var PKPAuthorization = class {
|
|
|
42585
42591
|
"final chainStr": chainStr
|
|
42586
42592
|
});
|
|
42587
42593
|
}
|
|
42594
|
+
console.log("[PKP-AUTH] Contract addresses check (BEFORE mapping):", {
|
|
42595
|
+
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
42596
|
+
configContractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
42597
|
+
positionManager: this.config.contractAddresses?.positionManager || "MISSING",
|
|
42598
|
+
loanOperationsManager: this.config.contractAddresses?.loanOperationsManager || "MISSING",
|
|
42599
|
+
termManager: this.config.contractAddresses?.termManager || "MISSING",
|
|
42600
|
+
ucdController: this.config.contractAddresses?.ucdController || "MISSING"
|
|
42601
|
+
});
|
|
42602
|
+
if (this.config.debug) {
|
|
42603
|
+
log.info("\u{1F50D} PKPAuthorization contract addresses check:", {
|
|
42604
|
+
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
42605
|
+
configContractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
42606
|
+
positionManager: this.config.contractAddresses?.positionManager || "MISSING",
|
|
42607
|
+
loanOperationsManager: this.config.contractAddresses?.loanOperationsManager || "MISSING",
|
|
42608
|
+
termManager: this.config.contractAddresses?.termManager || "MISSING",
|
|
42609
|
+
ucdController: this.config.contractAddresses?.ucdController || "MISSING"
|
|
42610
|
+
});
|
|
42611
|
+
}
|
|
42588
42612
|
const contractAddresses = this.mapContractAddressesToLitActionFormat(this.config.contractAddresses);
|
|
42613
|
+
console.log("[PKP-AUTH] Contract addresses check (AFTER mapping):", {
|
|
42614
|
+
hasMappedAddresses: !!contractAddresses,
|
|
42615
|
+
mappedKeys: contractAddresses ? Object.keys(contractAddresses) : [],
|
|
42616
|
+
PositionManager: contractAddresses?.PositionManager || "MISSING",
|
|
42617
|
+
LoanOperationsManagerModule: contractAddresses?.LoanOperationsManagerModule || "MISSING",
|
|
42618
|
+
TermManagerModule: contractAddresses?.TermManagerModule || "MISSING",
|
|
42619
|
+
UCDController: contractAddresses?.UCDController || "MISSING"
|
|
42620
|
+
});
|
|
42589
42621
|
const requiredContracts = ["PositionManager", "LoanOperationsManagerModule", "TermManagerModule", "UCDController"];
|
|
42590
42622
|
if (contractAddresses) {
|
|
42591
42623
|
const missingContracts = requiredContracts.filter((contract) => !contractAddresses[contract]);
|
|
@@ -42595,8 +42627,15 @@ var PKPAuthorization = class {
|
|
|
42595
42627
|
available: Object.keys(contractAddresses)
|
|
42596
42628
|
});
|
|
42597
42629
|
}
|
|
42598
|
-
} else
|
|
42599
|
-
|
|
42630
|
+
} else {
|
|
42631
|
+
if (this.config.debug) {
|
|
42632
|
+
log.error("\u274C CRITICAL: No contract addresses mapped for LIT Action!", {
|
|
42633
|
+
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
42634
|
+
configContractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
42635
|
+
mappedResult: contractAddresses
|
|
42636
|
+
});
|
|
42637
|
+
}
|
|
42638
|
+
log.error("\u26A0\uFE0F No contract addresses provided - Lit Action will fail with toLowerCase error");
|
|
42600
42639
|
}
|
|
42601
42640
|
const jsParams = {
|
|
42602
42641
|
chain: chainStr,
|
|
@@ -42631,14 +42670,108 @@ var PKPAuthorization = class {
|
|
|
42631
42670
|
note: "PKP must be authorized for Lit Action CID with scope [1] (SignAnything)"
|
|
42632
42671
|
});
|
|
42633
42672
|
}
|
|
42634
|
-
|
|
42673
|
+
const requiredContractsForLIT = ["PositionManager", "LoanOperationsManagerModule", "TermManagerModule", "UCDController"];
|
|
42674
|
+
const hasRequiredContracts = contractAddresses && requiredContractsForLIT.every(
|
|
42675
|
+
(contract) => contractAddresses[contract] && contractAddresses[contract].trim() !== ""
|
|
42676
|
+
);
|
|
42677
|
+
if (hasRequiredContracts) {
|
|
42635
42678
|
jsParams["contracts"] = contractAddresses;
|
|
42636
42679
|
jsParams["contractAddresses"] = contractAddresses;
|
|
42680
|
+
console.log("[PKP-AUTH] \u2705 Contract addresses INCLUDED in jsParams:", {
|
|
42681
|
+
contracts: Object.keys(contractAddresses),
|
|
42682
|
+
contractCount: Object.keys(contractAddresses).length,
|
|
42683
|
+
PositionManager: contractAddresses.PositionManager || "MISSING",
|
|
42684
|
+
LoanOperationsManagerModule: contractAddresses.LoanOperationsManagerModule || "MISSING",
|
|
42685
|
+
TermManagerModule: contractAddresses.TermManagerModule || "MISSING",
|
|
42686
|
+
UCDController: contractAddresses.UCDController || "MISSING"
|
|
42687
|
+
});
|
|
42637
42688
|
if (this.config.debug) {
|
|
42638
42689
|
log.info("\u{1F4CB} Contract addresses included in jsParams:", {
|
|
42639
|
-
contracts: Object.keys(contractAddresses)
|
|
42690
|
+
contracts: Object.keys(contractAddresses),
|
|
42691
|
+
contractCount: Object.keys(contractAddresses).length,
|
|
42692
|
+
hasPositionManager: !!contractAddresses.PositionManager,
|
|
42693
|
+
hasLoanOps: !!contractAddresses.LoanOperationsManagerModule
|
|
42694
|
+
});
|
|
42695
|
+
log.info("\u{1F4CB} Contract address values being sent:", {
|
|
42696
|
+
PositionManager: contractAddresses.PositionManager || "MISSING",
|
|
42697
|
+
LoanOperationsManagerModule: contractAddresses.LoanOperationsManagerModule || "MISSING",
|
|
42698
|
+
TermManagerModule: contractAddresses.TermManagerModule || "MISSING",
|
|
42699
|
+
UCDController: contractAddresses.UCDController || "MISSING"
|
|
42640
42700
|
});
|
|
42641
42701
|
}
|
|
42702
|
+
} else {
|
|
42703
|
+
const missingRequired = contractAddresses ? requiredContractsForLIT.filter((contract) => !contractAddresses[contract] || contractAddresses[contract].trim() === "") : requiredContractsForLIT;
|
|
42704
|
+
console.error("[PKP-AUTH] \u274C CRITICAL: Required contract addresses MISSING!", {
|
|
42705
|
+
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
42706
|
+
configContractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
42707
|
+
mappedResult: contractAddresses,
|
|
42708
|
+
missingRequiredContracts: missingRequired,
|
|
42709
|
+
availableContracts: contractAddresses ? Object.keys(contractAddresses) : []
|
|
42710
|
+
});
|
|
42711
|
+
log.error("\u274C CRITICAL: Required contract addresses missing - LIT Action will fail!", {
|
|
42712
|
+
hasConfigContractAddresses: !!this.config.contractAddresses,
|
|
42713
|
+
configContractAddressKeys: this.config.contractAddresses ? Object.keys(this.config.contractAddresses) : [],
|
|
42714
|
+
mappedResult: contractAddresses,
|
|
42715
|
+
missingRequiredContracts: missingRequired,
|
|
42716
|
+
availableContracts: contractAddresses ? Object.keys(contractAddresses) : []
|
|
42717
|
+
});
|
|
42718
|
+
if (contractAddresses && Object.keys(contractAddresses).length > 0) {
|
|
42719
|
+
jsParams["contracts"] = contractAddresses;
|
|
42720
|
+
jsParams["contractAddresses"] = contractAddresses;
|
|
42721
|
+
console.warn("[PKP-AUTH] \u26A0\uFE0F Passing incomplete contract addresses - LIT Action may fail");
|
|
42722
|
+
log.warn("\u26A0\uFE0F Passing incomplete contract addresses - LIT Action may fail");
|
|
42723
|
+
} else {
|
|
42724
|
+
console.error("[PKP-AUTH] \u274C No contract addresses to pass - LIT Action will definitely fail with toLowerCase error");
|
|
42725
|
+
log.error("\u274C No contract addresses to pass - LIT Action will definitely fail with toLowerCase error");
|
|
42726
|
+
}
|
|
42727
|
+
}
|
|
42728
|
+
if (this.config.debug) {
|
|
42729
|
+
log.info("\u{1F4E4} Complete jsParams being sent to LIT Action:", {
|
|
42730
|
+
jsParamsKeys: Object.keys(jsParams),
|
|
42731
|
+
jsParamsCount: Object.keys(jsParams).length,
|
|
42732
|
+
// Log all params with sanitized sensitive data
|
|
42733
|
+
chain: jsParams["chain"],
|
|
42734
|
+
bitcoinProviderUrl: jsParams["bitcoinProviderUrl"] ? "PROVIDED" : "NOT PROVIDED",
|
|
42735
|
+
amount: jsParams["amount"],
|
|
42736
|
+
publicKey: jsParams["publicKey"] ? `${jsParams["publicKey"].substring(0, 20)}...` : "NOT PROVIDED",
|
|
42737
|
+
ipfsId: jsParams["ipfsId"],
|
|
42738
|
+
pkpTokenId: jsParams["pkpTokenId"] || "NOT PROVIDED",
|
|
42739
|
+
rpcUrl: jsParams["rpcUrl"] ? "PROVIDED" : "NOT PROVIDED",
|
|
42740
|
+
contracts: jsParams["contracts"] ? {
|
|
42741
|
+
keys: Object.keys(jsParams["contracts"]),
|
|
42742
|
+
count: Object.keys(jsParams["contracts"]).length,
|
|
42743
|
+
PositionManager: jsParams["contracts"]?.PositionManager || "MISSING",
|
|
42744
|
+
LoanOperationsManagerModule: jsParams["contracts"]?.LoanOperationsManagerModule || "MISSING",
|
|
42745
|
+
TermManagerModule: jsParams["contracts"]?.TermManagerModule || "MISSING",
|
|
42746
|
+
UCDController: jsParams["contracts"]?.UCDController || "MISSING"
|
|
42747
|
+
} : "NOT PROVIDED",
|
|
42748
|
+
contractAddresses: jsParams["contractAddresses"] ? {
|
|
42749
|
+
keys: Object.keys(jsParams["contractAddresses"]),
|
|
42750
|
+
count: Object.keys(jsParams["contractAddresses"]).length
|
|
42751
|
+
} : "NOT PROVIDED",
|
|
42752
|
+
// Log full auth object structure (without signature value)
|
|
42753
|
+
auth: jsParams["auth"] ? {
|
|
42754
|
+
positionId: jsParams["auth"]?.positionId,
|
|
42755
|
+
timestamp: jsParams["auth"]?.timestamp,
|
|
42756
|
+
chainId: jsParams["auth"]?.chainId,
|
|
42757
|
+
amount: jsParams["auth"]?.amount,
|
|
42758
|
+
action: jsParams["auth"]?.action,
|
|
42759
|
+
mode: jsParams["auth"]?.mode,
|
|
42760
|
+
hasSignature: !!jsParams["auth"]?.signature
|
|
42761
|
+
} : "NOT PROVIDED"
|
|
42762
|
+
});
|
|
42763
|
+
const sanitizedParams = { ...jsParams };
|
|
42764
|
+
if (sanitizedParams["auth"] && typeof sanitizedParams["auth"] === "object") {
|
|
42765
|
+
const auth2 = sanitizedParams["auth"];
|
|
42766
|
+
sanitizedParams["auth"] = {
|
|
42767
|
+
...auth2,
|
|
42768
|
+
signature: auth2.signature ? `${auth2.signature.substring(0, 20)}...` : void 0
|
|
42769
|
+
};
|
|
42770
|
+
}
|
|
42771
|
+
if (typeof sanitizedParams["publicKey"] === "string") {
|
|
42772
|
+
sanitizedParams["publicKey"] = `${sanitizedParams["publicKey"].substring(0, 20)}...`;
|
|
42773
|
+
}
|
|
42774
|
+
log.info("\u{1F4E4} Complete jsParams (sanitized JSON):", JSON.stringify(sanitizedParams, null, 2));
|
|
42642
42775
|
}
|
|
42643
42776
|
const litResult = await this.executeLitAction(pkpPublicKey, jsParams, pkpTokenId, pkpEthAddress);
|
|
42644
42777
|
if (!litResult.success) {
|
|
@@ -43338,14 +43471,59 @@ var PKPAuthorization = class {
|
|
|
43338
43471
|
...formattedPkpTokenId ? { pkpTokenId: formattedPkpTokenId } : {}
|
|
43339
43472
|
};
|
|
43340
43473
|
if (this.config.debug) {
|
|
43341
|
-
log.info("\u{1F4E4} Service request body:", {
|
|
43474
|
+
log.info("\u{1F4E4} Service request body (summary):", {
|
|
43342
43475
|
ipfsId: requestBody.ipfsId,
|
|
43343
43476
|
pkpPublicKey: formattedPkpPublicKey.substring(0, 20) + "...",
|
|
43344
43477
|
pkpTokenId: formattedPkpTokenId || "NOT PROVIDED",
|
|
43345
43478
|
pkpTokenIdOriginal: pkpTokenId || "NOT PROVIDED",
|
|
43346
43479
|
pkpTokenIdFormatted: formattedPkpTokenId ? `${formattedPkpTokenId.length} chars (hex)` : "NOT PROVIDED",
|
|
43347
|
-
paramsKeys: Object.keys(jsParams)
|
|
43480
|
+
paramsKeys: Object.keys(jsParams),
|
|
43481
|
+
paramsCount: Object.keys(jsParams).length
|
|
43482
|
+
});
|
|
43483
|
+
log.info("\u{1F4E4} Complete jsParams being sent to service (for LIT Action):", {
|
|
43484
|
+
jsParamsKeys: Object.keys(jsParams),
|
|
43485
|
+
jsParamsCount: Object.keys(jsParams).length,
|
|
43486
|
+
chain: jsParams["chain"],
|
|
43487
|
+
bitcoinProviderUrl: jsParams["bitcoinProviderUrl"] ? "PROVIDED" : "NOT PROVIDED",
|
|
43488
|
+
amount: jsParams["amount"],
|
|
43489
|
+
publicKey: jsParams["publicKey"] ? `${jsParams["publicKey"].substring(0, 20)}...` : "NOT PROVIDED",
|
|
43490
|
+
ipfsId: jsParams["ipfsId"],
|
|
43491
|
+
pkpTokenId: jsParams["pkpTokenId"] || "NOT PROVIDED",
|
|
43492
|
+
rpcUrl: jsParams["rpcUrl"] ? "PROVIDED" : "NOT PROVIDED",
|
|
43493
|
+
contracts: jsParams["contracts"] ? {
|
|
43494
|
+
keys: Object.keys(jsParams["contracts"]),
|
|
43495
|
+
count: Object.keys(jsParams["contracts"]).length,
|
|
43496
|
+
PositionManager: jsParams["contracts"]?.PositionManager || "MISSING",
|
|
43497
|
+
LoanOperationsManagerModule: jsParams["contracts"]?.LoanOperationsManagerModule || "MISSING",
|
|
43498
|
+
TermManagerModule: jsParams["contracts"]?.TermManagerModule || "MISSING",
|
|
43499
|
+
UCDController: jsParams["contracts"]?.UCDController || "MISSING"
|
|
43500
|
+
} : "NOT PROVIDED",
|
|
43501
|
+
contractAddresses: jsParams["contractAddresses"] ? {
|
|
43502
|
+
keys: Object.keys(jsParams["contractAddresses"]),
|
|
43503
|
+
count: Object.keys(jsParams["contractAddresses"]).length
|
|
43504
|
+
} : "NOT PROVIDED",
|
|
43505
|
+
auth: jsParams["auth"] ? {
|
|
43506
|
+
positionId: jsParams["auth"]?.positionId,
|
|
43507
|
+
timestamp: jsParams["auth"]?.timestamp,
|
|
43508
|
+
chainId: jsParams["auth"]?.chainId,
|
|
43509
|
+
amount: jsParams["auth"]?.amount,
|
|
43510
|
+
action: jsParams["auth"]?.action,
|
|
43511
|
+
mode: jsParams["auth"]?.mode,
|
|
43512
|
+
hasSignature: !!jsParams["auth"]?.signature
|
|
43513
|
+
} : "NOT PROVIDED"
|
|
43348
43514
|
});
|
|
43515
|
+
const sanitizedParams = { ...jsParams };
|
|
43516
|
+
if (sanitizedParams["auth"] && typeof sanitizedParams["auth"] === "object") {
|
|
43517
|
+
const auth = sanitizedParams["auth"];
|
|
43518
|
+
sanitizedParams["auth"] = {
|
|
43519
|
+
...auth,
|
|
43520
|
+
signature: auth.signature ? `${auth.signature.substring(0, 20)}...` : void 0
|
|
43521
|
+
};
|
|
43522
|
+
}
|
|
43523
|
+
if (typeof sanitizedParams["publicKey"] === "string") {
|
|
43524
|
+
sanitizedParams["publicKey"] = `${sanitizedParams["publicKey"].substring(0, 20)}...`;
|
|
43525
|
+
}
|
|
43526
|
+
log.info("\u{1F4E4} Complete jsParams (sanitized JSON):", JSON.stringify(sanitizedParams, null, 2));
|
|
43349
43527
|
}
|
|
43350
43528
|
const response = await fetch(url, {
|
|
43351
43529
|
method: "POST",
|
|
@@ -43562,16 +43740,39 @@ var PKPAuthorization = class {
|
|
|
43562
43740
|
);
|
|
43563
43741
|
}
|
|
43564
43742
|
const formattedPkpPublicKey = pkpPublicKey?.startsWith("0x") ? pkpPublicKey.slice(2) : pkpPublicKey;
|
|
43743
|
+
const finalJsParams = {
|
|
43744
|
+
...jsParams,
|
|
43745
|
+
publicKey: formattedPkpPublicKey,
|
|
43746
|
+
ipfsId: cid
|
|
43747
|
+
};
|
|
43748
|
+
if (this.config.debug) {
|
|
43749
|
+
log.info("\u{1F680} Final jsParams being sent to LIT Protocol (IPFS execution):", {
|
|
43750
|
+
ipfsId: cid,
|
|
43751
|
+
jsParamsKeys: Object.keys(finalJsParams),
|
|
43752
|
+
jsParamsCount: Object.keys(finalJsParams).length,
|
|
43753
|
+
contracts: finalJsParams["contracts"] ? {
|
|
43754
|
+
keys: Object.keys(finalJsParams["contracts"]),
|
|
43755
|
+
PositionManager: finalJsParams["contracts"]?.PositionManager || "MISSING",
|
|
43756
|
+
LoanOperationsManagerModule: finalJsParams["contracts"]?.LoanOperationsManagerModule || "MISSING",
|
|
43757
|
+
TermManagerModule: finalJsParams["contracts"]?.TermManagerModule || "MISSING",
|
|
43758
|
+
UCDController: finalJsParams["contracts"]?.UCDController || "MISSING"
|
|
43759
|
+
} : "NOT PROVIDED",
|
|
43760
|
+
contractAddresses: finalJsParams["contractAddresses"] ? {
|
|
43761
|
+
keys: Object.keys(finalJsParams["contractAddresses"])
|
|
43762
|
+
} : "NOT PROVIDED",
|
|
43763
|
+
hasPublicKey: !!finalJsParams["publicKey"],
|
|
43764
|
+
publicKeyPreview: finalJsParams["publicKey"] ? `${finalJsParams["publicKey"].substring(0, 20)}...` : "MISSING",
|
|
43765
|
+
hasAuth: !!finalJsParams["auth"],
|
|
43766
|
+
chain: finalJsParams["chain"],
|
|
43767
|
+
amount: finalJsParams["amount"]
|
|
43768
|
+
});
|
|
43769
|
+
}
|
|
43565
43770
|
const result = await executeLitAction(
|
|
43566
43771
|
litClient,
|
|
43567
43772
|
{
|
|
43568
43773
|
ipfsId: cid,
|
|
43569
43774
|
sessionSigs: sessionSigsResult.sessionSigs,
|
|
43570
|
-
jsParams:
|
|
43571
|
-
...jsParams,
|
|
43572
|
-
publicKey: formattedPkpPublicKey,
|
|
43573
|
-
ipfsId: cid
|
|
43574
|
-
}
|
|
43775
|
+
jsParams: finalJsParams
|
|
43575
43776
|
},
|
|
43576
43777
|
{
|
|
43577
43778
|
maxAttempts: 1,
|
package/package.json
CHANGED