@mixrpay/agent-sdk 0.8.0 → 0.8.2

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.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.0";
528
+ var SDK_VERSION = "0.8.2";
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}/v1/wallet/balance`, {
1452
+ const infoResponse = await fetch(`${this.baseUrl}/api/v1/session-key/info`, {
1453
1453
  headers: {
1454
1454
  "X-Session-Key": this.sessionKey.address
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
  }
@@ -1516,7 +1527,7 @@ var AgentWallet = class {
1516
1527
  }
1517
1528
  this.logger.debug("Fetching session key info...");
1518
1529
  try {
1519
- const response = await fetch(`${this.baseUrl}/v1/session-key/info`, {
1530
+ const response = await fetch(`${this.baseUrl}/api/v1/session-key/info`, {
1520
1531
  headers: {
1521
1532
  "X-Session-Key": this.sessionKey.address
1522
1533
  }
@@ -1571,7 +1582,7 @@ var AgentWallet = class {
1571
1582
  async getSpendingStats() {
1572
1583
  this.logger.debug("Fetching spending stats...");
1573
1584
  try {
1574
- const response = await fetch(`${this.baseUrl}/v1/session-key/stats`, {
1585
+ const response = await fetch(`${this.baseUrl}/api/v1/session-key/stats`, {
1575
1586
  headers: {
1576
1587
  "X-Session-Key": this.sessionKey.address
1577
1588
  }
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.0";
383
+ declare const SDK_VERSION = "0.8.2";
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.0";
383
+ declare const SDK_VERSION = "0.8.2";
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.0";
491
+ var SDK_VERSION = "0.8.2";
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}/v1/wallet/balance`, {
1415
+ const infoResponse = await fetch(`${this.baseUrl}/api/v1/session-key/info`, {
1416
1416
  headers: {
1417
1417
  "X-Session-Key": this.sessionKey.address
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
  }
@@ -1479,7 +1490,7 @@ var AgentWallet = class {
1479
1490
  }
1480
1491
  this.logger.debug("Fetching session key info...");
1481
1492
  try {
1482
- const response = await fetch(`${this.baseUrl}/v1/session-key/info`, {
1493
+ const response = await fetch(`${this.baseUrl}/api/v1/session-key/info`, {
1483
1494
  headers: {
1484
1495
  "X-Session-Key": this.sessionKey.address
1485
1496
  }
@@ -1534,7 +1545,7 @@ var AgentWallet = class {
1534
1545
  async getSpendingStats() {
1535
1546
  this.logger.debug("Fetching spending stats...");
1536
1547
  try {
1537
- const response = await fetch(`${this.baseUrl}/v1/session-key/stats`, {
1548
+ const response = await fetch(`${this.baseUrl}/api/v1/session-key/stats`, {
1538
1549
  headers: {
1539
1550
  "X-Session-Key": this.sessionKey.address
1540
1551
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mixrpay/agent-sdk",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
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",