@agether/sdk 1.7.0 → 1.8.0

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
@@ -1117,8 +1117,28 @@ var init_X402Client = __esm({
1117
1117
  constructor(config) {
1118
1118
  this.config = config;
1119
1119
  const privateKey = config.privateKey.startsWith("0x") ? config.privateKey : `0x${config.privateKey}`;
1120
- const signer = (0, import_accounts.privateKeyToAccount)(privateKey);
1121
- this.address = signer.address;
1120
+ const eoaSigner = (0, import_accounts.privateKeyToAccount)(privateKey);
1121
+ let signer;
1122
+ if (config.accountAddress) {
1123
+ const accountAddr = config.accountAddress;
1124
+ signer = (0, import_accounts.toAccount)({
1125
+ address: accountAddr,
1126
+ async signMessage({ message }) {
1127
+ return eoaSigner.signMessage({ message });
1128
+ },
1129
+ async signTransaction(tx) {
1130
+ return eoaSigner.signTransaction(tx);
1131
+ },
1132
+ async signTypedData(typedData) {
1133
+ const sig = await eoaSigner.signTypedData(typedData);
1134
+ return `${sig}00`;
1135
+ }
1136
+ });
1137
+ this.address = accountAddr;
1138
+ } else {
1139
+ signer = eoaSigner;
1140
+ this.address = eoaSigner.address;
1141
+ }
1122
1142
  const client = new import_client.x402Client();
1123
1143
  (0, import_client2.registerExactEvmScheme)(client, { signer });
1124
1144
  this.paidFetch = (0, import_fetch.wrapFetchWithPayment)(fetch, client);
package/dist/index.js CHANGED
@@ -1345,8 +1345,28 @@ var X402Client = class {
1345
1345
  constructor(config) {
1346
1346
  this.config = config;
1347
1347
  const privateKey = config.privateKey.startsWith("0x") ? config.privateKey : `0x${config.privateKey}`;
1348
- const signer = (0, import_accounts.privateKeyToAccount)(privateKey);
1349
- this.address = signer.address;
1348
+ const eoaSigner = (0, import_accounts.privateKeyToAccount)(privateKey);
1349
+ let signer;
1350
+ if (config.accountAddress) {
1351
+ const accountAddr = config.accountAddress;
1352
+ signer = (0, import_accounts.toAccount)({
1353
+ address: accountAddr,
1354
+ async signMessage({ message }) {
1355
+ return eoaSigner.signMessage({ message });
1356
+ },
1357
+ async signTransaction(tx) {
1358
+ return eoaSigner.signTransaction(tx);
1359
+ },
1360
+ async signTypedData(typedData) {
1361
+ const sig = await eoaSigner.signTypedData(typedData);
1362
+ return `${sig}00`;
1363
+ }
1364
+ });
1365
+ this.address = accountAddr;
1366
+ } else {
1367
+ signer = eoaSigner;
1368
+ this.address = eoaSigner.address;
1369
+ }
1350
1370
  const client = new import_client.x402Client();
1351
1371
  (0, import_client2.registerExactEvmScheme)(client, { signer });
1352
1372
  this.paidFetch = (0, import_fetch.wrapFetchWithPayment)(fetch, client);
package/dist/index.mjs CHANGED
@@ -1276,13 +1276,33 @@ import axios2 from "axios";
1276
1276
  import { wrapFetchWithPayment } from "@x402/fetch";
1277
1277
  import { x402Client } from "@x402/core/client";
1278
1278
  import { registerExactEvmScheme } from "@x402/evm/exact/client";
1279
- import { privateKeyToAccount } from "viem/accounts";
1279
+ import { privateKeyToAccount, toAccount } from "viem/accounts";
1280
1280
  var X402Client = class {
1281
1281
  constructor(config) {
1282
1282
  this.config = config;
1283
1283
  const privateKey = config.privateKey.startsWith("0x") ? config.privateKey : `0x${config.privateKey}`;
1284
- const signer = privateKeyToAccount(privateKey);
1285
- this.address = signer.address;
1284
+ const eoaSigner = privateKeyToAccount(privateKey);
1285
+ let signer;
1286
+ if (config.accountAddress) {
1287
+ const accountAddr = config.accountAddress;
1288
+ signer = toAccount({
1289
+ address: accountAddr,
1290
+ async signMessage({ message }) {
1291
+ return eoaSigner.signMessage({ message });
1292
+ },
1293
+ async signTransaction(tx) {
1294
+ return eoaSigner.signTransaction(tx);
1295
+ },
1296
+ async signTypedData(typedData) {
1297
+ const sig = await eoaSigner.signTypedData(typedData);
1298
+ return `${sig}00`;
1299
+ }
1300
+ });
1301
+ this.address = accountAddr;
1302
+ } else {
1303
+ signer = eoaSigner;
1304
+ this.address = eoaSigner.address;
1305
+ }
1286
1306
  const client = new x402Client();
1287
1307
  registerExactEvmScheme(client, { signer });
1288
1308
  this.paidFetch = wrapFetchWithPayment(fetch, client);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agether/sdk",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
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",