@agether/sdk 1.4.0 → 1.4.1

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.d.mts CHANGED
@@ -917,7 +917,7 @@ declare class MorphoCreditClient {
917
917
  constructor(config: MorphoCreditConfig, collaterals?: Record<string, CollateralToken>);
918
918
  private resolveToken;
919
919
  /**
920
- * Resolve agentId from config, cache, or on-chain lookup.
920
+ * Get agentId from config or cache. Call register() first if not set.
921
921
  */
922
922
  getAgentId(): Promise<string>;
923
923
  /**
package/dist/index.d.ts CHANGED
@@ -917,7 +917,7 @@ declare class MorphoCreditClient {
917
917
  constructor(config: MorphoCreditConfig, collaterals?: Record<string, CollateralToken>);
918
918
  private resolveToken;
919
919
  /**
920
- * Resolve agentId from config, cache, or on-chain lookup.
920
+ * Get agentId from config or cache. Call register() first if not set.
921
921
  */
922
922
  getAgentId(): Promise<string>;
923
923
  /**
package/dist/index.js CHANGED
@@ -1532,21 +1532,11 @@ var _MorphoCreditClient = class _MorphoCreditClient {
1532
1532
  return token;
1533
1533
  }
1534
1534
  /**
1535
- * Resolve agentId from config, cache, or on-chain lookup.
1535
+ * Get agentId from config or cache. Call register() first if not set.
1536
1536
  */
1537
1537
  async getAgentId() {
1538
1538
  if (this.resolvedAgentId) return this.resolvedAgentId;
1539
- if (!this.config.contracts.agentRegistry) {
1540
- throw new Error("No agentId configured and no agentRegistry address to auto-resolve. Register first.");
1541
- }
1542
- const registry = new import_ethers5.Contract(this.config.contracts.agentRegistry, _MorphoCreditClient.ERC8004_ABI, this.signer.provider);
1543
- const balance = await registry.balanceOf(this.signer.address);
1544
- if (balance === 0n) {
1545
- throw new Error("No agent registered. Use register() first.");
1546
- }
1547
- const tokenId = await registry.tokenOfOwnerByIndex(this.signer.address, 0);
1548
- this.resolvedAgentId = tokenId.toString();
1549
- return this.resolvedAgentId;
1539
+ throw new Error("No agentId. Pass agentId in config or call register() first.");
1550
1540
  }
1551
1541
  /**
1552
1542
  * Get the AgentAccount address for the configured agentId.
@@ -1650,19 +1640,6 @@ var _MorphoCreditClient = class _MorphoCreditClient {
1650
1640
  alreadyRegistered: true
1651
1641
  };
1652
1642
  }
1653
- const balance = await registry.balanceOf(this.signer.address);
1654
- if (balance > 0n) {
1655
- const tokenId = await registry.tokenOfOwnerByIndex(this.signer.address, 0);
1656
- this.resolvedAgentId = tokenId.toString();
1657
- const accountAddr2 = await this.factory.getAccount(this.resolvedAgentId);
1658
- return {
1659
- tx: "",
1660
- agentId: this.resolvedAgentId,
1661
- address: this.signer.address,
1662
- agentAccount: accountAddr2,
1663
- alreadyRegistered: true
1664
- };
1665
- }
1666
1643
  const registrationFile = JSON.stringify({
1667
1644
  type: "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
1668
1645
  name,
@@ -2104,8 +2081,7 @@ var _MorphoCreditClient = class _MorphoCreditClient {
2104
2081
  _MorphoCreditClient.ERC8004_ABI = [
2105
2082
  "function register(string agentURI) returns (uint256)",
2106
2083
  "function ownerOf(uint256 tokenId) view returns (address)",
2107
- "function balanceOf(address owner) view returns (uint256)",
2108
- "function tokenOfOwnerByIndex(address owner, uint256 index) view returns (uint256)"
2084
+ "function balanceOf(address owner) view returns (uint256)"
2109
2085
  ];
2110
2086
  // ══════════════════════════════════════════
2111
2087
  // LTV Pre-check
package/dist/index.mjs CHANGED
@@ -1461,21 +1461,11 @@ var _MorphoCreditClient = class _MorphoCreditClient {
1461
1461
  return token;
1462
1462
  }
1463
1463
  /**
1464
- * Resolve agentId from config, cache, or on-chain lookup.
1464
+ * Get agentId from config or cache. Call register() first if not set.
1465
1465
  */
1466
1466
  async getAgentId() {
1467
1467
  if (this.resolvedAgentId) return this.resolvedAgentId;
1468
- if (!this.config.contracts.agentRegistry) {
1469
- throw new Error("No agentId configured and no agentRegistry address to auto-resolve. Register first.");
1470
- }
1471
- const registry = new Contract3(this.config.contracts.agentRegistry, _MorphoCreditClient.ERC8004_ABI, this.signer.provider);
1472
- const balance = await registry.balanceOf(this.signer.address);
1473
- if (balance === 0n) {
1474
- throw new Error("No agent registered. Use register() first.");
1475
- }
1476
- const tokenId = await registry.tokenOfOwnerByIndex(this.signer.address, 0);
1477
- this.resolvedAgentId = tokenId.toString();
1478
- return this.resolvedAgentId;
1468
+ throw new Error("No agentId. Pass agentId in config or call register() first.");
1479
1469
  }
1480
1470
  /**
1481
1471
  * Get the AgentAccount address for the configured agentId.
@@ -1579,19 +1569,6 @@ var _MorphoCreditClient = class _MorphoCreditClient {
1579
1569
  alreadyRegistered: true
1580
1570
  };
1581
1571
  }
1582
- const balance = await registry.balanceOf(this.signer.address);
1583
- if (balance > 0n) {
1584
- const tokenId = await registry.tokenOfOwnerByIndex(this.signer.address, 0);
1585
- this.resolvedAgentId = tokenId.toString();
1586
- const accountAddr2 = await this.factory.getAccount(this.resolvedAgentId);
1587
- return {
1588
- tx: "",
1589
- agentId: this.resolvedAgentId,
1590
- address: this.signer.address,
1591
- agentAccount: accountAddr2,
1592
- alreadyRegistered: true
1593
- };
1594
- }
1595
1572
  const registrationFile = JSON.stringify({
1596
1573
  type: "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
1597
1574
  name,
@@ -2033,8 +2010,7 @@ var _MorphoCreditClient = class _MorphoCreditClient {
2033
2010
  _MorphoCreditClient.ERC8004_ABI = [
2034
2011
  "function register(string agentURI) returns (uint256)",
2035
2012
  "function ownerOf(uint256 tokenId) view returns (address)",
2036
- "function balanceOf(address owner) view returns (uint256)",
2037
- "function tokenOfOwnerByIndex(address owner, uint256 index) view returns (uint256)"
2013
+ "function balanceOf(address owner) view returns (uint256)"
2038
2014
  ];
2039
2015
  // ══════════════════════════════════════════
2040
2016
  // LTV Pre-check
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agether/sdk",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "TypeScript SDK for Agether - autonomous credit for AI agents on Base",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",