@agether/sdk 1.6.4 → 1.6.5
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 +29 -4
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +29 -4
- package/dist/index.mjs +29 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -227,8 +227,10 @@ var init_MorphoClient = __esm({
|
|
|
227
227
|
const defaultCfg = getDefaultConfig(chainId);
|
|
228
228
|
this.config = defaultCfg;
|
|
229
229
|
this.agentId = config.agentId;
|
|
230
|
-
this.
|
|
231
|
-
this.
|
|
230
|
+
this._rpcUrl = config.rpcUrl || defaultCfg.rpcUrl;
|
|
231
|
+
this._privateKey = config.privateKey;
|
|
232
|
+
this.provider = new import_ethers.ethers.JsonRpcProvider(this._rpcUrl);
|
|
233
|
+
this.wallet = new import_ethers.ethers.Wallet(this._privateKey, this.provider);
|
|
232
234
|
const addrs = { ...defaultCfg.contracts, ...config.contracts };
|
|
233
235
|
this.accountFactory = new import_ethers.Contract(addrs.accountFactory, ACCOUNT_FACTORY_ABI, this.wallet);
|
|
234
236
|
this.morphoBlue = new import_ethers.Contract(addrs.morphoBlue, MORPHO_BLUE_ABI, this.provider);
|
|
@@ -260,6 +262,7 @@ var init_MorphoClient = __esm({
|
|
|
260
262
|
async _mintNewIdentity() {
|
|
261
263
|
const regTx = await this.identityRegistry.register();
|
|
262
264
|
const regReceipt = await regTx.wait();
|
|
265
|
+
this._refreshSigner();
|
|
263
266
|
let agentId = 0n;
|
|
264
267
|
for (const log of regReceipt.logs) {
|
|
265
268
|
try {
|
|
@@ -306,6 +309,7 @@ var init_MorphoClient = __esm({
|
|
|
306
309
|
if (!acctExists) {
|
|
307
310
|
const tx = await this.accountFactory.createAccount(agentId);
|
|
308
311
|
const receipt = await tx.wait();
|
|
312
|
+
this._refreshSigner();
|
|
309
313
|
txHash = receipt.hash;
|
|
310
314
|
}
|
|
311
315
|
const acctAddr = await this.accountFactory.getAccount(agentId);
|
|
@@ -372,6 +376,7 @@ var init_MorphoClient = __esm({
|
|
|
372
376
|
const amount = import_ethers.ethers.parseUnits(usdcAmount, 6);
|
|
373
377
|
const tx = await usdc.transfer(acctAddr, amount);
|
|
374
378
|
const receipt = await tx.wait();
|
|
379
|
+
this._refreshSigner();
|
|
375
380
|
return { tx: receipt.hash, amount: usdcAmount, agentAccount: acctAddr };
|
|
376
381
|
}
|
|
377
382
|
// ════════════════════════════════════════════════════════
|
|
@@ -718,6 +723,7 @@ var init_MorphoClient = __esm({
|
|
|
718
723
|
const colToken = new import_ethers.Contract(colInfo.address, ERC20_ABI, this.wallet);
|
|
719
724
|
const transferTx = await colToken.transfer(acctAddr, weiAmount);
|
|
720
725
|
await transferTx.wait();
|
|
726
|
+
this._refreshSigner();
|
|
721
727
|
const targets = [colInfo.address, morphoAddr];
|
|
722
728
|
const values = [0n, 0n];
|
|
723
729
|
const datas = [
|
|
@@ -794,6 +800,7 @@ var init_MorphoClient = __esm({
|
|
|
794
800
|
const colToken = new import_ethers.Contract(colInfo.address, ERC20_ABI, this.wallet);
|
|
795
801
|
const transferTx = await colToken.transfer(acctAddr, colWei);
|
|
796
802
|
await transferTx.wait();
|
|
803
|
+
this._refreshSigner();
|
|
797
804
|
const targets = [colInfo.address, morphoAddr, morphoAddr];
|
|
798
805
|
const values = [0n, 0n, 0n];
|
|
799
806
|
const datas = [
|
|
@@ -981,6 +988,7 @@ var init_MorphoClient = __esm({
|
|
|
981
988
|
const colToken = new import_ethers.Contract(colInfo.address, ERC20_ABI, this.wallet);
|
|
982
989
|
const tx = await colToken.transfer(targetAddr, weiAmount);
|
|
983
990
|
const receipt = await tx.wait();
|
|
991
|
+
this._refreshSigner();
|
|
984
992
|
return { tx: receipt.hash, targetAccount: targetAddr, targetAgentId: target.agentId };
|
|
985
993
|
}
|
|
986
994
|
// ════════════════════════════════════════════════════════
|
|
@@ -1008,6 +1016,19 @@ var init_MorphoClient = __esm({
|
|
|
1008
1016
|
// ════════════════════════════════════════════════════════
|
|
1009
1017
|
// Internal Helpers
|
|
1010
1018
|
// ════════════════════════════════════════════════════════
|
|
1019
|
+
/**
|
|
1020
|
+
* Recreate provider + wallet so the next tx fetches a fresh nonce from chain.
|
|
1021
|
+
* Anvil (and some RPC providers) return a stale `eth_getTransactionCount`
|
|
1022
|
+
* right after a block is mined, causing "nonce too low" on the follow-up tx.
|
|
1023
|
+
*/
|
|
1024
|
+
_refreshSigner() {
|
|
1025
|
+
this.provider = new import_ethers.ethers.JsonRpcProvider(this._rpcUrl);
|
|
1026
|
+
this.wallet = new import_ethers.ethers.Wallet(this._privateKey, this.provider);
|
|
1027
|
+
const addrs = this.config.contracts;
|
|
1028
|
+
this.accountFactory = new import_ethers.Contract(addrs.accountFactory, ACCOUNT_FACTORY_ABI, this.wallet);
|
|
1029
|
+
this.agentReputation = new import_ethers.Contract(addrs.agentReputation, AGENT_REPUTATION_ABI, this.wallet);
|
|
1030
|
+
this.identityRegistry = new import_ethers.Contract(addrs.identityRegistry, IDENTITY_REGISTRY_ABI, this.wallet);
|
|
1031
|
+
}
|
|
1011
1032
|
/**
|
|
1012
1033
|
* Execute a single call via AgentAccount.execute.
|
|
1013
1034
|
*/
|
|
@@ -1022,7 +1043,9 @@ var init_MorphoClient = __esm({
|
|
|
1022
1043
|
gasLimit = 500000n;
|
|
1023
1044
|
}
|
|
1024
1045
|
const tx = await account.execute(target, value, data, { gasLimit });
|
|
1025
|
-
|
|
1046
|
+
const receipt = await tx.wait();
|
|
1047
|
+
this._refreshSigner();
|
|
1048
|
+
return receipt;
|
|
1026
1049
|
}
|
|
1027
1050
|
/**
|
|
1028
1051
|
* Execute multiple calls via AgentAccount.executeBatch.
|
|
@@ -1038,7 +1061,9 @@ var init_MorphoClient = __esm({
|
|
|
1038
1061
|
gasLimit = 800000n;
|
|
1039
1062
|
}
|
|
1040
1063
|
const tx = await account.executeBatch(targets, values, datas, { gasLimit });
|
|
1041
|
-
|
|
1064
|
+
const receipt = await tx.wait();
|
|
1065
|
+
this._refreshSigner();
|
|
1066
|
+
return receipt;
|
|
1042
1067
|
}
|
|
1043
1068
|
/** Convert MorphoMarketParams to Solidity tuple. */
|
|
1044
1069
|
_toTuple(p) {
|
package/dist/index.d.mts
CHANGED
|
@@ -276,6 +276,8 @@ declare class MorphoClient {
|
|
|
276
276
|
private provider;
|
|
277
277
|
private config;
|
|
278
278
|
private agentId;
|
|
279
|
+
private _rpcUrl;
|
|
280
|
+
private _privateKey;
|
|
279
281
|
private accountFactory;
|
|
280
282
|
private morphoBlue;
|
|
281
283
|
private agentReputation;
|
|
@@ -447,6 +449,12 @@ declare class MorphoClient {
|
|
|
447
449
|
fresh: boolean;
|
|
448
450
|
age: bigint;
|
|
449
451
|
}>;
|
|
452
|
+
/**
|
|
453
|
+
* Recreate provider + wallet so the next tx fetches a fresh nonce from chain.
|
|
454
|
+
* Anvil (and some RPC providers) return a stale `eth_getTransactionCount`
|
|
455
|
+
* right after a block is mined, causing "nonce too low" on the follow-up tx.
|
|
456
|
+
*/
|
|
457
|
+
private _refreshSigner;
|
|
450
458
|
/**
|
|
451
459
|
* Execute a single call via AgentAccount.execute.
|
|
452
460
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -276,6 +276,8 @@ declare class MorphoClient {
|
|
|
276
276
|
private provider;
|
|
277
277
|
private config;
|
|
278
278
|
private agentId;
|
|
279
|
+
private _rpcUrl;
|
|
280
|
+
private _privateKey;
|
|
279
281
|
private accountFactory;
|
|
280
282
|
private morphoBlue;
|
|
281
283
|
private agentReputation;
|
|
@@ -447,6 +449,12 @@ declare class MorphoClient {
|
|
|
447
449
|
fresh: boolean;
|
|
448
450
|
age: bigint;
|
|
449
451
|
}>;
|
|
452
|
+
/**
|
|
453
|
+
* Recreate provider + wallet so the next tx fetches a fresh nonce from chain.
|
|
454
|
+
* Anvil (and some RPC providers) return a stale `eth_getTransactionCount`
|
|
455
|
+
* right after a block is mined, causing "nonce too low" on the follow-up tx.
|
|
456
|
+
*/
|
|
457
|
+
private _refreshSigner;
|
|
450
458
|
/**
|
|
451
459
|
* Execute a single call via AgentAccount.execute.
|
|
452
460
|
*/
|
package/dist/index.js
CHANGED
|
@@ -462,8 +462,10 @@ var MorphoClient = class {
|
|
|
462
462
|
const defaultCfg = getDefaultConfig(chainId);
|
|
463
463
|
this.config = defaultCfg;
|
|
464
464
|
this.agentId = config.agentId;
|
|
465
|
-
this.
|
|
466
|
-
this.
|
|
465
|
+
this._rpcUrl = config.rpcUrl || defaultCfg.rpcUrl;
|
|
466
|
+
this._privateKey = config.privateKey;
|
|
467
|
+
this.provider = new import_ethers2.ethers.JsonRpcProvider(this._rpcUrl);
|
|
468
|
+
this.wallet = new import_ethers2.ethers.Wallet(this._privateKey, this.provider);
|
|
467
469
|
const addrs = { ...defaultCfg.contracts, ...config.contracts };
|
|
468
470
|
this.accountFactory = new import_ethers2.Contract(addrs.accountFactory, ACCOUNT_FACTORY_ABI, this.wallet);
|
|
469
471
|
this.morphoBlue = new import_ethers2.Contract(addrs.morphoBlue, MORPHO_BLUE_ABI, this.provider);
|
|
@@ -495,6 +497,7 @@ var MorphoClient = class {
|
|
|
495
497
|
async _mintNewIdentity() {
|
|
496
498
|
const regTx = await this.identityRegistry.register();
|
|
497
499
|
const regReceipt = await regTx.wait();
|
|
500
|
+
this._refreshSigner();
|
|
498
501
|
let agentId = 0n;
|
|
499
502
|
for (const log of regReceipt.logs) {
|
|
500
503
|
try {
|
|
@@ -541,6 +544,7 @@ var MorphoClient = class {
|
|
|
541
544
|
if (!acctExists) {
|
|
542
545
|
const tx = await this.accountFactory.createAccount(agentId);
|
|
543
546
|
const receipt = await tx.wait();
|
|
547
|
+
this._refreshSigner();
|
|
544
548
|
txHash = receipt.hash;
|
|
545
549
|
}
|
|
546
550
|
const acctAddr = await this.accountFactory.getAccount(agentId);
|
|
@@ -607,6 +611,7 @@ var MorphoClient = class {
|
|
|
607
611
|
const amount = import_ethers2.ethers.parseUnits(usdcAmount, 6);
|
|
608
612
|
const tx = await usdc.transfer(acctAddr, amount);
|
|
609
613
|
const receipt = await tx.wait();
|
|
614
|
+
this._refreshSigner();
|
|
610
615
|
return { tx: receipt.hash, amount: usdcAmount, agentAccount: acctAddr };
|
|
611
616
|
}
|
|
612
617
|
// ════════════════════════════════════════════════════════
|
|
@@ -953,6 +958,7 @@ var MorphoClient = class {
|
|
|
953
958
|
const colToken = new import_ethers2.Contract(colInfo.address, ERC20_ABI, this.wallet);
|
|
954
959
|
const transferTx = await colToken.transfer(acctAddr, weiAmount);
|
|
955
960
|
await transferTx.wait();
|
|
961
|
+
this._refreshSigner();
|
|
956
962
|
const targets = [colInfo.address, morphoAddr];
|
|
957
963
|
const values = [0n, 0n];
|
|
958
964
|
const datas = [
|
|
@@ -1029,6 +1035,7 @@ var MorphoClient = class {
|
|
|
1029
1035
|
const colToken = new import_ethers2.Contract(colInfo.address, ERC20_ABI, this.wallet);
|
|
1030
1036
|
const transferTx = await colToken.transfer(acctAddr, colWei);
|
|
1031
1037
|
await transferTx.wait();
|
|
1038
|
+
this._refreshSigner();
|
|
1032
1039
|
const targets = [colInfo.address, morphoAddr, morphoAddr];
|
|
1033
1040
|
const values = [0n, 0n, 0n];
|
|
1034
1041
|
const datas = [
|
|
@@ -1216,6 +1223,7 @@ var MorphoClient = class {
|
|
|
1216
1223
|
const colToken = new import_ethers2.Contract(colInfo.address, ERC20_ABI, this.wallet);
|
|
1217
1224
|
const tx = await colToken.transfer(targetAddr, weiAmount);
|
|
1218
1225
|
const receipt = await tx.wait();
|
|
1226
|
+
this._refreshSigner();
|
|
1219
1227
|
return { tx: receipt.hash, targetAccount: targetAddr, targetAgentId: target.agentId };
|
|
1220
1228
|
}
|
|
1221
1229
|
// ════════════════════════════════════════════════════════
|
|
@@ -1243,6 +1251,19 @@ var MorphoClient = class {
|
|
|
1243
1251
|
// ════════════════════════════════════════════════════════
|
|
1244
1252
|
// Internal Helpers
|
|
1245
1253
|
// ════════════════════════════════════════════════════════
|
|
1254
|
+
/**
|
|
1255
|
+
* Recreate provider + wallet so the next tx fetches a fresh nonce from chain.
|
|
1256
|
+
* Anvil (and some RPC providers) return a stale `eth_getTransactionCount`
|
|
1257
|
+
* right after a block is mined, causing "nonce too low" on the follow-up tx.
|
|
1258
|
+
*/
|
|
1259
|
+
_refreshSigner() {
|
|
1260
|
+
this.provider = new import_ethers2.ethers.JsonRpcProvider(this._rpcUrl);
|
|
1261
|
+
this.wallet = new import_ethers2.ethers.Wallet(this._privateKey, this.provider);
|
|
1262
|
+
const addrs = this.config.contracts;
|
|
1263
|
+
this.accountFactory = new import_ethers2.Contract(addrs.accountFactory, ACCOUNT_FACTORY_ABI, this.wallet);
|
|
1264
|
+
this.agentReputation = new import_ethers2.Contract(addrs.agentReputation, AGENT_REPUTATION_ABI, this.wallet);
|
|
1265
|
+
this.identityRegistry = new import_ethers2.Contract(addrs.identityRegistry, IDENTITY_REGISTRY_ABI, this.wallet);
|
|
1266
|
+
}
|
|
1246
1267
|
/**
|
|
1247
1268
|
* Execute a single call via AgentAccount.execute.
|
|
1248
1269
|
*/
|
|
@@ -1257,7 +1278,9 @@ var MorphoClient = class {
|
|
|
1257
1278
|
gasLimit = 500000n;
|
|
1258
1279
|
}
|
|
1259
1280
|
const tx = await account.execute(target, value, data, { gasLimit });
|
|
1260
|
-
|
|
1281
|
+
const receipt = await tx.wait();
|
|
1282
|
+
this._refreshSigner();
|
|
1283
|
+
return receipt;
|
|
1261
1284
|
}
|
|
1262
1285
|
/**
|
|
1263
1286
|
* Execute multiple calls via AgentAccount.executeBatch.
|
|
@@ -1273,7 +1296,9 @@ var MorphoClient = class {
|
|
|
1273
1296
|
gasLimit = 800000n;
|
|
1274
1297
|
}
|
|
1275
1298
|
const tx = await account.executeBatch(targets, values, datas, { gasLimit });
|
|
1276
|
-
|
|
1299
|
+
const receipt = await tx.wait();
|
|
1300
|
+
this._refreshSigner();
|
|
1301
|
+
return receipt;
|
|
1277
1302
|
}
|
|
1278
1303
|
/** Convert MorphoMarketParams to Solidity tuple. */
|
|
1279
1304
|
_toTuple(p) {
|
package/dist/index.mjs
CHANGED
|
@@ -398,8 +398,10 @@ var MorphoClient = class {
|
|
|
398
398
|
const defaultCfg = getDefaultConfig(chainId);
|
|
399
399
|
this.config = defaultCfg;
|
|
400
400
|
this.agentId = config.agentId;
|
|
401
|
-
this.
|
|
402
|
-
this.
|
|
401
|
+
this._rpcUrl = config.rpcUrl || defaultCfg.rpcUrl;
|
|
402
|
+
this._privateKey = config.privateKey;
|
|
403
|
+
this.provider = new ethers2.JsonRpcProvider(this._rpcUrl);
|
|
404
|
+
this.wallet = new ethers2.Wallet(this._privateKey, this.provider);
|
|
403
405
|
const addrs = { ...defaultCfg.contracts, ...config.contracts };
|
|
404
406
|
this.accountFactory = new Contract2(addrs.accountFactory, ACCOUNT_FACTORY_ABI, this.wallet);
|
|
405
407
|
this.morphoBlue = new Contract2(addrs.morphoBlue, MORPHO_BLUE_ABI, this.provider);
|
|
@@ -431,6 +433,7 @@ var MorphoClient = class {
|
|
|
431
433
|
async _mintNewIdentity() {
|
|
432
434
|
const regTx = await this.identityRegistry.register();
|
|
433
435
|
const regReceipt = await regTx.wait();
|
|
436
|
+
this._refreshSigner();
|
|
434
437
|
let agentId = 0n;
|
|
435
438
|
for (const log of regReceipt.logs) {
|
|
436
439
|
try {
|
|
@@ -477,6 +480,7 @@ var MorphoClient = class {
|
|
|
477
480
|
if (!acctExists) {
|
|
478
481
|
const tx = await this.accountFactory.createAccount(agentId);
|
|
479
482
|
const receipt = await tx.wait();
|
|
483
|
+
this._refreshSigner();
|
|
480
484
|
txHash = receipt.hash;
|
|
481
485
|
}
|
|
482
486
|
const acctAddr = await this.accountFactory.getAccount(agentId);
|
|
@@ -543,6 +547,7 @@ var MorphoClient = class {
|
|
|
543
547
|
const amount = ethers2.parseUnits(usdcAmount, 6);
|
|
544
548
|
const tx = await usdc.transfer(acctAddr, amount);
|
|
545
549
|
const receipt = await tx.wait();
|
|
550
|
+
this._refreshSigner();
|
|
546
551
|
return { tx: receipt.hash, amount: usdcAmount, agentAccount: acctAddr };
|
|
547
552
|
}
|
|
548
553
|
// ════════════════════════════════════════════════════════
|
|
@@ -889,6 +894,7 @@ var MorphoClient = class {
|
|
|
889
894
|
const colToken = new Contract2(colInfo.address, ERC20_ABI, this.wallet);
|
|
890
895
|
const transferTx = await colToken.transfer(acctAddr, weiAmount);
|
|
891
896
|
await transferTx.wait();
|
|
897
|
+
this._refreshSigner();
|
|
892
898
|
const targets = [colInfo.address, morphoAddr];
|
|
893
899
|
const values = [0n, 0n];
|
|
894
900
|
const datas = [
|
|
@@ -965,6 +971,7 @@ var MorphoClient = class {
|
|
|
965
971
|
const colToken = new Contract2(colInfo.address, ERC20_ABI, this.wallet);
|
|
966
972
|
const transferTx = await colToken.transfer(acctAddr, colWei);
|
|
967
973
|
await transferTx.wait();
|
|
974
|
+
this._refreshSigner();
|
|
968
975
|
const targets = [colInfo.address, morphoAddr, morphoAddr];
|
|
969
976
|
const values = [0n, 0n, 0n];
|
|
970
977
|
const datas = [
|
|
@@ -1152,6 +1159,7 @@ var MorphoClient = class {
|
|
|
1152
1159
|
const colToken = new Contract2(colInfo.address, ERC20_ABI, this.wallet);
|
|
1153
1160
|
const tx = await colToken.transfer(targetAddr, weiAmount);
|
|
1154
1161
|
const receipt = await tx.wait();
|
|
1162
|
+
this._refreshSigner();
|
|
1155
1163
|
return { tx: receipt.hash, targetAccount: targetAddr, targetAgentId: target.agentId };
|
|
1156
1164
|
}
|
|
1157
1165
|
// ════════════════════════════════════════════════════════
|
|
@@ -1179,6 +1187,19 @@ var MorphoClient = class {
|
|
|
1179
1187
|
// ════════════════════════════════════════════════════════
|
|
1180
1188
|
// Internal Helpers
|
|
1181
1189
|
// ════════════════════════════════════════════════════════
|
|
1190
|
+
/**
|
|
1191
|
+
* Recreate provider + wallet so the next tx fetches a fresh nonce from chain.
|
|
1192
|
+
* Anvil (and some RPC providers) return a stale `eth_getTransactionCount`
|
|
1193
|
+
* right after a block is mined, causing "nonce too low" on the follow-up tx.
|
|
1194
|
+
*/
|
|
1195
|
+
_refreshSigner() {
|
|
1196
|
+
this.provider = new ethers2.JsonRpcProvider(this._rpcUrl);
|
|
1197
|
+
this.wallet = new ethers2.Wallet(this._privateKey, this.provider);
|
|
1198
|
+
const addrs = this.config.contracts;
|
|
1199
|
+
this.accountFactory = new Contract2(addrs.accountFactory, ACCOUNT_FACTORY_ABI, this.wallet);
|
|
1200
|
+
this.agentReputation = new Contract2(addrs.agentReputation, AGENT_REPUTATION_ABI, this.wallet);
|
|
1201
|
+
this.identityRegistry = new Contract2(addrs.identityRegistry, IDENTITY_REGISTRY_ABI, this.wallet);
|
|
1202
|
+
}
|
|
1182
1203
|
/**
|
|
1183
1204
|
* Execute a single call via AgentAccount.execute.
|
|
1184
1205
|
*/
|
|
@@ -1193,7 +1214,9 @@ var MorphoClient = class {
|
|
|
1193
1214
|
gasLimit = 500000n;
|
|
1194
1215
|
}
|
|
1195
1216
|
const tx = await account.execute(target, value, data, { gasLimit });
|
|
1196
|
-
|
|
1217
|
+
const receipt = await tx.wait();
|
|
1218
|
+
this._refreshSigner();
|
|
1219
|
+
return receipt;
|
|
1197
1220
|
}
|
|
1198
1221
|
/**
|
|
1199
1222
|
* Execute multiple calls via AgentAccount.executeBatch.
|
|
@@ -1209,7 +1232,9 @@ var MorphoClient = class {
|
|
|
1209
1232
|
gasLimit = 800000n;
|
|
1210
1233
|
}
|
|
1211
1234
|
const tx = await account.executeBatch(targets, values, datas, { gasLimit });
|
|
1212
|
-
|
|
1235
|
+
const receipt = await tx.wait();
|
|
1236
|
+
this._refreshSigner();
|
|
1237
|
+
return receipt;
|
|
1213
1238
|
}
|
|
1214
1239
|
/** Convert MorphoMarketParams to Solidity tuple. */
|
|
1215
1240
|
_toTuple(p) {
|