@agether/sdk 2.11.0 → 2.11.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/cli.js CHANGED
@@ -1763,7 +1763,7 @@ var init_AgetherClient = __esm({
1763
1763
  const signer = new import_ethers2.ethers.Wallet(privateKey, provider);
1764
1764
  return new _AgetherClient({ config, signer, agentId, _privateKey: privateKey });
1765
1765
  }
1766
- static fromSigner(signer, agentIdOrChain, chainIdOrConfig) {
1766
+ static async fromSigner(signer, agentIdOrChain, chainIdOrConfig) {
1767
1767
  if (!signer.provider) {
1768
1768
  throw new AgetherError("Signer must be connected to a provider", "NO_PROVIDER");
1769
1769
  }
@@ -1775,6 +1775,14 @@ var init_AgetherClient = __esm({
1775
1775
  } else {
1776
1776
  config = typeof agentIdOrChain === "number" ? getDefaultConfig(agentIdOrChain) : agentIdOrChain;
1777
1777
  }
1778
+ const network = await signer.provider.getNetwork();
1779
+ const actualChainId = Number(network.chainId);
1780
+ if (actualChainId !== config.chainId) {
1781
+ throw new AgetherError(
1782
+ `Chain mismatch: signer is on chain ${actualChainId} but config expects chain ${config.chainId}`,
1783
+ "CHAIN_MISMATCH"
1784
+ );
1785
+ }
1778
1786
  return new _AgetherClient({ config, signer, agentId });
1779
1787
  }
1780
1788
  // ════════════════════════════════════════════════════════
package/dist/index.d.mts CHANGED
@@ -195,26 +195,28 @@ declare class AgetherClient {
195
195
  * Create an AgetherClient from an **external signer** for a **new** agent (no agentId yet).
196
196
  *
197
197
  * Accepts any `ethers.AbstractSigner` — Privy, Bankr, Turnkey, MetaMask, etc.
198
- * The signer **must** already be connected to a provider.
198
+ * The signer **must** already be connected to a provider on the correct chain.
199
+ *
200
+ * Validates that the signer's provider chain matches the requested chain.
199
201
  *
200
202
  * Only `register()` and `getBalances()` are available until registration completes.
201
203
  *
202
204
  * @example
203
205
  * ```ts
204
- * const client = AgetherClient.fromSigner(privySigner, ChainId.Base);
206
+ * const client = await AgetherClient.fromSigner(privySigner, ChainId.Base);
205
207
  * const result = await client.register();
206
208
  * ```
207
209
  */
208
- static fromSigner(signer: ethers.AbstractSigner, chainIdOrConfig: ChainId | AgetherConfig): AgetherClient;
210
+ static fromSigner(signer: ethers.AbstractSigner, chainIdOrConfig: ChainId | AgetherConfig): Promise<AgetherClient>;
209
211
  /**
210
212
  * Create an AgetherClient from an **external signer** for an **existing** agent.
211
213
  *
212
214
  * @example
213
215
  * ```ts
214
- * const client = AgetherClient.fromSigner(privySigner, 42n, ChainId.Base);
216
+ * const client = await AgetherClient.fromSigner(privySigner, 42n, ChainId.Base);
215
217
  * ```
216
218
  */
217
- static fromSigner(signer: ethers.AbstractSigner, agentId: bigint, chainIdOrConfig: ChainId | AgetherConfig): AgetherClient;
219
+ static fromSigner(signer: ethers.AbstractSigner, agentId: bigint, chainIdOrConfig: ChainId | AgetherConfig): Promise<AgetherClient>;
218
220
  /**
219
221
  * Register: create ERC-8004 identity + Safe account in one flow.
220
222
  * If already registered, returns existing state.
package/dist/index.d.ts CHANGED
@@ -195,26 +195,28 @@ declare class AgetherClient {
195
195
  * Create an AgetherClient from an **external signer** for a **new** agent (no agentId yet).
196
196
  *
197
197
  * Accepts any `ethers.AbstractSigner` — Privy, Bankr, Turnkey, MetaMask, etc.
198
- * The signer **must** already be connected to a provider.
198
+ * The signer **must** already be connected to a provider on the correct chain.
199
+ *
200
+ * Validates that the signer's provider chain matches the requested chain.
199
201
  *
200
202
  * Only `register()` and `getBalances()` are available until registration completes.
201
203
  *
202
204
  * @example
203
205
  * ```ts
204
- * const client = AgetherClient.fromSigner(privySigner, ChainId.Base);
206
+ * const client = await AgetherClient.fromSigner(privySigner, ChainId.Base);
205
207
  * const result = await client.register();
206
208
  * ```
207
209
  */
208
- static fromSigner(signer: ethers.AbstractSigner, chainIdOrConfig: ChainId | AgetherConfig): AgetherClient;
210
+ static fromSigner(signer: ethers.AbstractSigner, chainIdOrConfig: ChainId | AgetherConfig): Promise<AgetherClient>;
209
211
  /**
210
212
  * Create an AgetherClient from an **external signer** for an **existing** agent.
211
213
  *
212
214
  * @example
213
215
  * ```ts
214
- * const client = AgetherClient.fromSigner(privySigner, 42n, ChainId.Base);
216
+ * const client = await AgetherClient.fromSigner(privySigner, 42n, ChainId.Base);
215
217
  * ```
216
218
  */
217
- static fromSigner(signer: ethers.AbstractSigner, agentId: bigint, chainIdOrConfig: ChainId | AgetherConfig): AgetherClient;
219
+ static fromSigner(signer: ethers.AbstractSigner, agentId: bigint, chainIdOrConfig: ChainId | AgetherConfig): Promise<AgetherClient>;
218
220
  /**
219
221
  * Register: create ERC-8004 identity + Safe account in one flow.
220
222
  * If already registered, returns existing state.
package/dist/index.js CHANGED
@@ -418,7 +418,7 @@ var AgetherClient = class _AgetherClient {
418
418
  const signer = new import_ethers.ethers.Wallet(privateKey, provider);
419
419
  return new _AgetherClient({ config, signer, agentId, _privateKey: privateKey });
420
420
  }
421
- static fromSigner(signer, agentIdOrChain, chainIdOrConfig) {
421
+ static async fromSigner(signer, agentIdOrChain, chainIdOrConfig) {
422
422
  if (!signer.provider) {
423
423
  throw new AgetherError("Signer must be connected to a provider", "NO_PROVIDER");
424
424
  }
@@ -430,6 +430,14 @@ var AgetherClient = class _AgetherClient {
430
430
  } else {
431
431
  config = typeof agentIdOrChain === "number" ? getDefaultConfig(agentIdOrChain) : agentIdOrChain;
432
432
  }
433
+ const network = await signer.provider.getNetwork();
434
+ const actualChainId = Number(network.chainId);
435
+ if (actualChainId !== config.chainId) {
436
+ throw new AgetherError(
437
+ `Chain mismatch: signer is on chain ${actualChainId} but config expects chain ${config.chainId}`,
438
+ "CHAIN_MISMATCH"
439
+ );
440
+ }
433
441
  return new _AgetherClient({ config, signer, agentId });
434
442
  }
435
443
  // ════════════════════════════════════════════════════════
package/dist/index.mjs CHANGED
@@ -343,7 +343,7 @@ var AgetherClient = class _AgetherClient {
343
343
  const signer = new ethers.Wallet(privateKey, provider);
344
344
  return new _AgetherClient({ config, signer, agentId, _privateKey: privateKey });
345
345
  }
346
- static fromSigner(signer, agentIdOrChain, chainIdOrConfig) {
346
+ static async fromSigner(signer, agentIdOrChain, chainIdOrConfig) {
347
347
  if (!signer.provider) {
348
348
  throw new AgetherError("Signer must be connected to a provider", "NO_PROVIDER");
349
349
  }
@@ -355,6 +355,14 @@ var AgetherClient = class _AgetherClient {
355
355
  } else {
356
356
  config = typeof agentIdOrChain === "number" ? getDefaultConfig(agentIdOrChain) : agentIdOrChain;
357
357
  }
358
+ const network = await signer.provider.getNetwork();
359
+ const actualChainId = Number(network.chainId);
360
+ if (actualChainId !== config.chainId) {
361
+ throw new AgetherError(
362
+ `Chain mismatch: signer is on chain ${actualChainId} but config expects chain ${config.chainId}`,
363
+ "CHAIN_MISMATCH"
364
+ );
365
+ }
358
366
  return new _AgetherClient({ config, signer, agentId });
359
367
  }
360
368
  // ════════════════════════════════════════════════════════
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agether/sdk",
3
- "version": "2.11.0",
3
+ "version": "2.11.1",
4
4
  "description": "TypeScript SDK for Agether - autonomous credit for AI agents on Ethereum & Base",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",