@mixrpay/agent-sdk 0.8.1 → 0.8.3

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.

Potentially problematic release.


This version of @mixrpay/agent-sdk might be problematic. Click here for more details.

package/dist/index.cjs CHANGED
@@ -525,7 +525,7 @@ function getAmountUsd(requirements) {
525
525
  }
526
526
 
527
527
  // src/agent-wallet.ts
528
- var SDK_VERSION = "0.8.1";
528
+ var SDK_VERSION = "0.8.3";
529
529
  var DEFAULT_BASE_URL = process.env.MIXRPAY_BASE_URL || "https://www.mixrpay.com";
530
530
  var DEFAULT_TIMEOUT = 3e4;
531
531
  var NETWORKS = {
@@ -1449,14 +1449,25 @@ var AgentWallet = class {
1449
1449
  async getBalance() {
1450
1450
  this.logger.debug("Fetching wallet balance...");
1451
1451
  try {
1452
- const response = await fetch(`${this.baseUrl}/api/v1/wallet/balance`, {
1452
+ const infoResponse = await fetch(`${this.baseUrl}/api/v1/session-key/info`, {
1453
1453
  headers: {
1454
- "X-Session-Key": this.sessionKey.address
1454
+ "X-Session-Key": this.sessionKey.address.toLowerCase()
1455
1455
  }
1456
1456
  });
1457
+ if (!infoResponse.ok) {
1458
+ throw new Error("Failed to get session key info");
1459
+ }
1460
+ const info = await infoResponse.json();
1461
+ const walletAddress = info.wallet_address || info.walletAddress;
1462
+ if (!walletAddress) {
1463
+ throw new Error("No wallet address in session key info");
1464
+ }
1465
+ const response = await fetch(
1466
+ `${this.baseUrl}/api/wallet/balance?address=${walletAddress}&chain=base`
1467
+ );
1457
1468
  if (response.ok) {
1458
1469
  const data = await response.json();
1459
- const balance = data.balance_usd || data.balanceUsd || 0;
1470
+ const balance = data.balance_usdc || data.balance_usd || 0;
1460
1471
  this.logger.debug(`Balance: $${balance}`);
1461
1472
  return balance;
1462
1473
  }
@@ -1518,7 +1529,7 @@ var AgentWallet = class {
1518
1529
  try {
1519
1530
  const response = await fetch(`${this.baseUrl}/api/v1/session-key/info`, {
1520
1531
  headers: {
1521
- "X-Session-Key": this.sessionKey.address
1532
+ "X-Session-Key": this.sessionKey.address.toLowerCase()
1522
1533
  }
1523
1534
  });
1524
1535
  if (response.ok) {
@@ -1573,7 +1584,7 @@ var AgentWallet = class {
1573
1584
  try {
1574
1585
  const response = await fetch(`${this.baseUrl}/api/v1/session-key/stats`, {
1575
1586
  headers: {
1576
- "X-Session-Key": this.sessionKey.address
1587
+ "X-Session-Key": this.sessionKey.address.toLowerCase()
1577
1588
  }
1578
1589
  });
1579
1590
  if (response.ok) {
package/dist/index.d.cts CHANGED
@@ -380,7 +380,7 @@ interface SessionStats {
380
380
  */
381
381
 
382
382
  /** Current SDK version */
383
- declare const SDK_VERSION = "0.8.1";
383
+ declare const SDK_VERSION = "0.8.3";
384
384
  /** Supported networks */
385
385
  declare const NETWORKS: {
386
386
  readonly BASE_MAINNET: {
package/dist/index.d.ts CHANGED
@@ -380,7 +380,7 @@ interface SessionStats {
380
380
  */
381
381
 
382
382
  /** Current SDK version */
383
- declare const SDK_VERSION = "0.8.1";
383
+ declare const SDK_VERSION = "0.8.3";
384
384
  /** Supported networks */
385
385
  declare const NETWORKS: {
386
386
  readonly BASE_MAINNET: {
package/dist/index.js CHANGED
@@ -488,7 +488,7 @@ function getAmountUsd(requirements) {
488
488
  }
489
489
 
490
490
  // src/agent-wallet.ts
491
- var SDK_VERSION = "0.8.1";
491
+ var SDK_VERSION = "0.8.3";
492
492
  var DEFAULT_BASE_URL = process.env.MIXRPAY_BASE_URL || "https://www.mixrpay.com";
493
493
  var DEFAULT_TIMEOUT = 3e4;
494
494
  var NETWORKS = {
@@ -1412,14 +1412,25 @@ var AgentWallet = class {
1412
1412
  async getBalance() {
1413
1413
  this.logger.debug("Fetching wallet balance...");
1414
1414
  try {
1415
- const response = await fetch(`${this.baseUrl}/api/v1/wallet/balance`, {
1415
+ const infoResponse = await fetch(`${this.baseUrl}/api/v1/session-key/info`, {
1416
1416
  headers: {
1417
- "X-Session-Key": this.sessionKey.address
1417
+ "X-Session-Key": this.sessionKey.address.toLowerCase()
1418
1418
  }
1419
1419
  });
1420
+ if (!infoResponse.ok) {
1421
+ throw new Error("Failed to get session key info");
1422
+ }
1423
+ const info = await infoResponse.json();
1424
+ const walletAddress = info.wallet_address || info.walletAddress;
1425
+ if (!walletAddress) {
1426
+ throw new Error("No wallet address in session key info");
1427
+ }
1428
+ const response = await fetch(
1429
+ `${this.baseUrl}/api/wallet/balance?address=${walletAddress}&chain=base`
1430
+ );
1420
1431
  if (response.ok) {
1421
1432
  const data = await response.json();
1422
- const balance = data.balance_usd || data.balanceUsd || 0;
1433
+ const balance = data.balance_usdc || data.balance_usd || 0;
1423
1434
  this.logger.debug(`Balance: $${balance}`);
1424
1435
  return balance;
1425
1436
  }
@@ -1481,7 +1492,7 @@ var AgentWallet = class {
1481
1492
  try {
1482
1493
  const response = await fetch(`${this.baseUrl}/api/v1/session-key/info`, {
1483
1494
  headers: {
1484
- "X-Session-Key": this.sessionKey.address
1495
+ "X-Session-Key": this.sessionKey.address.toLowerCase()
1485
1496
  }
1486
1497
  });
1487
1498
  if (response.ok) {
@@ -1536,7 +1547,7 @@ var AgentWallet = class {
1536
1547
  try {
1537
1548
  const response = await fetch(`${this.baseUrl}/api/v1/session-key/stats`, {
1538
1549
  headers: {
1539
- "X-Session-Key": this.sessionKey.address
1550
+ "X-Session-Key": this.sessionKey.address.toLowerCase()
1540
1551
  }
1541
1552
  });
1542
1553
  if (response.ok) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mixrpay/agent-sdk",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "MixrPay Agent SDK - Enable AI agents to make x402 payments with session keys",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",