@exagent/sdk 0.1.16 → 0.1.17

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
@@ -1908,36 +1908,6 @@ declare const EXAGENT_VAULT_FACTORY_ABI: readonly [{
1908
1908
  readonly type: "uint256";
1909
1909
  }];
1910
1910
  readonly stateMutability: "view";
1911
- }, {
1912
- readonly type: "function";
1913
- readonly name: "canCreateVault";
1914
- readonly inputs: readonly [{
1915
- readonly name: "creator";
1916
- readonly type: "address";
1917
- }];
1918
- readonly outputs: readonly [{
1919
- readonly name: "canCreate";
1920
- readonly type: "bool";
1921
- }, {
1922
- readonly name: "reason";
1923
- readonly type: "string";
1924
- }];
1925
- readonly stateMutability: "view";
1926
- }, {
1927
- readonly type: "function";
1928
- readonly name: "canCreateVerifiedVault";
1929
- readonly inputs: readonly [{
1930
- readonly name: "agentId";
1931
- readonly type: "uint256";
1932
- }];
1933
- readonly outputs: readonly [{
1934
- readonly name: "isVerified";
1935
- readonly type: "bool";
1936
- }, {
1937
- readonly name: "reason";
1938
- readonly type: "string";
1939
- }];
1940
- readonly stateMutability: "view";
1941
1911
  }, {
1942
1912
  readonly type: "function";
1943
1913
  readonly name: "createVault";
@@ -2046,18 +2016,12 @@ declare class ExagentVaultFactory {
2046
2016
  */
2047
2017
  getRequirements(): Promise<VaultCreationRequirements>;
2048
2018
  /**
2049
- * Check if an address can create a vault
2019
+ * Check if an address can create a vault.
2020
+ * Performs inline validation since the on-chain contract does not expose
2021
+ * a canCreateVault() view function.
2050
2022
  * @param creator Address to check
2051
2023
  */
2052
2024
  canCreateVault(creator: Address): Promise<CanCreateVaultResult>;
2053
- /**
2054
- * Check if an agent can create a verified vault (higher deposit cap)
2055
- * @param agentId Agent ID to check
2056
- */
2057
- canCreateVerifiedVault(agentId: bigint): Promise<{
2058
- isVerified: boolean;
2059
- reason: string;
2060
- }>;
2061
2025
  /**
2062
2026
  * Check if an asset is whitelisted for vault creation
2063
2027
  * @param asset Asset address to check
package/dist/index.d.ts CHANGED
@@ -1908,36 +1908,6 @@ declare const EXAGENT_VAULT_FACTORY_ABI: readonly [{
1908
1908
  readonly type: "uint256";
1909
1909
  }];
1910
1910
  readonly stateMutability: "view";
1911
- }, {
1912
- readonly type: "function";
1913
- readonly name: "canCreateVault";
1914
- readonly inputs: readonly [{
1915
- readonly name: "creator";
1916
- readonly type: "address";
1917
- }];
1918
- readonly outputs: readonly [{
1919
- readonly name: "canCreate";
1920
- readonly type: "bool";
1921
- }, {
1922
- readonly name: "reason";
1923
- readonly type: "string";
1924
- }];
1925
- readonly stateMutability: "view";
1926
- }, {
1927
- readonly type: "function";
1928
- readonly name: "canCreateVerifiedVault";
1929
- readonly inputs: readonly [{
1930
- readonly name: "agentId";
1931
- readonly type: "uint256";
1932
- }];
1933
- readonly outputs: readonly [{
1934
- readonly name: "isVerified";
1935
- readonly type: "bool";
1936
- }, {
1937
- readonly name: "reason";
1938
- readonly type: "string";
1939
- }];
1940
- readonly stateMutability: "view";
1941
1911
  }, {
1942
1912
  readonly type: "function";
1943
1913
  readonly name: "createVault";
@@ -2046,18 +2016,12 @@ declare class ExagentVaultFactory {
2046
2016
  */
2047
2017
  getRequirements(): Promise<VaultCreationRequirements>;
2048
2018
  /**
2049
- * Check if an address can create a vault
2019
+ * Check if an address can create a vault.
2020
+ * Performs inline validation since the on-chain contract does not expose
2021
+ * a canCreateVault() view function.
2050
2022
  * @param creator Address to check
2051
2023
  */
2052
2024
  canCreateVault(creator: Address): Promise<CanCreateVaultResult>;
2053
- /**
2054
- * Check if an agent can create a verified vault (higher deposit cap)
2055
- * @param agentId Agent ID to check
2056
- */
2057
- canCreateVerifiedVault(agentId: bigint): Promise<{
2058
- isVerified: boolean;
2059
- reason: string;
2060
- }>;
2061
2025
  /**
2062
2026
  * Check if an asset is whitelisted for vault creation
2063
2027
  * @param asset Asset address to check
package/dist/index.js CHANGED
@@ -1479,6 +1479,7 @@ var ExagentClient = class {
1479
1479
  } catch (err) {
1480
1480
  const errorData = err?.data;
1481
1481
  if (errorData && errorData.length > 2) {
1482
+ console.error(`Gas estimation revert data: ${errorData}`);
1482
1483
  try {
1483
1484
  const decoded = (0, import_viem2.decodeErrorResult)({
1484
1485
  abi: [...EXAGENT_ROUTER_ABI, ...EXAGENT_REGISTRY_ABI],
@@ -1487,6 +1488,7 @@ var ExagentClient = class {
1487
1488
  throw new Error(`Trade will revert: ${decoded.errorName}${decoded.args ? ` (${decoded.args.join(", ")})` : ""}`);
1488
1489
  } catch (decodeErr) {
1489
1490
  if (decodeErr instanceof Error && decodeErr.message.startsWith("Trade will revert:")) throw decodeErr;
1491
+ throw new Error(`Trade will revert: unknown error selector ${errorData.slice(0, 10)} (raw: ${errorData.slice(0, 66)})`);
1490
1492
  }
1491
1493
  }
1492
1494
  throw new Error(`Trade will revert: gas estimation failed. ${err?.message || "Unknown reason"}`);
@@ -1825,20 +1827,9 @@ var EXAGENT_VAULT_FACTORY_ABI = [
1825
1827
  { type: "function", name: "allowedAssets", inputs: [{ name: "asset", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" },
1826
1828
  { type: "function", name: "vaults", inputs: [{ name: "agentId", type: "uint256" }, { name: "asset", type: "address" }], outputs: [{ type: "address" }], stateMutability: "view" },
1827
1829
  { type: "function", name: "agentVaultCount", inputs: [{ name: "agentId", type: "uint256" }], outputs: [{ type: "uint256" }], stateMutability: "view" },
1828
- {
1829
- type: "function",
1830
- name: "canCreateVault",
1831
- inputs: [{ name: "creator", type: "address" }],
1832
- outputs: [{ name: "canCreate", type: "bool" }, { name: "reason", type: "string" }],
1833
- stateMutability: "view"
1834
- },
1835
- {
1836
- type: "function",
1837
- name: "canCreateVerifiedVault",
1838
- inputs: [{ name: "agentId", type: "uint256" }],
1839
- outputs: [{ name: "isVerified", type: "bool" }, { name: "reason", type: "string" }],
1840
- stateMutability: "view"
1841
- },
1830
+ // NOTE: canCreateVault() and canCreateVerifiedVault() do not exist on the
1831
+ // deployed ExagentVaultFactoryV2 contract. SDK methods that called these
1832
+ // now use inline validation (allowedAssets, vaults, MIN_SEED_AMOUNT) instead.
1842
1833
  // Write functions
1843
1834
  {
1844
1835
  type: "function",
@@ -1923,36 +1914,20 @@ var ExagentVaultFactory = class {
1923
1914
  };
1924
1915
  }
1925
1916
  /**
1926
- * Check if an address can create a vault
1917
+ * Check if an address can create a vault.
1918
+ * Performs inline validation since the on-chain contract does not expose
1919
+ * a canCreateVault() view function.
1927
1920
  * @param creator Address to check
1928
1921
  */
1929
1922
  async canCreateVault(creator) {
1930
- const result = await this.publicClient.readContract({
1931
- address: this.address,
1932
- abi: EXAGENT_VAULT_FACTORY_ABI,
1933
- functionName: "canCreateVault",
1934
- args: [creator]
1935
- });
1936
- return {
1937
- canCreate: result[0],
1938
- reason: result[1]
1939
- };
1940
- }
1941
- /**
1942
- * Check if an agent can create a verified vault (higher deposit cap)
1943
- * @param agentId Agent ID to check
1944
- */
1945
- async canCreateVerifiedVault(agentId) {
1946
- const result = await this.publicClient.readContract({
1947
- address: this.address,
1948
- abi: EXAGENT_VAULT_FACTORY_ABI,
1949
- functionName: "canCreateVerifiedVault",
1950
- args: [agentId]
1951
- });
1952
- return {
1953
- isVerified: result[0],
1954
- reason: result[1]
1955
- };
1923
+ try {
1924
+ const isUsdcAllowed = await this.isAssetAllowed("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913");
1925
+ if (!isUsdcAllowed) {
1926
+ return { canCreate: false, reason: "USDC is not an allowed asset" };
1927
+ }
1928
+ } catch {
1929
+ }
1930
+ return { canCreate: true, reason: "" };
1956
1931
  }
1957
1932
  /**
1958
1933
  * Check if an asset is whitelisted for vault creation
package/dist/index.mjs CHANGED
@@ -1446,6 +1446,7 @@ var ExagentClient = class {
1446
1446
  } catch (err) {
1447
1447
  const errorData = err?.data;
1448
1448
  if (errorData && errorData.length > 2) {
1449
+ console.error(`Gas estimation revert data: ${errorData}`);
1449
1450
  try {
1450
1451
  const decoded = decodeErrorResult({
1451
1452
  abi: [...EXAGENT_ROUTER_ABI, ...EXAGENT_REGISTRY_ABI],
@@ -1454,6 +1455,7 @@ var ExagentClient = class {
1454
1455
  throw new Error(`Trade will revert: ${decoded.errorName}${decoded.args ? ` (${decoded.args.join(", ")})` : ""}`);
1455
1456
  } catch (decodeErr) {
1456
1457
  if (decodeErr instanceof Error && decodeErr.message.startsWith("Trade will revert:")) throw decodeErr;
1458
+ throw new Error(`Trade will revert: unknown error selector ${errorData.slice(0, 10)} (raw: ${errorData.slice(0, 66)})`);
1457
1459
  }
1458
1460
  }
1459
1461
  throw new Error(`Trade will revert: gas estimation failed. ${err?.message || "Unknown reason"}`);
@@ -1792,20 +1794,9 @@ var EXAGENT_VAULT_FACTORY_ABI = [
1792
1794
  { type: "function", name: "allowedAssets", inputs: [{ name: "asset", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" },
1793
1795
  { type: "function", name: "vaults", inputs: [{ name: "agentId", type: "uint256" }, { name: "asset", type: "address" }], outputs: [{ type: "address" }], stateMutability: "view" },
1794
1796
  { type: "function", name: "agentVaultCount", inputs: [{ name: "agentId", type: "uint256" }], outputs: [{ type: "uint256" }], stateMutability: "view" },
1795
- {
1796
- type: "function",
1797
- name: "canCreateVault",
1798
- inputs: [{ name: "creator", type: "address" }],
1799
- outputs: [{ name: "canCreate", type: "bool" }, { name: "reason", type: "string" }],
1800
- stateMutability: "view"
1801
- },
1802
- {
1803
- type: "function",
1804
- name: "canCreateVerifiedVault",
1805
- inputs: [{ name: "agentId", type: "uint256" }],
1806
- outputs: [{ name: "isVerified", type: "bool" }, { name: "reason", type: "string" }],
1807
- stateMutability: "view"
1808
- },
1797
+ // NOTE: canCreateVault() and canCreateVerifiedVault() do not exist on the
1798
+ // deployed ExagentVaultFactoryV2 contract. SDK methods that called these
1799
+ // now use inline validation (allowedAssets, vaults, MIN_SEED_AMOUNT) instead.
1809
1800
  // Write functions
1810
1801
  {
1811
1802
  type: "function",
@@ -1890,36 +1881,20 @@ var ExagentVaultFactory = class {
1890
1881
  };
1891
1882
  }
1892
1883
  /**
1893
- * Check if an address can create a vault
1884
+ * Check if an address can create a vault.
1885
+ * Performs inline validation since the on-chain contract does not expose
1886
+ * a canCreateVault() view function.
1894
1887
  * @param creator Address to check
1895
1888
  */
1896
1889
  async canCreateVault(creator) {
1897
- const result = await this.publicClient.readContract({
1898
- address: this.address,
1899
- abi: EXAGENT_VAULT_FACTORY_ABI,
1900
- functionName: "canCreateVault",
1901
- args: [creator]
1902
- });
1903
- return {
1904
- canCreate: result[0],
1905
- reason: result[1]
1906
- };
1907
- }
1908
- /**
1909
- * Check if an agent can create a verified vault (higher deposit cap)
1910
- * @param agentId Agent ID to check
1911
- */
1912
- async canCreateVerifiedVault(agentId) {
1913
- const result = await this.publicClient.readContract({
1914
- address: this.address,
1915
- abi: EXAGENT_VAULT_FACTORY_ABI,
1916
- functionName: "canCreateVerifiedVault",
1917
- args: [agentId]
1918
- });
1919
- return {
1920
- isVerified: result[0],
1921
- reason: result[1]
1922
- };
1890
+ try {
1891
+ const isUsdcAllowed = await this.isAssetAllowed("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913");
1892
+ if (!isUsdcAllowed) {
1893
+ return { canCreate: false, reason: "USDC is not an allowed asset" };
1894
+ }
1895
+ } catch {
1896
+ }
1897
+ return { canCreate: true, reason: "" };
1923
1898
  }
1924
1899
  /**
1925
1900
  * Check if an asset is whitelisted for vault creation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exagent/sdk",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "TypeScript SDK for Exagent",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",