cronos-agent-wallet 1.2.6 → 1.2.7
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/internal/AgentWallet.js +11 -3
- package/package.json +1 -1
|
@@ -192,12 +192,15 @@ class AgentWallet {
|
|
|
192
192
|
const localHash = hashPolicy(this.config);
|
|
193
193
|
// Note: We check if on-chain hash is set (non-zero) before enforcing
|
|
194
194
|
if (onChain.policyHash !== ethers_1.ethers.ZeroHash && onChain.policyHash !== localHash) {
|
|
195
|
-
const msg = `Policy
|
|
195
|
+
const msg = `[SECURITY] Policy Mismatch! Your local config (dailyLimit/maxPerTx) differs from the on-chain policy. \n` +
|
|
196
|
+
` -> Local Hash: ${localHash}\n` +
|
|
197
|
+
` -> Chain Hash: ${onChain.policyHash}\n` +
|
|
198
|
+
` -> Tip: Ensure your 'AgentClient' config matches what you deployed via 'set_policy'.`;
|
|
196
199
|
if (this.config?.strictPolicy) {
|
|
197
200
|
throw new Error(msg);
|
|
198
201
|
}
|
|
199
202
|
else {
|
|
200
|
-
console.warn(`[AgentWallet] WARN: ${msg}
|
|
203
|
+
console.warn(`[AgentWallet] WARN: ${msg}\n -> Running in PERMISSIVE mode.`);
|
|
201
204
|
}
|
|
202
205
|
}
|
|
203
206
|
else {
|
|
@@ -205,7 +208,12 @@ class AgentWallet {
|
|
|
205
208
|
}
|
|
206
209
|
}
|
|
207
210
|
catch (error) {
|
|
208
|
-
|
|
211
|
+
// Only log here if we are NOT throwing (i.e. unexpected errors), or if permissive.
|
|
212
|
+
// If strict, the caller (constructor) will catch and log/exit, so we avoid double logs.
|
|
213
|
+
if (!this.config?.strictPolicy) {
|
|
214
|
+
console.error("[AgentWallet] Anchor check failed:", error.message);
|
|
215
|
+
}
|
|
216
|
+
// Propagate if strict
|
|
209
217
|
if (this.config?.strictPolicy)
|
|
210
218
|
throw error;
|
|
211
219
|
}
|