@agether/sdk 1.10.2 → 1.11.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 +57 -22
- package/dist/index.d.mts +13 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +57 -20
- package/dist/index.mjs +56 -20
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -47,7 +47,7 @@ var init_types = __esm({
|
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
// src/utils/abis.ts
|
|
50
|
-
var IDENTITY_REGISTRY_ABI, ACCOUNT_FACTORY_ABI, AGENT_ACCOUNT_ABI, AGENT_REPUTATION_ABI, MORPHO_BLUE_ABI, ERC20_ABI;
|
|
50
|
+
var IDENTITY_REGISTRY_ABI, ACCOUNT_FACTORY_ABI, AGENT_ACCOUNT_ABI, AGENT_REPUTATION_ABI, MORPHO_BLUE_ABI, ERC20_ABI, KYA_HOOK_ABI;
|
|
51
51
|
var init_abis = __esm({
|
|
52
52
|
"src/utils/abis.ts"() {
|
|
53
53
|
"use strict";
|
|
@@ -66,24 +66,30 @@ var init_abis = __esm({
|
|
|
66
66
|
"function totalAccounts() view returns (uint256)",
|
|
67
67
|
"function getAgentId(address account) view returns (uint256)",
|
|
68
68
|
"function createAccount(uint256 agentId) returns (address account)",
|
|
69
|
-
"function
|
|
70
|
-
"function
|
|
71
|
-
"event AccountCreated(uint256 indexed agentId, address indexed account, address indexed owner)"
|
|
72
|
-
"event ValidationRegistryUpdated(address indexed oldRegistry, address indexed newRegistry)"
|
|
69
|
+
"function protocolHook() view returns (address)",
|
|
70
|
+
"function identityRegistry() view returns (address)",
|
|
71
|
+
"event AccountCreated(uint256 indexed agentId, address indexed account, address indexed owner)"
|
|
73
72
|
];
|
|
74
73
|
AGENT_ACCOUNT_ABI = [
|
|
75
74
|
"function agentId() view returns (uint256)",
|
|
76
75
|
"function owner() view returns (address)",
|
|
77
76
|
"function factory() view returns (address)",
|
|
78
|
-
"function validationRegistry() view returns (address)",
|
|
79
77
|
"function identityRegistry() view returns (address)",
|
|
80
78
|
"function balanceOf(address token) view returns (uint256)",
|
|
81
79
|
"function ethBalance() view returns (uint256)",
|
|
82
|
-
|
|
83
|
-
"function
|
|
80
|
+
// ERC-7579 execution
|
|
81
|
+
"function execute(bytes32 mode, bytes executionCalldata) payable",
|
|
82
|
+
"function executeFromExecutor(bytes32 mode, bytes executionCalldata) payable returns (bytes[])",
|
|
83
|
+
// ERC-7579 module management
|
|
84
|
+
"function installModule(uint256 moduleTypeId, address module, bytes initData) payable",
|
|
85
|
+
"function uninstallModule(uint256 moduleTypeId, address module, bytes deInitData) payable",
|
|
86
|
+
"function isModuleInstalled(uint256 moduleTypeId, address module, bytes additionalContext) view returns (bool)",
|
|
87
|
+
"function hook() view returns (address)",
|
|
88
|
+
// Funding (direct, no execution needed)
|
|
84
89
|
"function fund(address token, uint256 amount)",
|
|
85
90
|
"function withdraw(address token, uint256 amount, address to)",
|
|
86
91
|
"function withdrawETH(uint256 amount, address to)",
|
|
92
|
+
// EIP-1271
|
|
87
93
|
"function isValidSignature(bytes32 hash, bytes signature) view returns (bytes4)"
|
|
88
94
|
];
|
|
89
95
|
AGENT_REPUTATION_ABI = [
|
|
@@ -124,6 +130,10 @@ var init_abis = __esm({
|
|
|
124
130
|
"function symbol() view returns (string)",
|
|
125
131
|
"function name() view returns (string)"
|
|
126
132
|
];
|
|
133
|
+
KYA_HOOK_ABI = [
|
|
134
|
+
"function validationRegistry() view returns (address)",
|
|
135
|
+
"function setValidationRegistry(address newRegistry)"
|
|
136
|
+
];
|
|
127
137
|
}
|
|
128
138
|
});
|
|
129
139
|
|
|
@@ -146,14 +156,16 @@ var init_config = __esm({
|
|
|
146
156
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
147
157
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
148
158
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
159
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
149
160
|
usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
150
161
|
identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
151
162
|
morphoBlue: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb"
|
|
152
163
|
},
|
|
153
164
|
[8453 /* Base */]: {
|
|
154
|
-
accountFactory: "
|
|
155
|
-
validationRegistry: "
|
|
156
|
-
agentReputation: "
|
|
165
|
+
accountFactory: "0x89a8758E60A56EcB47247D92E05447eFd450d6Bf",
|
|
166
|
+
validationRegistry: "0x6f76cF69B71Dc5F9A414BCEe4583b12738E47985",
|
|
167
|
+
agentReputation: "0xe88f3419a2dbac70e3aF6E487b0C63e8301C6A87",
|
|
168
|
+
kyaHook: "0x28e50Aa9eD517E369b2806928709B44062aD9821",
|
|
157
169
|
usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
158
170
|
identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
159
171
|
morphoBlue: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb"
|
|
@@ -162,6 +174,7 @@ var init_config = __esm({
|
|
|
162
174
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
163
175
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
164
176
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
177
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
165
178
|
usdc: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
166
179
|
identityRegistry: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
|
|
167
180
|
morphoBlue: "0x0000000000000000000000000000000000000000"
|
|
@@ -170,6 +183,7 @@ var init_config = __esm({
|
|
|
170
183
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
171
184
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
172
185
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
186
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
173
187
|
usdc: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
|
|
174
188
|
identityRegistry: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
|
|
175
189
|
morphoBlue: "0x0000000000000000000000000000000000000000"
|
|
@@ -178,6 +192,7 @@ var init_config = __esm({
|
|
|
178
192
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
179
193
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
180
194
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
195
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
181
196
|
usdc: "0x56d4d6aEe0278c5Df2FA23Ecb32eC146C9446FDf",
|
|
182
197
|
identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
183
198
|
morphoBlue: "0x0000000000000000000000000000000000000000"
|
|
@@ -205,7 +220,7 @@ var MorphoClient_exports = {};
|
|
|
205
220
|
__export(MorphoClient_exports, {
|
|
206
221
|
MorphoClient: () => MorphoClient
|
|
207
222
|
});
|
|
208
|
-
var import_ethers, import_axios, BASE_COLLATERALS, MORPHO_API_URL, morphoIface, erc20Iface, MorphoClient;
|
|
223
|
+
var import_ethers, import_axios, BASE_COLLATERALS, MORPHO_API_URL, MODE_SINGLE, MODE_BATCH, morphoIface, erc20Iface, MorphoClient;
|
|
209
224
|
var init_MorphoClient = __esm({
|
|
210
225
|
"src/clients/MorphoClient.ts"() {
|
|
211
226
|
"use strict";
|
|
@@ -220,6 +235,8 @@ var init_MorphoClient = __esm({
|
|
|
220
235
|
cbETH: { address: "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22", symbol: "cbETH", decimals: 18 }
|
|
221
236
|
};
|
|
222
237
|
MORPHO_API_URL = "https://api.morpho.org/graphql";
|
|
238
|
+
MODE_SINGLE = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
239
|
+
MODE_BATCH = "0x0100000000000000000000000000000000000000000000000000000000000000";
|
|
223
240
|
morphoIface = new import_ethers.ethers.Interface(MORPHO_BLUE_ABI);
|
|
224
241
|
erc20Iface = new import_ethers.ethers.Interface(ERC20_ABI);
|
|
225
242
|
MorphoClient = class {
|
|
@@ -263,12 +280,21 @@ var init_MorphoClient = __esm({
|
|
|
263
280
|
// ════════════════════════════════════════════════════════
|
|
264
281
|
/**
|
|
265
282
|
* Check whether the KYA (Know Your Agent) code verification gate is active.
|
|
266
|
-
*
|
|
267
|
-
*
|
|
283
|
+
* Reads the account's installed hook and checks if it has a non-zero
|
|
284
|
+
* validationRegistry — when set, the hook enforces KYA code approval.
|
|
268
285
|
*/
|
|
269
286
|
async isKyaRequired() {
|
|
270
|
-
|
|
271
|
-
|
|
287
|
+
try {
|
|
288
|
+
const acctAddr = await this.getAccountAddress();
|
|
289
|
+
const account = new import_ethers.Contract(acctAddr, AGENT_ACCOUNT_ABI, this.provider);
|
|
290
|
+
const hookAddr = await account.hook();
|
|
291
|
+
if (hookAddr === import_ethers.ethers.ZeroAddress) return false;
|
|
292
|
+
const hook = new import_ethers.Contract(hookAddr, KYA_HOOK_ABI, this.provider);
|
|
293
|
+
const registryAddr = await hook.validationRegistry();
|
|
294
|
+
return registryAddr !== import_ethers.ethers.ZeroAddress;
|
|
295
|
+
} catch {
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
272
298
|
}
|
|
273
299
|
// ════════════════════════════════════════════════════════
|
|
274
300
|
// Account Management
|
|
@@ -1140,39 +1166,48 @@ var init_MorphoClient = __esm({
|
|
|
1140
1166
|
}
|
|
1141
1167
|
}
|
|
1142
1168
|
/**
|
|
1143
|
-
* Execute a single call via AgentAccount.execute.
|
|
1169
|
+
* Execute a single call via AgentAccount.execute (ERC-7579 single mode).
|
|
1144
1170
|
*/
|
|
1145
1171
|
async exec(target, data, value = 0n) {
|
|
1146
1172
|
const acctAddr = await this.getAccountAddress();
|
|
1147
1173
|
const account = new import_ethers.Contract(acctAddr, AGENT_ACCOUNT_ABI, this._signer);
|
|
1174
|
+
const executionCalldata = import_ethers.ethers.AbiCoder.defaultAbiCoder().encode(
|
|
1175
|
+
["address", "uint256", "bytes"],
|
|
1176
|
+
[target, value, data]
|
|
1177
|
+
);
|
|
1148
1178
|
let gasLimit;
|
|
1149
1179
|
try {
|
|
1150
|
-
const estimate = await account.execute.estimateGas(
|
|
1180
|
+
const estimate = await account.execute.estimateGas(MODE_SINGLE, executionCalldata);
|
|
1151
1181
|
gasLimit = estimate * 130n / 100n;
|
|
1152
1182
|
} catch (e) {
|
|
1153
1183
|
console.warn("[agether] exec gas estimation failed, using default 500k:", e instanceof Error ? e.message : e);
|
|
1154
1184
|
gasLimit = 500000n;
|
|
1155
1185
|
}
|
|
1156
|
-
const tx = await account.execute(
|
|
1186
|
+
const tx = await account.execute(MODE_SINGLE, executionCalldata, { gasLimit });
|
|
1157
1187
|
const receipt = await tx.wait();
|
|
1158
1188
|
this._refreshSigner();
|
|
1159
1189
|
return receipt;
|
|
1160
1190
|
}
|
|
1161
1191
|
/**
|
|
1162
|
-
* Execute multiple calls via AgentAccount.
|
|
1192
|
+
* Execute multiple calls via AgentAccount.execute (ERC-7579 batch mode).
|
|
1163
1193
|
*/
|
|
1164
1194
|
async batch(targets, values, datas) {
|
|
1165
1195
|
const acctAddr = await this.getAccountAddress();
|
|
1166
1196
|
const account = new import_ethers.Contract(acctAddr, AGENT_ACCOUNT_ABI, this._signer);
|
|
1197
|
+
const executions = targets.map((t, i) => [t, values[i], datas[i]]);
|
|
1198
|
+
const executionCalldata = import_ethers.ethers.AbiCoder.defaultAbiCoder().encode(
|
|
1199
|
+
["(address,uint256,bytes)[]"],
|
|
1200
|
+
[executions]
|
|
1201
|
+
);
|
|
1167
1202
|
let gasLimit;
|
|
1168
1203
|
try {
|
|
1169
|
-
const estimate = await account.
|
|
1204
|
+
const estimate = await account.execute.estimateGas(MODE_BATCH, executionCalldata);
|
|
1170
1205
|
gasLimit = estimate * 130n / 100n;
|
|
1171
1206
|
} catch (e) {
|
|
1172
1207
|
console.warn("[agether] batch gas estimation failed, using default 800k:", e instanceof Error ? e.message : e);
|
|
1173
1208
|
gasLimit = 800000n;
|
|
1174
1209
|
}
|
|
1175
|
-
const tx = await account.
|
|
1210
|
+
const tx = await account.execute(MODE_BATCH, executionCalldata, { gasLimit });
|
|
1176
1211
|
const receipt = await tx.wait();
|
|
1177
1212
|
this._refreshSigner();
|
|
1178
1213
|
return receipt;
|
package/dist/index.d.mts
CHANGED
|
@@ -103,6 +103,7 @@ interface ContractAddresses {
|
|
|
103
103
|
accountFactory: string;
|
|
104
104
|
validationRegistry: string;
|
|
105
105
|
agentReputation: string;
|
|
106
|
+
kyaHook: string;
|
|
106
107
|
usdc: string;
|
|
107
108
|
identityRegistry: string;
|
|
108
109
|
morphoBlue: string;
|
|
@@ -176,10 +177,14 @@ declare class AgetherClient {
|
|
|
176
177
|
}
|
|
177
178
|
|
|
178
179
|
/**
|
|
179
|
-
* MorphoClient — Direct Morpho Blue lending via AgentAccount
|
|
180
|
+
* MorphoClient — Direct Morpho Blue lending via AgentAccount (ERC-7579)
|
|
180
181
|
*
|
|
181
182
|
* Architecture (no intermediary contract):
|
|
182
|
-
* EOA → AgentAccount.
|
|
183
|
+
* EOA → AgentAccount.execute(MODE_BATCH, ...) → Morpho Blue (direct)
|
|
184
|
+
*
|
|
185
|
+
* ERC-7579 execution modes:
|
|
186
|
+
* - Single: execute(MODE_SINGLE, abi.encode(target, value, callData))
|
|
187
|
+
* - Batch: execute(MODE_BATCH, abi.encode(Execution[]))
|
|
183
188
|
*
|
|
184
189
|
* Batched operations:
|
|
185
190
|
* - depositAndBorrow: [ERC20.approve, Morpho.supplyCollateral, Morpho.borrow]
|
|
@@ -342,8 +347,8 @@ declare class MorphoClient {
|
|
|
342
347
|
constructor(config: MorphoClientConfig);
|
|
343
348
|
/**
|
|
344
349
|
* Check whether the KYA (Know Your Agent) code verification gate is active.
|
|
345
|
-
*
|
|
346
|
-
*
|
|
350
|
+
* Reads the account's installed hook and checks if it has a non-zero
|
|
351
|
+
* validationRegistry — when set, the hook enforces KYA code approval.
|
|
347
352
|
*/
|
|
348
353
|
isKyaRequired(): Promise<boolean>;
|
|
349
354
|
/** Resolve the AgentAccount address (cached, with retry for flaky RPCs). */
|
|
@@ -535,11 +540,11 @@ declare class MorphoClient {
|
|
|
535
540
|
*/
|
|
536
541
|
private _refreshSigner;
|
|
537
542
|
/**
|
|
538
|
-
* Execute a single call via AgentAccount.execute.
|
|
543
|
+
* Execute a single call via AgentAccount.execute (ERC-7579 single mode).
|
|
539
544
|
*/
|
|
540
545
|
private exec;
|
|
541
546
|
/**
|
|
542
|
-
* Execute multiple calls via AgentAccount.
|
|
547
|
+
* Execute multiple calls via AgentAccount.execute (ERC-7579 batch mode).
|
|
543
548
|
*/
|
|
544
549
|
private batch;
|
|
545
550
|
/** Convert MorphoMarketParams to Solidity tuple. */
|
|
@@ -1040,6 +1045,7 @@ declare const AGENT_REPUTATION_ABI: string[];
|
|
|
1040
1045
|
declare const VALIDATION_REGISTRY_ABI: string[];
|
|
1041
1046
|
declare const MORPHO_BLUE_ABI: string[];
|
|
1042
1047
|
declare const ERC20_ABI: string[];
|
|
1048
|
+
declare const KYA_HOOK_ABI: string[];
|
|
1043
1049
|
|
|
1044
1050
|
/**
|
|
1045
1051
|
* Network configurations
|
|
@@ -1063,4 +1069,4 @@ declare function getDefaultConfig(chainId: ChainId): AgetherConfig;
|
|
|
1063
1069
|
*/
|
|
1064
1070
|
declare function createConfig(chainId: ChainId, options?: Partial<AgetherConfig>): AgetherConfig;
|
|
1065
1071
|
|
|
1066
|
-
export { ACCOUNT_FACTORY_ABI, AGENT_ACCOUNT_ABI, AGENT_REPUTATION_ABI, AgentIdentityClient, type AgentIdentityClientOptions, AgentNotApprovedError, AgetherClient, type AgetherClientOptions, type AgetherConfig, AgetherError, type AgetherSigner, type AgetherViemWallet, type BalancesResult, type BorrowResult, ChainId, type ContractAddresses, type DepositAndBorrowResult, type DepositResult, ERC20_ABI, type FundResult, IDENTITY_REGISTRY_ABI, InsufficientBalanceError, MORPHO_BLUE_ABI, MorphoClient, type MorphoClientConfig, type MorphoMarketInfo, type MorphoMarketParams, type MorphoPosition, type PaymentRequirements, type PositionResult, type RegisterResult, type RepayResult, type ScoreAttestation, type ScoreResult, ScoringClient, type ScoringClientConfig, ScoringRejectedError, type SpendingTracker, type StatusResult, type TransactionResult, VALIDATION_REGISTRY_ABI, type WithdrawResult, X402Client, type X402Config, type X402PaymentRequest, type X402PaymentResult, type X402Response, bpsToRate, createConfig, formatAPR, formatAddress, formatHealthFactor, formatPercent, formatTimestamp, formatUSD, formatUnits, getDefaultConfig, parseUnits, rateToBps };
|
|
1072
|
+
export { ACCOUNT_FACTORY_ABI, AGENT_ACCOUNT_ABI, AGENT_REPUTATION_ABI, AgentIdentityClient, type AgentIdentityClientOptions, AgentNotApprovedError, AgetherClient, type AgetherClientOptions, type AgetherConfig, AgetherError, type AgetherSigner, type AgetherViemWallet, type BalancesResult, type BorrowResult, ChainId, type ContractAddresses, type DepositAndBorrowResult, type DepositResult, ERC20_ABI, type FundResult, IDENTITY_REGISTRY_ABI, InsufficientBalanceError, KYA_HOOK_ABI, MORPHO_BLUE_ABI, MorphoClient, type MorphoClientConfig, type MorphoMarketInfo, type MorphoMarketParams, type MorphoPosition, type PaymentRequirements, type PositionResult, type RegisterResult, type RepayResult, type ScoreAttestation, type ScoreResult, ScoringClient, type ScoringClientConfig, ScoringRejectedError, type SpendingTracker, type StatusResult, type TransactionResult, VALIDATION_REGISTRY_ABI, type WithdrawResult, X402Client, type X402Config, type X402PaymentRequest, type X402PaymentResult, type X402Response, bpsToRate, createConfig, formatAPR, formatAddress, formatHealthFactor, formatPercent, formatTimestamp, formatUSD, formatUnits, getDefaultConfig, parseUnits, rateToBps };
|
package/dist/index.d.ts
CHANGED
|
@@ -103,6 +103,7 @@ interface ContractAddresses {
|
|
|
103
103
|
accountFactory: string;
|
|
104
104
|
validationRegistry: string;
|
|
105
105
|
agentReputation: string;
|
|
106
|
+
kyaHook: string;
|
|
106
107
|
usdc: string;
|
|
107
108
|
identityRegistry: string;
|
|
108
109
|
morphoBlue: string;
|
|
@@ -176,10 +177,14 @@ declare class AgetherClient {
|
|
|
176
177
|
}
|
|
177
178
|
|
|
178
179
|
/**
|
|
179
|
-
* MorphoClient — Direct Morpho Blue lending via AgentAccount
|
|
180
|
+
* MorphoClient — Direct Morpho Blue lending via AgentAccount (ERC-7579)
|
|
180
181
|
*
|
|
181
182
|
* Architecture (no intermediary contract):
|
|
182
|
-
* EOA → AgentAccount.
|
|
183
|
+
* EOA → AgentAccount.execute(MODE_BATCH, ...) → Morpho Blue (direct)
|
|
184
|
+
*
|
|
185
|
+
* ERC-7579 execution modes:
|
|
186
|
+
* - Single: execute(MODE_SINGLE, abi.encode(target, value, callData))
|
|
187
|
+
* - Batch: execute(MODE_BATCH, abi.encode(Execution[]))
|
|
183
188
|
*
|
|
184
189
|
* Batched operations:
|
|
185
190
|
* - depositAndBorrow: [ERC20.approve, Morpho.supplyCollateral, Morpho.borrow]
|
|
@@ -342,8 +347,8 @@ declare class MorphoClient {
|
|
|
342
347
|
constructor(config: MorphoClientConfig);
|
|
343
348
|
/**
|
|
344
349
|
* Check whether the KYA (Know Your Agent) code verification gate is active.
|
|
345
|
-
*
|
|
346
|
-
*
|
|
350
|
+
* Reads the account's installed hook and checks if it has a non-zero
|
|
351
|
+
* validationRegistry — when set, the hook enforces KYA code approval.
|
|
347
352
|
*/
|
|
348
353
|
isKyaRequired(): Promise<boolean>;
|
|
349
354
|
/** Resolve the AgentAccount address (cached, with retry for flaky RPCs). */
|
|
@@ -535,11 +540,11 @@ declare class MorphoClient {
|
|
|
535
540
|
*/
|
|
536
541
|
private _refreshSigner;
|
|
537
542
|
/**
|
|
538
|
-
* Execute a single call via AgentAccount.execute.
|
|
543
|
+
* Execute a single call via AgentAccount.execute (ERC-7579 single mode).
|
|
539
544
|
*/
|
|
540
545
|
private exec;
|
|
541
546
|
/**
|
|
542
|
-
* Execute multiple calls via AgentAccount.
|
|
547
|
+
* Execute multiple calls via AgentAccount.execute (ERC-7579 batch mode).
|
|
543
548
|
*/
|
|
544
549
|
private batch;
|
|
545
550
|
/** Convert MorphoMarketParams to Solidity tuple. */
|
|
@@ -1040,6 +1045,7 @@ declare const AGENT_REPUTATION_ABI: string[];
|
|
|
1040
1045
|
declare const VALIDATION_REGISTRY_ABI: string[];
|
|
1041
1046
|
declare const MORPHO_BLUE_ABI: string[];
|
|
1042
1047
|
declare const ERC20_ABI: string[];
|
|
1048
|
+
declare const KYA_HOOK_ABI: string[];
|
|
1043
1049
|
|
|
1044
1050
|
/**
|
|
1045
1051
|
* Network configurations
|
|
@@ -1063,4 +1069,4 @@ declare function getDefaultConfig(chainId: ChainId): AgetherConfig;
|
|
|
1063
1069
|
*/
|
|
1064
1070
|
declare function createConfig(chainId: ChainId, options?: Partial<AgetherConfig>): AgetherConfig;
|
|
1065
1071
|
|
|
1066
|
-
export { ACCOUNT_FACTORY_ABI, AGENT_ACCOUNT_ABI, AGENT_REPUTATION_ABI, AgentIdentityClient, type AgentIdentityClientOptions, AgentNotApprovedError, AgetherClient, type AgetherClientOptions, type AgetherConfig, AgetherError, type AgetherSigner, type AgetherViemWallet, type BalancesResult, type BorrowResult, ChainId, type ContractAddresses, type DepositAndBorrowResult, type DepositResult, ERC20_ABI, type FundResult, IDENTITY_REGISTRY_ABI, InsufficientBalanceError, MORPHO_BLUE_ABI, MorphoClient, type MorphoClientConfig, type MorphoMarketInfo, type MorphoMarketParams, type MorphoPosition, type PaymentRequirements, type PositionResult, type RegisterResult, type RepayResult, type ScoreAttestation, type ScoreResult, ScoringClient, type ScoringClientConfig, ScoringRejectedError, type SpendingTracker, type StatusResult, type TransactionResult, VALIDATION_REGISTRY_ABI, type WithdrawResult, X402Client, type X402Config, type X402PaymentRequest, type X402PaymentResult, type X402Response, bpsToRate, createConfig, formatAPR, formatAddress, formatHealthFactor, formatPercent, formatTimestamp, formatUSD, formatUnits, getDefaultConfig, parseUnits, rateToBps };
|
|
1072
|
+
export { ACCOUNT_FACTORY_ABI, AGENT_ACCOUNT_ABI, AGENT_REPUTATION_ABI, AgentIdentityClient, type AgentIdentityClientOptions, AgentNotApprovedError, AgetherClient, type AgetherClientOptions, type AgetherConfig, AgetherError, type AgetherSigner, type AgetherViemWallet, type BalancesResult, type BorrowResult, ChainId, type ContractAddresses, type DepositAndBorrowResult, type DepositResult, ERC20_ABI, type FundResult, IDENTITY_REGISTRY_ABI, InsufficientBalanceError, KYA_HOOK_ABI, MORPHO_BLUE_ABI, MorphoClient, type MorphoClientConfig, type MorphoMarketInfo, type MorphoMarketParams, type MorphoPosition, type PaymentRequirements, type PositionResult, type RegisterResult, type RepayResult, type ScoreAttestation, type ScoreResult, ScoringClient, type ScoringClientConfig, ScoringRejectedError, type SpendingTracker, type StatusResult, type TransactionResult, VALIDATION_REGISTRY_ABI, type WithdrawResult, X402Client, type X402Config, type X402PaymentRequest, type X402PaymentResult, type X402Response, bpsToRate, createConfig, formatAPR, formatAddress, formatHealthFactor, formatPercent, formatTimestamp, formatUSD, formatUnits, getDefaultConfig, parseUnits, rateToBps };
|
package/dist/index.js
CHANGED
|
@@ -41,6 +41,7 @@ __export(index_exports, {
|
|
|
41
41
|
ERC20_ABI: () => ERC20_ABI,
|
|
42
42
|
IDENTITY_REGISTRY_ABI: () => IDENTITY_REGISTRY_ABI,
|
|
43
43
|
InsufficientBalanceError: () => InsufficientBalanceError,
|
|
44
|
+
KYA_HOOK_ABI: () => KYA_HOOK_ABI,
|
|
44
45
|
MORPHO_BLUE_ABI: () => MORPHO_BLUE_ABI,
|
|
45
46
|
MorphoClient: () => MorphoClient,
|
|
46
47
|
ScoringClient: () => ScoringClient,
|
|
@@ -126,24 +127,30 @@ var ACCOUNT_FACTORY_ABI = [
|
|
|
126
127
|
"function totalAccounts() view returns (uint256)",
|
|
127
128
|
"function getAgentId(address account) view returns (uint256)",
|
|
128
129
|
"function createAccount(uint256 agentId) returns (address account)",
|
|
129
|
-
"function
|
|
130
|
-
"function
|
|
131
|
-
"event AccountCreated(uint256 indexed agentId, address indexed account, address indexed owner)"
|
|
132
|
-
"event ValidationRegistryUpdated(address indexed oldRegistry, address indexed newRegistry)"
|
|
130
|
+
"function protocolHook() view returns (address)",
|
|
131
|
+
"function identityRegistry() view returns (address)",
|
|
132
|
+
"event AccountCreated(uint256 indexed agentId, address indexed account, address indexed owner)"
|
|
133
133
|
];
|
|
134
134
|
var AGENT_ACCOUNT_ABI = [
|
|
135
135
|
"function agentId() view returns (uint256)",
|
|
136
136
|
"function owner() view returns (address)",
|
|
137
137
|
"function factory() view returns (address)",
|
|
138
|
-
"function validationRegistry() view returns (address)",
|
|
139
138
|
"function identityRegistry() view returns (address)",
|
|
140
139
|
"function balanceOf(address token) view returns (uint256)",
|
|
141
140
|
"function ethBalance() view returns (uint256)",
|
|
142
|
-
|
|
143
|
-
"function
|
|
141
|
+
// ERC-7579 execution
|
|
142
|
+
"function execute(bytes32 mode, bytes executionCalldata) payable",
|
|
143
|
+
"function executeFromExecutor(bytes32 mode, bytes executionCalldata) payable returns (bytes[])",
|
|
144
|
+
// ERC-7579 module management
|
|
145
|
+
"function installModule(uint256 moduleTypeId, address module, bytes initData) payable",
|
|
146
|
+
"function uninstallModule(uint256 moduleTypeId, address module, bytes deInitData) payable",
|
|
147
|
+
"function isModuleInstalled(uint256 moduleTypeId, address module, bytes additionalContext) view returns (bool)",
|
|
148
|
+
"function hook() view returns (address)",
|
|
149
|
+
// Funding (direct, no execution needed)
|
|
144
150
|
"function fund(address token, uint256 amount)",
|
|
145
151
|
"function withdraw(address token, uint256 amount, address to)",
|
|
146
152
|
"function withdrawETH(uint256 amount, address to)",
|
|
153
|
+
// EIP-1271
|
|
147
154
|
"function isValidSignature(bytes32 hash, bytes signature) view returns (bytes4)"
|
|
148
155
|
];
|
|
149
156
|
var AGENT_REPUTATION_ABI = [
|
|
@@ -190,6 +197,10 @@ var ERC20_ABI = [
|
|
|
190
197
|
"function symbol() view returns (string)",
|
|
191
198
|
"function name() view returns (string)"
|
|
192
199
|
];
|
|
200
|
+
var KYA_HOOK_ABI = [
|
|
201
|
+
"function validationRegistry() view returns (address)",
|
|
202
|
+
"function setValidationRegistry(address newRegistry)"
|
|
203
|
+
];
|
|
193
204
|
|
|
194
205
|
// src/utils/config.ts
|
|
195
206
|
var CONTRACT_ADDRESSES = {
|
|
@@ -197,14 +208,16 @@ var CONTRACT_ADDRESSES = {
|
|
|
197
208
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
198
209
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
199
210
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
211
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
200
212
|
usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
201
213
|
identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
202
214
|
morphoBlue: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb"
|
|
203
215
|
},
|
|
204
216
|
[8453 /* Base */]: {
|
|
205
|
-
accountFactory: "
|
|
206
|
-
validationRegistry: "
|
|
207
|
-
agentReputation: "
|
|
217
|
+
accountFactory: "0x89a8758E60A56EcB47247D92E05447eFd450d6Bf",
|
|
218
|
+
validationRegistry: "0x6f76cF69B71Dc5F9A414BCEe4583b12738E47985",
|
|
219
|
+
agentReputation: "0xe88f3419a2dbac70e3aF6E487b0C63e8301C6A87",
|
|
220
|
+
kyaHook: "0x28e50Aa9eD517E369b2806928709B44062aD9821",
|
|
208
221
|
usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
209
222
|
identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
210
223
|
morphoBlue: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb"
|
|
@@ -213,6 +226,7 @@ var CONTRACT_ADDRESSES = {
|
|
|
213
226
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
214
227
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
215
228
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
229
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
216
230
|
usdc: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
217
231
|
identityRegistry: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
|
|
218
232
|
morphoBlue: "0x0000000000000000000000000000000000000000"
|
|
@@ -221,6 +235,7 @@ var CONTRACT_ADDRESSES = {
|
|
|
221
235
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
222
236
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
223
237
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
238
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
224
239
|
usdc: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
|
|
225
240
|
identityRegistry: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
|
|
226
241
|
morphoBlue: "0x0000000000000000000000000000000000000000"
|
|
@@ -229,6 +244,7 @@ var CONTRACT_ADDRESSES = {
|
|
|
229
244
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
230
245
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
231
246
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
247
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
232
248
|
usdc: "0x56d4d6aEe0278c5Df2FA23Ecb32eC146C9446FDf",
|
|
233
249
|
identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
234
250
|
morphoBlue: "0x0000000000000000000000000000000000000000"
|
|
@@ -458,6 +474,8 @@ var BASE_COLLATERALS = {
|
|
|
458
474
|
cbETH: { address: "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22", symbol: "cbETH", decimals: 18 }
|
|
459
475
|
};
|
|
460
476
|
var MORPHO_API_URL = "https://api.morpho.org/graphql";
|
|
477
|
+
var MODE_SINGLE = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
478
|
+
var MODE_BATCH = "0x0100000000000000000000000000000000000000000000000000000000000000";
|
|
461
479
|
var morphoIface = new import_ethers2.ethers.Interface(MORPHO_BLUE_ABI);
|
|
462
480
|
var erc20Iface = new import_ethers2.ethers.Interface(ERC20_ABI);
|
|
463
481
|
var MorphoClient = class {
|
|
@@ -501,12 +519,21 @@ var MorphoClient = class {
|
|
|
501
519
|
// ════════════════════════════════════════════════════════
|
|
502
520
|
/**
|
|
503
521
|
* Check whether the KYA (Know Your Agent) code verification gate is active.
|
|
504
|
-
*
|
|
505
|
-
*
|
|
522
|
+
* Reads the account's installed hook and checks if it has a non-zero
|
|
523
|
+
* validationRegistry — when set, the hook enforces KYA code approval.
|
|
506
524
|
*/
|
|
507
525
|
async isKyaRequired() {
|
|
508
|
-
|
|
509
|
-
|
|
526
|
+
try {
|
|
527
|
+
const acctAddr = await this.getAccountAddress();
|
|
528
|
+
const account = new import_ethers2.Contract(acctAddr, AGENT_ACCOUNT_ABI, this.provider);
|
|
529
|
+
const hookAddr = await account.hook();
|
|
530
|
+
if (hookAddr === import_ethers2.ethers.ZeroAddress) return false;
|
|
531
|
+
const hook = new import_ethers2.Contract(hookAddr, KYA_HOOK_ABI, this.provider);
|
|
532
|
+
const registryAddr = await hook.validationRegistry();
|
|
533
|
+
return registryAddr !== import_ethers2.ethers.ZeroAddress;
|
|
534
|
+
} catch {
|
|
535
|
+
return false;
|
|
536
|
+
}
|
|
510
537
|
}
|
|
511
538
|
// ════════════════════════════════════════════════════════
|
|
512
539
|
// Account Management
|
|
@@ -1378,39 +1405,48 @@ var MorphoClient = class {
|
|
|
1378
1405
|
}
|
|
1379
1406
|
}
|
|
1380
1407
|
/**
|
|
1381
|
-
* Execute a single call via AgentAccount.execute.
|
|
1408
|
+
* Execute a single call via AgentAccount.execute (ERC-7579 single mode).
|
|
1382
1409
|
*/
|
|
1383
1410
|
async exec(target, data, value = 0n) {
|
|
1384
1411
|
const acctAddr = await this.getAccountAddress();
|
|
1385
1412
|
const account = new import_ethers2.Contract(acctAddr, AGENT_ACCOUNT_ABI, this._signer);
|
|
1413
|
+
const executionCalldata = import_ethers2.ethers.AbiCoder.defaultAbiCoder().encode(
|
|
1414
|
+
["address", "uint256", "bytes"],
|
|
1415
|
+
[target, value, data]
|
|
1416
|
+
);
|
|
1386
1417
|
let gasLimit;
|
|
1387
1418
|
try {
|
|
1388
|
-
const estimate = await account.execute.estimateGas(
|
|
1419
|
+
const estimate = await account.execute.estimateGas(MODE_SINGLE, executionCalldata);
|
|
1389
1420
|
gasLimit = estimate * 130n / 100n;
|
|
1390
1421
|
} catch (e) {
|
|
1391
1422
|
console.warn("[agether] exec gas estimation failed, using default 500k:", e instanceof Error ? e.message : e);
|
|
1392
1423
|
gasLimit = 500000n;
|
|
1393
1424
|
}
|
|
1394
|
-
const tx = await account.execute(
|
|
1425
|
+
const tx = await account.execute(MODE_SINGLE, executionCalldata, { gasLimit });
|
|
1395
1426
|
const receipt = await tx.wait();
|
|
1396
1427
|
this._refreshSigner();
|
|
1397
1428
|
return receipt;
|
|
1398
1429
|
}
|
|
1399
1430
|
/**
|
|
1400
|
-
* Execute multiple calls via AgentAccount.
|
|
1431
|
+
* Execute multiple calls via AgentAccount.execute (ERC-7579 batch mode).
|
|
1401
1432
|
*/
|
|
1402
1433
|
async batch(targets, values, datas) {
|
|
1403
1434
|
const acctAddr = await this.getAccountAddress();
|
|
1404
1435
|
const account = new import_ethers2.Contract(acctAddr, AGENT_ACCOUNT_ABI, this._signer);
|
|
1436
|
+
const executions = targets.map((t, i) => [t, values[i], datas[i]]);
|
|
1437
|
+
const executionCalldata = import_ethers2.ethers.AbiCoder.defaultAbiCoder().encode(
|
|
1438
|
+
["(address,uint256,bytes)[]"],
|
|
1439
|
+
[executions]
|
|
1440
|
+
);
|
|
1405
1441
|
let gasLimit;
|
|
1406
1442
|
try {
|
|
1407
|
-
const estimate = await account.
|
|
1443
|
+
const estimate = await account.execute.estimateGas(MODE_BATCH, executionCalldata);
|
|
1408
1444
|
gasLimit = estimate * 130n / 100n;
|
|
1409
1445
|
} catch (e) {
|
|
1410
1446
|
console.warn("[agether] batch gas estimation failed, using default 800k:", e instanceof Error ? e.message : e);
|
|
1411
1447
|
gasLimit = 800000n;
|
|
1412
1448
|
}
|
|
1413
|
-
const tx = await account.
|
|
1449
|
+
const tx = await account.execute(MODE_BATCH, executionCalldata, { gasLimit });
|
|
1414
1450
|
const receipt = await tx.wait();
|
|
1415
1451
|
this._refreshSigner();
|
|
1416
1452
|
return receipt;
|
|
@@ -2250,6 +2286,7 @@ function rateToBps(rate) {
|
|
|
2250
2286
|
ERC20_ABI,
|
|
2251
2287
|
IDENTITY_REGISTRY_ABI,
|
|
2252
2288
|
InsufficientBalanceError,
|
|
2289
|
+
KYA_HOOK_ABI,
|
|
2253
2290
|
MORPHO_BLUE_ABI,
|
|
2254
2291
|
MorphoClient,
|
|
2255
2292
|
ScoringClient,
|
package/dist/index.mjs
CHANGED
|
@@ -62,24 +62,30 @@ var ACCOUNT_FACTORY_ABI = [
|
|
|
62
62
|
"function totalAccounts() view returns (uint256)",
|
|
63
63
|
"function getAgentId(address account) view returns (uint256)",
|
|
64
64
|
"function createAccount(uint256 agentId) returns (address account)",
|
|
65
|
-
"function
|
|
66
|
-
"function
|
|
67
|
-
"event AccountCreated(uint256 indexed agentId, address indexed account, address indexed owner)"
|
|
68
|
-
"event ValidationRegistryUpdated(address indexed oldRegistry, address indexed newRegistry)"
|
|
65
|
+
"function protocolHook() view returns (address)",
|
|
66
|
+
"function identityRegistry() view returns (address)",
|
|
67
|
+
"event AccountCreated(uint256 indexed agentId, address indexed account, address indexed owner)"
|
|
69
68
|
];
|
|
70
69
|
var AGENT_ACCOUNT_ABI = [
|
|
71
70
|
"function agentId() view returns (uint256)",
|
|
72
71
|
"function owner() view returns (address)",
|
|
73
72
|
"function factory() view returns (address)",
|
|
74
|
-
"function validationRegistry() view returns (address)",
|
|
75
73
|
"function identityRegistry() view returns (address)",
|
|
76
74
|
"function balanceOf(address token) view returns (uint256)",
|
|
77
75
|
"function ethBalance() view returns (uint256)",
|
|
78
|
-
|
|
79
|
-
"function
|
|
76
|
+
// ERC-7579 execution
|
|
77
|
+
"function execute(bytes32 mode, bytes executionCalldata) payable",
|
|
78
|
+
"function executeFromExecutor(bytes32 mode, bytes executionCalldata) payable returns (bytes[])",
|
|
79
|
+
// ERC-7579 module management
|
|
80
|
+
"function installModule(uint256 moduleTypeId, address module, bytes initData) payable",
|
|
81
|
+
"function uninstallModule(uint256 moduleTypeId, address module, bytes deInitData) payable",
|
|
82
|
+
"function isModuleInstalled(uint256 moduleTypeId, address module, bytes additionalContext) view returns (bool)",
|
|
83
|
+
"function hook() view returns (address)",
|
|
84
|
+
// Funding (direct, no execution needed)
|
|
80
85
|
"function fund(address token, uint256 amount)",
|
|
81
86
|
"function withdraw(address token, uint256 amount, address to)",
|
|
82
87
|
"function withdrawETH(uint256 amount, address to)",
|
|
88
|
+
// EIP-1271
|
|
83
89
|
"function isValidSignature(bytes32 hash, bytes signature) view returns (bytes4)"
|
|
84
90
|
];
|
|
85
91
|
var AGENT_REPUTATION_ABI = [
|
|
@@ -126,6 +132,10 @@ var ERC20_ABI = [
|
|
|
126
132
|
"function symbol() view returns (string)",
|
|
127
133
|
"function name() view returns (string)"
|
|
128
134
|
];
|
|
135
|
+
var KYA_HOOK_ABI = [
|
|
136
|
+
"function validationRegistry() view returns (address)",
|
|
137
|
+
"function setValidationRegistry(address newRegistry)"
|
|
138
|
+
];
|
|
129
139
|
|
|
130
140
|
// src/utils/config.ts
|
|
131
141
|
var CONTRACT_ADDRESSES = {
|
|
@@ -133,14 +143,16 @@ var CONTRACT_ADDRESSES = {
|
|
|
133
143
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
134
144
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
135
145
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
146
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
136
147
|
usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
137
148
|
identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
138
149
|
morphoBlue: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb"
|
|
139
150
|
},
|
|
140
151
|
[8453 /* Base */]: {
|
|
141
|
-
accountFactory: "
|
|
142
|
-
validationRegistry: "
|
|
143
|
-
agentReputation: "
|
|
152
|
+
accountFactory: "0x89a8758E60A56EcB47247D92E05447eFd450d6Bf",
|
|
153
|
+
validationRegistry: "0x6f76cF69B71Dc5F9A414BCEe4583b12738E47985",
|
|
154
|
+
agentReputation: "0xe88f3419a2dbac70e3aF6E487b0C63e8301C6A87",
|
|
155
|
+
kyaHook: "0x28e50Aa9eD517E369b2806928709B44062aD9821",
|
|
144
156
|
usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
145
157
|
identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
146
158
|
morphoBlue: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb"
|
|
@@ -149,6 +161,7 @@ var CONTRACT_ADDRESSES = {
|
|
|
149
161
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
150
162
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
151
163
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
164
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
152
165
|
usdc: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
153
166
|
identityRegistry: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
|
|
154
167
|
morphoBlue: "0x0000000000000000000000000000000000000000"
|
|
@@ -157,6 +170,7 @@ var CONTRACT_ADDRESSES = {
|
|
|
157
170
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
158
171
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
159
172
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
173
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
160
174
|
usdc: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
|
|
161
175
|
identityRegistry: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
|
|
162
176
|
morphoBlue: "0x0000000000000000000000000000000000000000"
|
|
@@ -165,6 +179,7 @@ var CONTRACT_ADDRESSES = {
|
|
|
165
179
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
166
180
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
167
181
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
182
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
168
183
|
usdc: "0x56d4d6aEe0278c5Df2FA23Ecb32eC146C9446FDf",
|
|
169
184
|
identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
170
185
|
morphoBlue: "0x0000000000000000000000000000000000000000"
|
|
@@ -394,6 +409,8 @@ var BASE_COLLATERALS = {
|
|
|
394
409
|
cbETH: { address: "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22", symbol: "cbETH", decimals: 18 }
|
|
395
410
|
};
|
|
396
411
|
var MORPHO_API_URL = "https://api.morpho.org/graphql";
|
|
412
|
+
var MODE_SINGLE = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
413
|
+
var MODE_BATCH = "0x0100000000000000000000000000000000000000000000000000000000000000";
|
|
397
414
|
var morphoIface = new ethers2.Interface(MORPHO_BLUE_ABI);
|
|
398
415
|
var erc20Iface = new ethers2.Interface(ERC20_ABI);
|
|
399
416
|
var MorphoClient = class {
|
|
@@ -437,12 +454,21 @@ var MorphoClient = class {
|
|
|
437
454
|
// ════════════════════════════════════════════════════════
|
|
438
455
|
/**
|
|
439
456
|
* Check whether the KYA (Know Your Agent) code verification gate is active.
|
|
440
|
-
*
|
|
441
|
-
*
|
|
457
|
+
* Reads the account's installed hook and checks if it has a non-zero
|
|
458
|
+
* validationRegistry — when set, the hook enforces KYA code approval.
|
|
442
459
|
*/
|
|
443
460
|
async isKyaRequired() {
|
|
444
|
-
|
|
445
|
-
|
|
461
|
+
try {
|
|
462
|
+
const acctAddr = await this.getAccountAddress();
|
|
463
|
+
const account = new Contract2(acctAddr, AGENT_ACCOUNT_ABI, this.provider);
|
|
464
|
+
const hookAddr = await account.hook();
|
|
465
|
+
if (hookAddr === ethers2.ZeroAddress) return false;
|
|
466
|
+
const hook = new Contract2(hookAddr, KYA_HOOK_ABI, this.provider);
|
|
467
|
+
const registryAddr = await hook.validationRegistry();
|
|
468
|
+
return registryAddr !== ethers2.ZeroAddress;
|
|
469
|
+
} catch {
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
446
472
|
}
|
|
447
473
|
// ════════════════════════════════════════════════════════
|
|
448
474
|
// Account Management
|
|
@@ -1314,39 +1340,48 @@ var MorphoClient = class {
|
|
|
1314
1340
|
}
|
|
1315
1341
|
}
|
|
1316
1342
|
/**
|
|
1317
|
-
* Execute a single call via AgentAccount.execute.
|
|
1343
|
+
* Execute a single call via AgentAccount.execute (ERC-7579 single mode).
|
|
1318
1344
|
*/
|
|
1319
1345
|
async exec(target, data, value = 0n) {
|
|
1320
1346
|
const acctAddr = await this.getAccountAddress();
|
|
1321
1347
|
const account = new Contract2(acctAddr, AGENT_ACCOUNT_ABI, this._signer);
|
|
1348
|
+
const executionCalldata = ethers2.AbiCoder.defaultAbiCoder().encode(
|
|
1349
|
+
["address", "uint256", "bytes"],
|
|
1350
|
+
[target, value, data]
|
|
1351
|
+
);
|
|
1322
1352
|
let gasLimit;
|
|
1323
1353
|
try {
|
|
1324
|
-
const estimate = await account.execute.estimateGas(
|
|
1354
|
+
const estimate = await account.execute.estimateGas(MODE_SINGLE, executionCalldata);
|
|
1325
1355
|
gasLimit = estimate * 130n / 100n;
|
|
1326
1356
|
} catch (e) {
|
|
1327
1357
|
console.warn("[agether] exec gas estimation failed, using default 500k:", e instanceof Error ? e.message : e);
|
|
1328
1358
|
gasLimit = 500000n;
|
|
1329
1359
|
}
|
|
1330
|
-
const tx = await account.execute(
|
|
1360
|
+
const tx = await account.execute(MODE_SINGLE, executionCalldata, { gasLimit });
|
|
1331
1361
|
const receipt = await tx.wait();
|
|
1332
1362
|
this._refreshSigner();
|
|
1333
1363
|
return receipt;
|
|
1334
1364
|
}
|
|
1335
1365
|
/**
|
|
1336
|
-
* Execute multiple calls via AgentAccount.
|
|
1366
|
+
* Execute multiple calls via AgentAccount.execute (ERC-7579 batch mode).
|
|
1337
1367
|
*/
|
|
1338
1368
|
async batch(targets, values, datas) {
|
|
1339
1369
|
const acctAddr = await this.getAccountAddress();
|
|
1340
1370
|
const account = new Contract2(acctAddr, AGENT_ACCOUNT_ABI, this._signer);
|
|
1371
|
+
const executions = targets.map((t, i) => [t, values[i], datas[i]]);
|
|
1372
|
+
const executionCalldata = ethers2.AbiCoder.defaultAbiCoder().encode(
|
|
1373
|
+
["(address,uint256,bytes)[]"],
|
|
1374
|
+
[executions]
|
|
1375
|
+
);
|
|
1341
1376
|
let gasLimit;
|
|
1342
1377
|
try {
|
|
1343
|
-
const estimate = await account.
|
|
1378
|
+
const estimate = await account.execute.estimateGas(MODE_BATCH, executionCalldata);
|
|
1344
1379
|
gasLimit = estimate * 130n / 100n;
|
|
1345
1380
|
} catch (e) {
|
|
1346
1381
|
console.warn("[agether] batch gas estimation failed, using default 800k:", e instanceof Error ? e.message : e);
|
|
1347
1382
|
gasLimit = 800000n;
|
|
1348
1383
|
}
|
|
1349
|
-
const tx = await account.
|
|
1384
|
+
const tx = await account.execute(MODE_BATCH, executionCalldata, { gasLimit });
|
|
1350
1385
|
const receipt = await tx.wait();
|
|
1351
1386
|
this._refreshSigner();
|
|
1352
1387
|
return receipt;
|
|
@@ -2185,6 +2220,7 @@ export {
|
|
|
2185
2220
|
ERC20_ABI,
|
|
2186
2221
|
IDENTITY_REGISTRY_ABI,
|
|
2187
2222
|
InsufficientBalanceError,
|
|
2223
|
+
KYA_HOOK_ABI,
|
|
2188
2224
|
MORPHO_BLUE_ABI,
|
|
2189
2225
|
MorphoClient,
|
|
2190
2226
|
ScoringClient,
|