@agether/sdk 1.10.0 → 1.10.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 +24 -7
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +24 -7
- package/dist/index.mjs +24 -7
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -273,16 +273,29 @@ var init_MorphoClient = __esm({
|
|
|
273
273
|
// ════════════════════════════════════════════════════════
|
|
274
274
|
// Account Management
|
|
275
275
|
// ════════════════════════════════════════════════════════
|
|
276
|
-
/** Resolve the AgentAccount address (cached). */
|
|
276
|
+
/** Resolve the AgentAccount address (cached, with retry for flaky RPCs). */
|
|
277
277
|
async getAccountAddress() {
|
|
278
278
|
if (this._accountAddress) return this._accountAddress;
|
|
279
279
|
if (!this.agentId) throw new AgetherError("agentId not set", "NO_AGENT_ID");
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
|
|
280
|
+
const MAX_RETRIES = 3;
|
|
281
|
+
let lastErr;
|
|
282
|
+
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
|
|
283
|
+
try {
|
|
284
|
+
const addr = await this.accountFactory.getAccount(BigInt(this.agentId));
|
|
285
|
+
if (addr === import_ethers.ethers.ZeroAddress) {
|
|
286
|
+
throw new AgetherError("No AgentAccount found. Call register() first.", "NO_ACCOUNT");
|
|
287
|
+
}
|
|
288
|
+
this._accountAddress = addr;
|
|
289
|
+
return addr;
|
|
290
|
+
} catch (err) {
|
|
291
|
+
if (err instanceof AgetherError) throw err;
|
|
292
|
+
lastErr = err;
|
|
293
|
+
if (attempt < MAX_RETRIES) {
|
|
294
|
+
await new Promise((r) => setTimeout(r, 500 * attempt));
|
|
295
|
+
}
|
|
296
|
+
}
|
|
283
297
|
}
|
|
284
|
-
|
|
285
|
-
return addr;
|
|
298
|
+
throw lastErr;
|
|
286
299
|
}
|
|
287
300
|
getAgentId() {
|
|
288
301
|
if (!this.agentId) throw new AgetherError("agentId not set", "NO_AGENT_ID");
|
|
@@ -428,7 +441,11 @@ var init_MorphoClient = __esm({
|
|
|
428
441
|
usdc: import_ethers.ethers.formatUnits(acctUsdc, 6),
|
|
429
442
|
collateral: acctCollateral
|
|
430
443
|
};
|
|
431
|
-
} catch {
|
|
444
|
+
} catch (err) {
|
|
445
|
+
if (err instanceof AgetherError && err.code === "NO_ACCOUNT") {
|
|
446
|
+
} else {
|
|
447
|
+
console.warn("[agether] getBalances: failed to fetch AgentAccount data:", err.message ?? err);
|
|
448
|
+
}
|
|
432
449
|
}
|
|
433
450
|
return result;
|
|
434
451
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -346,7 +346,7 @@ declare class MorphoClient {
|
|
|
346
346
|
* execute/executeBatch without prior code approval.
|
|
347
347
|
*/
|
|
348
348
|
isKyaRequired(): Promise<boolean>;
|
|
349
|
-
/** Resolve the AgentAccount address (cached). */
|
|
349
|
+
/** Resolve the AgentAccount address (cached, with retry for flaky RPCs). */
|
|
350
350
|
getAccountAddress(): Promise<string>;
|
|
351
351
|
getAgentId(): string;
|
|
352
352
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -346,7 +346,7 @@ declare class MorphoClient {
|
|
|
346
346
|
* execute/executeBatch without prior code approval.
|
|
347
347
|
*/
|
|
348
348
|
isKyaRequired(): Promise<boolean>;
|
|
349
|
-
/** Resolve the AgentAccount address (cached). */
|
|
349
|
+
/** Resolve the AgentAccount address (cached, with retry for flaky RPCs). */
|
|
350
350
|
getAccountAddress(): Promise<string>;
|
|
351
351
|
getAgentId(): string;
|
|
352
352
|
/**
|
package/dist/index.js
CHANGED
|
@@ -508,16 +508,29 @@ var MorphoClient = class {
|
|
|
508
508
|
// ════════════════════════════════════════════════════════
|
|
509
509
|
// Account Management
|
|
510
510
|
// ════════════════════════════════════════════════════════
|
|
511
|
-
/** Resolve the AgentAccount address (cached). */
|
|
511
|
+
/** Resolve the AgentAccount address (cached, with retry for flaky RPCs). */
|
|
512
512
|
async getAccountAddress() {
|
|
513
513
|
if (this._accountAddress) return this._accountAddress;
|
|
514
514
|
if (!this.agentId) throw new AgetherError("agentId not set", "NO_AGENT_ID");
|
|
515
|
-
const
|
|
516
|
-
|
|
517
|
-
|
|
515
|
+
const MAX_RETRIES = 3;
|
|
516
|
+
let lastErr;
|
|
517
|
+
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
|
|
518
|
+
try {
|
|
519
|
+
const addr = await this.accountFactory.getAccount(BigInt(this.agentId));
|
|
520
|
+
if (addr === import_ethers2.ethers.ZeroAddress) {
|
|
521
|
+
throw new AgetherError("No AgentAccount found. Call register() first.", "NO_ACCOUNT");
|
|
522
|
+
}
|
|
523
|
+
this._accountAddress = addr;
|
|
524
|
+
return addr;
|
|
525
|
+
} catch (err) {
|
|
526
|
+
if (err instanceof AgetherError) throw err;
|
|
527
|
+
lastErr = err;
|
|
528
|
+
if (attempt < MAX_RETRIES) {
|
|
529
|
+
await new Promise((r) => setTimeout(r, 500 * attempt));
|
|
530
|
+
}
|
|
531
|
+
}
|
|
518
532
|
}
|
|
519
|
-
|
|
520
|
-
return addr;
|
|
533
|
+
throw lastErr;
|
|
521
534
|
}
|
|
522
535
|
getAgentId() {
|
|
523
536
|
if (!this.agentId) throw new AgetherError("agentId not set", "NO_AGENT_ID");
|
|
@@ -663,7 +676,11 @@ var MorphoClient = class {
|
|
|
663
676
|
usdc: import_ethers2.ethers.formatUnits(acctUsdc, 6),
|
|
664
677
|
collateral: acctCollateral
|
|
665
678
|
};
|
|
666
|
-
} catch {
|
|
679
|
+
} catch (err) {
|
|
680
|
+
if (err instanceof AgetherError && err.code === "NO_ACCOUNT") {
|
|
681
|
+
} else {
|
|
682
|
+
console.warn("[agether] getBalances: failed to fetch AgentAccount data:", err.message ?? err);
|
|
683
|
+
}
|
|
667
684
|
}
|
|
668
685
|
return result;
|
|
669
686
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -444,16 +444,29 @@ var MorphoClient = class {
|
|
|
444
444
|
// ════════════════════════════════════════════════════════
|
|
445
445
|
// Account Management
|
|
446
446
|
// ════════════════════════════════════════════════════════
|
|
447
|
-
/** Resolve the AgentAccount address (cached). */
|
|
447
|
+
/** Resolve the AgentAccount address (cached, with retry for flaky RPCs). */
|
|
448
448
|
async getAccountAddress() {
|
|
449
449
|
if (this._accountAddress) return this._accountAddress;
|
|
450
450
|
if (!this.agentId) throw new AgetherError("agentId not set", "NO_AGENT_ID");
|
|
451
|
-
const
|
|
452
|
-
|
|
453
|
-
|
|
451
|
+
const MAX_RETRIES = 3;
|
|
452
|
+
let lastErr;
|
|
453
|
+
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
|
|
454
|
+
try {
|
|
455
|
+
const addr = await this.accountFactory.getAccount(BigInt(this.agentId));
|
|
456
|
+
if (addr === ethers2.ZeroAddress) {
|
|
457
|
+
throw new AgetherError("No AgentAccount found. Call register() first.", "NO_ACCOUNT");
|
|
458
|
+
}
|
|
459
|
+
this._accountAddress = addr;
|
|
460
|
+
return addr;
|
|
461
|
+
} catch (err) {
|
|
462
|
+
if (err instanceof AgetherError) throw err;
|
|
463
|
+
lastErr = err;
|
|
464
|
+
if (attempt < MAX_RETRIES) {
|
|
465
|
+
await new Promise((r) => setTimeout(r, 500 * attempt));
|
|
466
|
+
}
|
|
467
|
+
}
|
|
454
468
|
}
|
|
455
|
-
|
|
456
|
-
return addr;
|
|
469
|
+
throw lastErr;
|
|
457
470
|
}
|
|
458
471
|
getAgentId() {
|
|
459
472
|
if (!this.agentId) throw new AgetherError("agentId not set", "NO_AGENT_ID");
|
|
@@ -599,7 +612,11 @@ var MorphoClient = class {
|
|
|
599
612
|
usdc: ethers2.formatUnits(acctUsdc, 6),
|
|
600
613
|
collateral: acctCollateral
|
|
601
614
|
};
|
|
602
|
-
} catch {
|
|
615
|
+
} catch (err) {
|
|
616
|
+
if (err instanceof AgetherError && err.code === "NO_ACCOUNT") {
|
|
617
|
+
} else {
|
|
618
|
+
console.warn("[agether] getBalances: failed to fetch AgentAccount data:", err.message ?? err);
|
|
619
|
+
}
|
|
603
620
|
}
|
|
604
621
|
return result;
|
|
605
622
|
}
|