@agether/sdk 1.5.2 → 1.5.4
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/{MorphoClient-3UAKN2VR.mjs → MorphoClient-AV27HBOF.mjs} +1 -1
- package/dist/{chunk-GAFDBPDW.mjs → chunk-OMCWZ3VN.mjs} +7 -2
- package/dist/cli.js +29 -20
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +29 -20
- package/dist/index.mjs +1093 -31
- package/package.json +1 -1
|
@@ -224,8 +224,8 @@ var MorphoClient = class {
|
|
|
224
224
|
const addrs = { ...defaultCfg.contracts, ...config.contracts };
|
|
225
225
|
this.accountFactory = new Contract(addrs.accountFactory, ACCOUNT_FACTORY_ABI, this.wallet);
|
|
226
226
|
this.morphoBlue = new Contract(addrs.morphoBlue, MORPHO_BLUE_ABI, this.provider);
|
|
227
|
-
this.agentReputation = new Contract(addrs.agentReputation, AGENT_REPUTATION_ABI, this.
|
|
228
|
-
this.identityRegistry = new Contract(addrs.identityRegistry, IDENTITY_REGISTRY_ABI, this.
|
|
227
|
+
this.agentReputation = new Contract(addrs.agentReputation, AGENT_REPUTATION_ABI, this.wallet);
|
|
228
|
+
this.identityRegistry = new Contract(addrs.identityRegistry, IDENTITY_REGISTRY_ABI, this.wallet);
|
|
229
229
|
}
|
|
230
230
|
// ════════════════════════════════════════════════════════
|
|
231
231
|
// Account Management
|
|
@@ -266,6 +266,11 @@ var MorphoClient = class {
|
|
|
266
266
|
let agentId;
|
|
267
267
|
if (balance > 0n && this.agentId) {
|
|
268
268
|
agentId = BigInt(this.agentId);
|
|
269
|
+
} else if (balance > 0n) {
|
|
270
|
+
throw new AgetherError(
|
|
271
|
+
"Wallet already has an ERC-8004 identity but agentId is unknown. Pass agentId in config.",
|
|
272
|
+
"AGENT_ID_UNKNOWN"
|
|
273
|
+
);
|
|
269
274
|
} else {
|
|
270
275
|
const regTx = await this.identityRegistry.register();
|
|
271
276
|
const regReceipt = await regTx.wait();
|
package/dist/cli.js
CHANGED
|
@@ -232,8 +232,8 @@ var init_MorphoClient = __esm({
|
|
|
232
232
|
const addrs = { ...defaultCfg.contracts, ...config.contracts };
|
|
233
233
|
this.accountFactory = new import_ethers.Contract(addrs.accountFactory, ACCOUNT_FACTORY_ABI, this.wallet);
|
|
234
234
|
this.morphoBlue = new import_ethers.Contract(addrs.morphoBlue, MORPHO_BLUE_ABI, this.provider);
|
|
235
|
-
this.agentReputation = new import_ethers.Contract(addrs.agentReputation, AGENT_REPUTATION_ABI, this.
|
|
236
|
-
this.identityRegistry = new import_ethers.Contract(addrs.identityRegistry, IDENTITY_REGISTRY_ABI, this.
|
|
235
|
+
this.agentReputation = new import_ethers.Contract(addrs.agentReputation, AGENT_REPUTATION_ABI, this.wallet);
|
|
236
|
+
this.identityRegistry = new import_ethers.Contract(addrs.identityRegistry, IDENTITY_REGISTRY_ABI, this.wallet);
|
|
237
237
|
}
|
|
238
238
|
// ════════════════════════════════════════════════════════
|
|
239
239
|
// Account Management
|
|
@@ -256,6 +256,25 @@ var init_MorphoClient = __esm({
|
|
|
256
256
|
getWalletAddress() {
|
|
257
257
|
return this.wallet.address;
|
|
258
258
|
}
|
|
259
|
+
/** Mint a new ERC-8004 identity and return the agentId. */
|
|
260
|
+
async _mintNewIdentity() {
|
|
261
|
+
const regTx = await this.identityRegistry.register();
|
|
262
|
+
const regReceipt = await regTx.wait();
|
|
263
|
+
let agentId = 0n;
|
|
264
|
+
for (const log of regReceipt.logs) {
|
|
265
|
+
try {
|
|
266
|
+
const parsed = this.identityRegistry.interface.parseLog({ topics: log.topics, data: log.data });
|
|
267
|
+
if (parsed?.name === "Transfer") {
|
|
268
|
+
agentId = parsed.args[2];
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
} catch {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (agentId === 0n) throw new AgetherError("Failed to parse agentId from registration", "PARSE_ERROR");
|
|
276
|
+
return agentId;
|
|
277
|
+
}
|
|
259
278
|
/**
|
|
260
279
|
* Register: create ERC-8004 identity + AgentAccount in one flow.
|
|
261
280
|
* If already registered, returns existing state.
|
|
@@ -270,26 +289,16 @@ var init_MorphoClient = __esm({
|
|
|
270
289
|
return { agentId: this.agentId, address: eoaAddr, agentAccount: acct, alreadyRegistered: true };
|
|
271
290
|
}
|
|
272
291
|
}
|
|
273
|
-
const balance = await this.identityRegistry.balanceOf(eoaAddr);
|
|
274
292
|
let agentId;
|
|
275
|
-
if (
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
for (const log of regReceipt.logs) {
|
|
282
|
-
try {
|
|
283
|
-
const parsed = this.identityRegistry.interface.parseLog({ topics: log.topics, data: log.data });
|
|
284
|
-
if (parsed?.name === "Transfer") {
|
|
285
|
-
agentId = parsed.args[2];
|
|
286
|
-
break;
|
|
287
|
-
}
|
|
288
|
-
} catch {
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
293
|
+
if (this.agentId) {
|
|
294
|
+
const balance = await this.identityRegistry.balanceOf(eoaAddr);
|
|
295
|
+
if (balance > 0n) {
|
|
296
|
+
agentId = BigInt(this.agentId);
|
|
297
|
+
} else {
|
|
298
|
+
agentId = await this._mintNewIdentity();
|
|
291
299
|
}
|
|
292
|
-
|
|
300
|
+
} else {
|
|
301
|
+
agentId = await this._mintNewIdentity();
|
|
293
302
|
}
|
|
294
303
|
this.agentId = agentId.toString();
|
|
295
304
|
const acctExists = await this.accountFactory.accountExists(agentId);
|
package/dist/cli.mjs
CHANGED
|
@@ -44,7 +44,7 @@ async function waitForTx(tx, retries = 5) {
|
|
|
44
44
|
throw new Error("Failed to get transaction receipt after retries");
|
|
45
45
|
}
|
|
46
46
|
async function getMorphoClient(config) {
|
|
47
|
-
const { MorphoClient } = await import("./MorphoClient-
|
|
47
|
+
const { MorphoClient } = await import("./MorphoClient-AV27HBOF.mjs");
|
|
48
48
|
return new MorphoClient({
|
|
49
49
|
privateKey: config.privateKey,
|
|
50
50
|
rpcUrl: config.rpcUrl,
|
package/dist/index.d.mts
CHANGED
|
@@ -287,6 +287,8 @@ declare class MorphoClient {
|
|
|
287
287
|
getAccountAddress(): Promise<string>;
|
|
288
288
|
getAgentId(): string;
|
|
289
289
|
getWalletAddress(): string;
|
|
290
|
+
/** Mint a new ERC-8004 identity and return the agentId. */
|
|
291
|
+
private _mintNewIdentity;
|
|
290
292
|
/**
|
|
291
293
|
* Register: create ERC-8004 identity + AgentAccount in one flow.
|
|
292
294
|
* If already registered, returns existing state.
|
package/dist/index.d.ts
CHANGED
|
@@ -287,6 +287,8 @@ declare class MorphoClient {
|
|
|
287
287
|
getAccountAddress(): Promise<string>;
|
|
288
288
|
getAgentId(): string;
|
|
289
289
|
getWalletAddress(): string;
|
|
290
|
+
/** Mint a new ERC-8004 identity and return the agentId. */
|
|
291
|
+
private _mintNewIdentity;
|
|
290
292
|
/**
|
|
291
293
|
* Register: create ERC-8004 identity + AgentAccount in one flow.
|
|
292
294
|
* If already registered, returns existing state.
|
package/dist/index.js
CHANGED
|
@@ -467,8 +467,8 @@ var MorphoClient = class {
|
|
|
467
467
|
const addrs = { ...defaultCfg.contracts, ...config.contracts };
|
|
468
468
|
this.accountFactory = new import_ethers2.Contract(addrs.accountFactory, ACCOUNT_FACTORY_ABI, this.wallet);
|
|
469
469
|
this.morphoBlue = new import_ethers2.Contract(addrs.morphoBlue, MORPHO_BLUE_ABI, this.provider);
|
|
470
|
-
this.agentReputation = new import_ethers2.Contract(addrs.agentReputation, AGENT_REPUTATION_ABI, this.
|
|
471
|
-
this.identityRegistry = new import_ethers2.Contract(addrs.identityRegistry, IDENTITY_REGISTRY_ABI, this.
|
|
470
|
+
this.agentReputation = new import_ethers2.Contract(addrs.agentReputation, AGENT_REPUTATION_ABI, this.wallet);
|
|
471
|
+
this.identityRegistry = new import_ethers2.Contract(addrs.identityRegistry, IDENTITY_REGISTRY_ABI, this.wallet);
|
|
472
472
|
}
|
|
473
473
|
// ════════════════════════════════════════════════════════
|
|
474
474
|
// Account Management
|
|
@@ -491,6 +491,25 @@ var MorphoClient = class {
|
|
|
491
491
|
getWalletAddress() {
|
|
492
492
|
return this.wallet.address;
|
|
493
493
|
}
|
|
494
|
+
/** Mint a new ERC-8004 identity and return the agentId. */
|
|
495
|
+
async _mintNewIdentity() {
|
|
496
|
+
const regTx = await this.identityRegistry.register();
|
|
497
|
+
const regReceipt = await regTx.wait();
|
|
498
|
+
let agentId = 0n;
|
|
499
|
+
for (const log of regReceipt.logs) {
|
|
500
|
+
try {
|
|
501
|
+
const parsed = this.identityRegistry.interface.parseLog({ topics: log.topics, data: log.data });
|
|
502
|
+
if (parsed?.name === "Transfer") {
|
|
503
|
+
agentId = parsed.args[2];
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
} catch {
|
|
507
|
+
continue;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
if (agentId === 0n) throw new AgetherError("Failed to parse agentId from registration", "PARSE_ERROR");
|
|
511
|
+
return agentId;
|
|
512
|
+
}
|
|
494
513
|
/**
|
|
495
514
|
* Register: create ERC-8004 identity + AgentAccount in one flow.
|
|
496
515
|
* If already registered, returns existing state.
|
|
@@ -505,26 +524,16 @@ var MorphoClient = class {
|
|
|
505
524
|
return { agentId: this.agentId, address: eoaAddr, agentAccount: acct, alreadyRegistered: true };
|
|
506
525
|
}
|
|
507
526
|
}
|
|
508
|
-
const balance = await this.identityRegistry.balanceOf(eoaAddr);
|
|
509
527
|
let agentId;
|
|
510
|
-
if (
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
for (const log of regReceipt.logs) {
|
|
517
|
-
try {
|
|
518
|
-
const parsed = this.identityRegistry.interface.parseLog({ topics: log.topics, data: log.data });
|
|
519
|
-
if (parsed?.name === "Transfer") {
|
|
520
|
-
agentId = parsed.args[2];
|
|
521
|
-
break;
|
|
522
|
-
}
|
|
523
|
-
} catch {
|
|
524
|
-
continue;
|
|
525
|
-
}
|
|
528
|
+
if (this.agentId) {
|
|
529
|
+
const balance = await this.identityRegistry.balanceOf(eoaAddr);
|
|
530
|
+
if (balance > 0n) {
|
|
531
|
+
agentId = BigInt(this.agentId);
|
|
532
|
+
} else {
|
|
533
|
+
agentId = await this._mintNewIdentity();
|
|
526
534
|
}
|
|
527
|
-
|
|
535
|
+
} else {
|
|
536
|
+
agentId = await this._mintNewIdentity();
|
|
528
537
|
}
|
|
529
538
|
this.agentId = agentId.toString();
|
|
530
539
|
const acctExists = await this.accountFactory.accountExists(agentId);
|