@exagent/sdk 0.1.2 → 0.1.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.
package/dist/index.d.mts CHANGED
@@ -357,13 +357,13 @@ declare class ExagentRegistry {
357
357
  */
358
358
  getNextAgentId(): Promise<bigint>;
359
359
  /**
360
- * Generate the raw packed message bytes for wallet linking.
361
- * Must match the contract's abi.encodePacked format exactly:
362
- * keccak256(abi.encodePacked("Link wallet ", wallet, " to Exagent ", agentId, " nonce ", nonce))
360
+ * Generate the message hash for wallet linking.
361
+ * Matches the contract's keccak256(abi.encodePacked(...)) exactly.
362
+ * Sign the returned hash with signMessage({ raw: hash }) to produce a valid signature.
363
363
  * @param wallet The wallet to link
364
364
  * @param agentId The agent ID to link to
365
365
  * @param nonce The current nonce for the wallet
366
- * @returns Raw packed bytes as hex string
366
+ * @returns keccak256 hash of the packed message (32 bytes)
367
367
  */
368
368
  static generateLinkMessage(wallet: Address, agentId: bigint, nonce: bigint): Hex;
369
369
  /**
@@ -1970,9 +1970,11 @@ declare class ExagentClient {
1970
1970
  /**
1971
1971
  * Link an additional wallet to this agent
1972
1972
  * @param wallet Wallet address to link
1973
- * @param signMessage Function to sign a message with the wallet
1973
+ * @param signMessage Function to sign the message hash with the wallet (use signMessage({ raw: hash }))
1974
1974
  */
1975
- linkWallet(wallet: Address, signMessage: (message: string) => Promise<`0x${string}`>): Promise<Hash>;
1975
+ linkWallet(wallet: Address, signMessage: (message: {
1976
+ raw: `0x${string}`;
1977
+ }) => Promise<`0x${string}`>): Promise<Hash>;
1976
1978
  /**
1977
1979
  * Get all wallets linked to this agent
1978
1980
  */
package/dist/index.d.ts CHANGED
@@ -357,13 +357,13 @@ declare class ExagentRegistry {
357
357
  */
358
358
  getNextAgentId(): Promise<bigint>;
359
359
  /**
360
- * Generate the raw packed message bytes for wallet linking.
361
- * Must match the contract's abi.encodePacked format exactly:
362
- * keccak256(abi.encodePacked("Link wallet ", wallet, " to Exagent ", agentId, " nonce ", nonce))
360
+ * Generate the message hash for wallet linking.
361
+ * Matches the contract's keccak256(abi.encodePacked(...)) exactly.
362
+ * Sign the returned hash with signMessage({ raw: hash }) to produce a valid signature.
363
363
  * @param wallet The wallet to link
364
364
  * @param agentId The agent ID to link to
365
365
  * @param nonce The current nonce for the wallet
366
- * @returns Raw packed bytes as hex string
366
+ * @returns keccak256 hash of the packed message (32 bytes)
367
367
  */
368
368
  static generateLinkMessage(wallet: Address, agentId: bigint, nonce: bigint): Hex;
369
369
  /**
@@ -1970,9 +1970,11 @@ declare class ExagentClient {
1970
1970
  /**
1971
1971
  * Link an additional wallet to this agent
1972
1972
  * @param wallet Wallet address to link
1973
- * @param signMessage Function to sign a message with the wallet
1973
+ * @param signMessage Function to sign the message hash with the wallet (use signMessage({ raw: hash }))
1974
1974
  */
1975
- linkWallet(wallet: Address, signMessage: (message: string) => Promise<`0x${string}`>): Promise<Hash>;
1975
+ linkWallet(wallet: Address, signMessage: (message: {
1976
+ raw: `0x${string}`;
1977
+ }) => Promise<`0x${string}`>): Promise<Hash>;
1976
1978
  /**
1977
1979
  * Get all wallets linked to this agent
1978
1980
  */
package/dist/index.js CHANGED
@@ -511,19 +511,19 @@ var ExagentRegistry = class {
511
511
  return nextId;
512
512
  }
513
513
  /**
514
- * Generate the raw packed message bytes for wallet linking.
515
- * Must match the contract's abi.encodePacked format exactly:
516
- * keccak256(abi.encodePacked("Link wallet ", wallet, " to Exagent ", agentId, " nonce ", nonce))
514
+ * Generate the message hash for wallet linking.
515
+ * Matches the contract's keccak256(abi.encodePacked(...)) exactly.
516
+ * Sign the returned hash with signMessage({ raw: hash }) to produce a valid signature.
517
517
  * @param wallet The wallet to link
518
518
  * @param agentId The agent ID to link to
519
519
  * @param nonce The current nonce for the wallet
520
- * @returns Raw packed bytes as hex string
520
+ * @returns keccak256 hash of the packed message (32 bytes)
521
521
  */
522
522
  static generateLinkMessage(wallet, agentId, nonce) {
523
- return (0, import_viem.encodePacked)(
523
+ return (0, import_viem.keccak256)((0, import_viem.encodePacked)(
524
524
  ["string", "address", "string", "uint256", "string", "uint256"],
525
525
  ["Link wallet ", wallet, " to Exagent ", agentId, " nonce ", nonce]
526
- );
526
+ ));
527
527
  }
528
528
  // ============ V4: One Agent Per Wallet ============
529
529
  /**
@@ -655,8 +655,8 @@ var ExagentRegistry = class {
655
655
  * @returns keccak256 hash of the config
656
656
  */
657
657
  static calculateConfigHash(provider, model) {
658
- const { keccak256, encodePacked: encodePacked2 } = require("viem");
659
- return keccak256(encodePacked2(["string", "string"], [provider, model]));
658
+ const { keccak256: keccak2562, encodePacked: encodePacked2 } = require("viem");
659
+ return keccak2562(encodePacked2(["string", "string"], [provider, model]));
660
660
  }
661
661
  };
662
662
 
@@ -1982,14 +1982,14 @@ var ExagentClient = class {
1982
1982
  /**
1983
1983
  * Link an additional wallet to this agent
1984
1984
  * @param wallet Wallet address to link
1985
- * @param signMessage Function to sign a message with the wallet
1985
+ * @param signMessage Function to sign the message hash with the wallet (use signMessage({ raw: hash }))
1986
1986
  */
1987
1987
  async linkWallet(wallet, signMessage) {
1988
1988
  const agentId = await this.getAgentId();
1989
1989
  if (!agentId) throw new Error("Agent not registered");
1990
1990
  const nonce = await this.registry.getNonce(wallet);
1991
- const message = ExagentRegistry.generateLinkMessage(wallet, agentId, nonce);
1992
- const signature = await signMessage(message);
1991
+ const messageHash = ExagentRegistry.generateLinkMessage(wallet, agentId, nonce);
1992
+ const signature = await signMessage({ raw: messageHash });
1993
1993
  return this.registry.linkWallet(agentId, wallet, signature);
1994
1994
  }
1995
1995
  /**
package/dist/index.mjs CHANGED
@@ -15,7 +15,8 @@ import { privateKeyToAccount } from "viem/accounts";
15
15
 
16
16
  // src/contracts/registry.ts
17
17
  import {
18
- encodePacked
18
+ encodePacked,
19
+ keccak256
19
20
  } from "viem";
20
21
  var EXAGENT_REGISTRY_ABI = [
21
22
  {
@@ -485,19 +486,19 @@ var ExagentRegistry = class {
485
486
  return nextId;
486
487
  }
487
488
  /**
488
- * Generate the raw packed message bytes for wallet linking.
489
- * Must match the contract's abi.encodePacked format exactly:
490
- * keccak256(abi.encodePacked("Link wallet ", wallet, " to Exagent ", agentId, " nonce ", nonce))
489
+ * Generate the message hash for wallet linking.
490
+ * Matches the contract's keccak256(abi.encodePacked(...)) exactly.
491
+ * Sign the returned hash with signMessage({ raw: hash }) to produce a valid signature.
491
492
  * @param wallet The wallet to link
492
493
  * @param agentId The agent ID to link to
493
494
  * @param nonce The current nonce for the wallet
494
- * @returns Raw packed bytes as hex string
495
+ * @returns keccak256 hash of the packed message (32 bytes)
495
496
  */
496
497
  static generateLinkMessage(wallet, agentId, nonce) {
497
- return encodePacked(
498
+ return keccak256(encodePacked(
498
499
  ["string", "address", "string", "uint256", "string", "uint256"],
499
500
  ["Link wallet ", wallet, " to Exagent ", agentId, " nonce ", nonce]
500
- );
501
+ ));
501
502
  }
502
503
  // ============ V4: One Agent Per Wallet ============
503
504
  /**
@@ -629,8 +630,8 @@ var ExagentRegistry = class {
629
630
  * @returns keccak256 hash of the config
630
631
  */
631
632
  static calculateConfigHash(provider, model) {
632
- const { keccak256, encodePacked: encodePacked2 } = __require("viem");
633
- return keccak256(encodePacked2(["string", "string"], [provider, model]));
633
+ const { keccak256: keccak2562, encodePacked: encodePacked2 } = __require("viem");
634
+ return keccak2562(encodePacked2(["string", "string"], [provider, model]));
634
635
  }
635
636
  };
636
637
 
@@ -1956,14 +1957,14 @@ var ExagentClient = class {
1956
1957
  /**
1957
1958
  * Link an additional wallet to this agent
1958
1959
  * @param wallet Wallet address to link
1959
- * @param signMessage Function to sign a message with the wallet
1960
+ * @param signMessage Function to sign the message hash with the wallet (use signMessage({ raw: hash }))
1960
1961
  */
1961
1962
  async linkWallet(wallet, signMessage) {
1962
1963
  const agentId = await this.getAgentId();
1963
1964
  if (!agentId) throw new Error("Agent not registered");
1964
1965
  const nonce = await this.registry.getNonce(wallet);
1965
- const message = ExagentRegistry.generateLinkMessage(wallet, agentId, nonce);
1966
- const signature = await signMessage(message);
1966
+ const messageHash = ExagentRegistry.generateLinkMessage(wallet, agentId, nonce);
1967
+ const signature = await signMessage({ raw: messageHash });
1967
1968
  return this.registry.linkWallet(agentId, wallet, signature);
1968
1969
  }
1969
1970
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exagent/sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "TypeScript SDK for Exagent",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",