@gvnrdao/dh-sdk 0.0.21 → 0.0.23

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.
@@ -126,7 +126,7 @@ function getMainnetConfig() {
126
126
  subgraphs: {
127
127
  diamondHandsUrl: "", // To be updated when mainnet subgraph is deployed
128
128
  },
129
- litNetwork: "datil",
129
+ litNetwork: "datil-test",
130
130
  debug: false,
131
131
  };
132
132
  }
@@ -348,12 +348,22 @@ class DiamondHandsSDK {
348
348
  else {
349
349
  if (this.config.debug) {
350
350
  console.log(`🌐 Service mode - initializing LitOps with endpoint: ${this.serviceEndpoint}`);
351
+ console.log(`🔍 Network Configuration for LitOps:`);
352
+ console.log(` LIT Network: ${this.config.litNetwork || 'not specified'}`);
353
+ console.log(` Chain ID: ${this.provider ? 'from provider' : 'not available'}`);
354
+ if (this.provider) {
355
+ const network = await this.provider.getNetwork();
356
+ console.log(` Detected Chain ID: ${network.chainId}`);
357
+ }
358
+ console.log(` Service endpoint: ${this.serviceEndpoint}`);
351
359
  }
352
360
  // Initialize LitOps in service mode
353
361
  this.litOps = new dh_lit_ops_1.LitOps({
354
362
  mode: "service",
355
363
  serviceEndpoint: this.serviceEndpoint,
356
364
  debug: this.config.debug,
365
+ // Note: LitOps in service mode should handle network automatically
366
+ // but let's see if we need to pass it explicitly
357
367
  });
358
368
  }
359
369
  this.initialized = true;
@@ -458,11 +468,46 @@ class DiamondHandsSDK {
458
468
  // Step 1: Create PKP via LitOps service mode (just like the test does)
459
469
  if (this.config.debug) {
460
470
  console.log("📝 Step 1: Creating PKP via LitOps.getNewDiamondHandsLoanPkp()");
471
+ console.log(`🔍 PKP Service Details:`);
472
+ console.log(` Service endpoint: ${this.serviceEndpoint}`);
473
+ console.log(` API endpoint: ${this.serviceEndpoint}/api/lit/pkp/create-diamond-hands-loan`);
474
+ console.log(` LitOps mode: service`);
475
+ console.log(` Expected LIT Network: datil-test (for Sepolia)`);
476
+ console.log(` Expected CID format: 0x12209a72715ecfff9735b1b984c804f24694027d44ddea4822b9cecaf12df842835e`);
477
+ console.log(` ⚠️ NOTE: Service should NOT receive 'QmYjYi4mMNDie1odSetbGa6YvNf8GQFyEGjjkS3YztAY1B' - this indicates wrong CID source`);
478
+ console.log(` ⚠️ NOTE: Service should NOT use 'datil' network - should be 'datil-test'`);
461
479
  }
462
480
  if (!this.litOps) {
463
481
  throw new Error("LitOps not initialized for service mode");
464
482
  }
465
- const pkpResult = await this.litOps.getNewDiamondHandsLoanPkp();
483
+ let pkpResult;
484
+ try {
485
+ pkpResult = await this.litOps.getNewDiamondHandsLoanPkp();
486
+ }
487
+ catch (error) {
488
+ if (this.config.debug) {
489
+ console.error(`❌ PKP Service Call Failed:`);
490
+ console.error(` Error message: ${error instanceof Error ? error.message : String(error)}`);
491
+ // Try to extract more details from axios error or similar
492
+ const axiosError = error;
493
+ if (axiosError.response) {
494
+ console.error(` HTTP Status: ${axiosError.response.status} ${axiosError.response.statusText}`);
495
+ console.error(` Response headers:`, axiosError.response.headers);
496
+ console.error(` Response body:`, axiosError.response.data);
497
+ }
498
+ if (axiosError.request) {
499
+ console.error(` Request URL: ${axiosError.config?.url || 'unknown'}`);
500
+ console.error(` Request method: ${axiosError.config?.method || 'unknown'}`);
501
+ console.error(` Request headers:`, axiosError.config?.headers);
502
+ console.error(` Request data:`, axiosError.config?.data);
503
+ }
504
+ console.error(` Full error object:`, error);
505
+ }
506
+ // Re-throw with enhanced error message
507
+ const enhancedMessage = error instanceof Error ? error.message : String(error);
508
+ const statusInfo = error.response ? ` (HTTP ${error.response.status})` : '';
509
+ throw new Error(`PKP service call failed${statusInfo}: ${enhancedMessage}`);
510
+ }
466
511
  if (!pkpResult.success) {
467
512
  throw new Error(`LitOps PKP creation failed: ${pkpResult.error || "Unknown error"}`);
468
513
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gvnrdao/dh-sdk",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "TypeScript SDK for Diamond Hands Protocol - Bitcoin-backed lending with LIT Protocol PKPs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",