@pushchain/core 6.0.27-alpha.0 → 6.0.27-alpha.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.
Files changed (78) hide show
  1. package/AGW.md +49 -17
  2. package/CHANGELOG.md +10 -0
  3. package/package.json +1 -1
  4. package/src/lib/agentic/agentic.types.d.ts +8 -3
  5. package/src/lib/agentic/capabilities.d.ts +1 -1
  6. package/src/lib/agentic/capabilities.js +1 -1
  7. package/src/lib/agentic/codec/abi-layout.d.ts +5 -0
  8. package/src/lib/agentic/codec/abi-layout.js +50 -3
  9. package/src/lib/agentic/codec/defaults.d.ts +2 -2
  10. package/src/lib/agentic/codec/defaults.js +2 -2
  11. package/src/lib/agentic/codec/ids.d.ts +1 -1
  12. package/src/lib/agentic/codec/ids.js +1 -1
  13. package/src/lib/agentic/codec/native.d.ts +4 -6
  14. package/src/lib/agentic/codec/native.js +27 -14
  15. package/src/lib/agentic/codec/pins.d.ts +20 -0
  16. package/src/lib/agentic/codec/pins.js +29 -0
  17. package/src/lib/agentic/codec/rules.d.ts +1 -1
  18. package/src/lib/agentic/codec/rules.js +3 -3
  19. package/src/lib/agentic/codec/session.d.ts +2 -2
  20. package/src/lib/agentic/codec/session.js +3 -3
  21. package/src/lib/agentic/codec/svm-terms.d.ts +1 -1
  22. package/src/lib/agentic/codec/svm-terms.js +7 -3
  23. package/src/lib/agentic/codec/universal-terms.d.ts +15 -0
  24. package/src/lib/agentic/codec/universal-terms.js +2 -0
  25. package/src/lib/agentic/codec/universal.js +22 -6
  26. package/src/lib/agentic/constants.d.ts +1 -0
  27. package/src/lib/agentic/constants.js +1 -0
  28. package/src/lib/agentic/contracts/abi/{v5 → v6}/agent-validator.js +1 -1
  29. package/src/lib/agentic/contracts/abi/{v5 → v6}/agw-factory.d.ts +299 -0
  30. package/src/lib/agentic/contracts/abi/{v5 → v6}/agw-factory.js +393 -2
  31. package/src/lib/agentic/contracts/abi/{v5 → v6}/agw.d.ts +96 -1
  32. package/src/lib/agentic/contracts/abi/{v5 → v6}/agw.js +128 -3
  33. package/src/lib/agentic/contracts/abi/{v5 → v6}/index.d.ts +1 -1
  34. package/src/lib/agentic/contracts/abi/{v5 → v6}/index.js +3 -3
  35. package/src/lib/agentic/contracts/abi/{v5 → v6}/smart-session.js +1 -1
  36. package/src/lib/agentic/contracts/abi/{v5 → v6}/universal-rules-policy.d.ts +329 -308
  37. package/src/lib/agentic/contracts/abi/{v5 → v6}/universal-rules-policy.js +396 -369
  38. package/src/lib/agentic/contracts/donut-v6.d.ts +11 -0
  39. package/src/lib/agentic/contracts/donut-v6.js +15 -0
  40. package/src/lib/agentic/contracts/{v5.d.ts → v6.d.ts} +800 -384
  41. package/src/lib/agentic/contracts/{v5.js → v6.js} +60 -33
  42. package/src/lib/agentic/deployments.d.ts +5 -5
  43. package/src/lib/agentic/deployments.js +19 -19
  44. package/src/lib/agentic/errors.d.ts +1 -7
  45. package/src/lib/agentic/errors.js +1 -9
  46. package/src/lib/agentic/execution/outbound.d.ts +4 -4
  47. package/src/lib/agentic/execution/outbound.js +5 -5
  48. package/src/lib/agentic/execution/send.js +3 -11
  49. package/src/lib/agentic/execution/svm-outbound.d.ts +1 -1
  50. package/src/lib/agentic/execution/svm-payload.js +1 -1
  51. package/src/lib/agentic/execution/svm-public.js +1 -7
  52. package/src/lib/agentic/execution/svm-send.d.ts +1 -1
  53. package/src/lib/agentic/execution/svm-send.js +0 -3
  54. package/src/lib/agentic/index.d.ts +1 -1
  55. package/src/lib/agentic/management/common.js +7 -5
  56. package/src/lib/agentic/management/create.d.ts +1 -13
  57. package/src/lib/agentic/management/create.js +24 -157
  58. package/src/lib/agentic/management/svm.js +2 -2
  59. package/src/lib/agentic/presets/catalog.d.ts +7 -2
  60. package/src/lib/agentic/presets/catalog.js +300 -3
  61. package/src/lib/agentic/presets/index.js +93 -18
  62. package/src/lib/agentic/presets/types.d.ts +5 -1
  63. package/src/lib/agentic/public-rule.d.ts +2 -2
  64. package/src/lib/agentic/public-rule.js +24 -40
  65. package/src/lib/agentic/reads/rules.js +27 -11
  66. package/src/lib/agentic/reads/svm.d.ts +1 -1
  67. package/src/lib/agentic/reads/svm.js +2 -2
  68. package/src/lib/agentic/response.js +7 -7
  69. package/src/lib/agentic/revert.js +5 -5
  70. package/src/lib/agentic/runtime.js +12 -3
  71. package/src/lib/agentic/utils.js +1 -1
  72. package/src/lib/constants/index.d.ts +1 -0
  73. package/src/lib/index.d.ts +1 -1
  74. package/src/lib/push-chain/push-chain.d.ts +1 -0
  75. package/src/lib/agentic/contracts/donut-v5.d.ts +0 -11
  76. package/src/lib/agentic/contracts/donut-v5.js +0 -15
  77. /package/src/lib/agentic/contracts/abi/{v5 → v6}/agent-validator.d.ts +0 -0
  78. /package/src/lib/agentic/contracts/abi/{v5 → v6}/smart-session.d.ts +0 -0
@@ -25,7 +25,9 @@ async function assertOwner(runtime, gen, wallet, snap) {
25
25
  const owner = (0, viem_1.getAddress)(await snap.read(wallet, gen.contracts.abis.wallet, 'owner'));
26
26
  const signer = runtime.signerPushAccount();
27
27
  if (owner !== signer) {
28
- throw new errors_2.AgenticError(errors_2.AGENTIC_ERROR_CODE.NOT_WALLET_OWNER, `${signer} is not the owner of ${wallet} (owner is ${owner})`, { hint: 'Rule and label writes are owner-only. Initialize with the owner signer.' });
28
+ throw new errors_2.AgenticError(errors_2.AGENTIC_ERROR_CODE.NOT_WALLET_OWNER, `${signer} is not the owner of ${wallet} (owner is ${owner})`, {
29
+ hint: 'Rule and label writes are owner-only. Initialize with the owner signer.',
30
+ });
29
31
  }
30
32
  return owner;
31
33
  }
@@ -66,7 +68,7 @@ async function confirmedLogs(runtime, tx) {
66
68
  if (hashes.length === 1) {
67
69
  if (receipt.status !== 1) {
68
70
  throw new errors_2.AgenticRevertError(`Push transaction ${tx.hash} reverted`, {
69
- transactionHashes: hashes,
71
+ cause: { txHash: tx.hash },
70
72
  });
71
73
  }
72
74
  return { logs: receipt.logs, hashes };
@@ -81,7 +83,9 @@ async function confirmedLogs(runtime, tx) {
81
83
  throw unavailable(cause);
82
84
  }
83
85
  if (r.status !== 'success') {
84
- throw new errors_2.AgenticRevertError(`Push transaction ${hash} reverted`, { transactionHashes: hashes });
86
+ throw new errors_2.AgenticRevertError(`Push transaction ${hash} reverted`, {
87
+ cause: { txHash: hash },
88
+ });
85
89
  }
86
90
  logs.push(...r.logs);
87
91
  }
@@ -95,8 +99,6 @@ function wrapSendError(err) {
95
99
  if (err instanceof errors_1.PushChainBatchExecutionError) {
96
100
  return new errors_2.AgenticRevertError(err.message, {
97
101
  decodedError: decoded ?? err.decodedError,
98
- transactionHashes: err.transactionHashes,
99
- pendingTransactionHash: err.pendingTransactionHash,
100
102
  cause: err,
101
103
  });
102
104
  }
@@ -1,16 +1,4 @@
1
1
  import type { AgenticRuntime } from '../runtime';
2
2
  import type { InternalCreateOptions, CreateResult } from '../agentic.types';
3
- /**
4
- * client.agentic.create(label, { rules }): deploy + grants only. Funding and
5
- * approvals are separate ordinary sends. Every input is validated and every
6
- * prediction re-read immediately before signing; IDs are returned from
7
- * receipts in input order.
8
- *
9
- * Strategy follows the signer: an external owner's UEA batches atomically, a
10
- * Push EOA uses an EIP-7702 batch when available and otherwise the documented
11
- * sequential fallback. A sequential failure raises CREATE_PARTIAL with the
12
- * deployed wallet, confirmed/pending hashes and granted IDs so the caller can
13
- * finish with `wallet(w).rules.add(remaining)` — the SDK never deploys another
14
- * wallet on its own.
15
- */
3
+ /** One index-bound v6 factory call deploys and grants atomically for EOA/UEA owners. */
16
4
  export declare function createWallet(runtime: AgenticRuntime, label: string, options: InternalCreateOptions): Promise<CreateResult>;
@@ -4,34 +4,21 @@ exports.createWallet = createWallet;
4
4
  const duplicates_1 = require("./duplicates");
5
5
  const viem_1 = require("viem");
6
6
  const progress_hook_types_1 = require("../../progress-hook/progress-hook.types");
7
- const errors_1 = require("../../orchestrator/internals/errors");
8
7
  const capabilities_1 = require("../capabilities");
9
8
  const deployments_1 = require("../deployments");
10
9
  const ids_1 = require("../codec/ids");
11
10
  const prepare_1 = require("./prepare");
12
11
  const label_1 = require("./label");
13
- const errors_2 = require("../errors");
12
+ const errors_1 = require("../errors");
14
13
  const snapshot_1 = require("../reads/snapshot");
15
14
  const wallets_1 = require("../reads/wallets");
16
15
  const common_1 = require("./common");
17
- /**
18
- * client.agentic.create(label, { rules }): deploy + grants only. Funding and
19
- * approvals are separate ordinary sends. Every input is validated and every
20
- * prediction re-read immediately before signing; IDs are returned from
21
- * receipts in input order.
22
- *
23
- * Strategy follows the signer: an external owner's UEA batches atomically, a
24
- * Push EOA uses an EIP-7702 batch when available and otherwise the documented
25
- * sequential fallback. A sequential failure raises CREATE_PARTIAL with the
26
- * deployed wallet, confirmed/pending hashes and granted IDs so the caller can
27
- * finish with `wallet(w).rules.add(remaining)` — the SDK never deploys another
28
- * wallet on its own.
29
- */
16
+ /** One index-bound v6 factory call deploys and grants atomically for EOA/UEA owners. */
30
17
  async function createWallet(runtime, label, options) {
31
18
  const hook = options?.progressHook;
32
19
  (0, label_1.assertLabel)(label);
33
20
  if (!options || !Array.isArray(options.rules)) {
34
- throw new errors_2.AgenticError(errors_2.AGENTIC_ERROR_CODE.INVALID_RULE, 'options.rules is required (use [] for a bare wallet)');
21
+ throw new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.INVALID_RULE, 'options.rules is required (use [] for a bare wallet)');
35
22
  }
36
23
  (0, common_1.assertCanSign)(runtime, 'agentic.create');
37
24
  const gen = (0, deployments_1.currentGeneration)(runtime.network);
@@ -49,13 +36,13 @@ async function createWallet(runtime, label, options) {
49
36
  index,
50
37
  });
51
38
  if (wallet !== mirror || deployed || (await snap.code(wallet))) {
52
- throw new errors_2.AgenticError(errors_2.AGENTIC_ERROR_CODE.INDEX_RACE, `next wallet slot ${index} for ${owner} is not a fresh counterfactual address`, { details: { wallet, mirror, deployed } });
39
+ throw new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.INDEX_RACE, `next wallet slot ${index} for ${owner} is not a fresh counterfactual address`, { details: { wallet, mirror, deployed } });
53
40
  }
54
41
  const prepared = await (0, prepare_1.prepareWalletRules)(runtime, gen, owner, wallet, options.rules, snap);
55
42
  (0, duplicates_1.assertNoDuplicateRules)(prepared);
56
43
  const selfTarget = prepared.findIndex((p) => p.nativeTerms?.some((t) => t.target === wallet));
57
44
  if (selfTarget >= 0) {
58
- throw new errors_2.AgenticError(errors_2.AGENTIC_ERROR_CODE.INVALID_RULE, `rules[${selfTarget}].target is the wallet being created; the contracts refuse it as a native target`);
45
+ throw new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.INVALID_RULE, `rules[${selfTarget}].target is the wallet being created; the contracts refuse it as a native target`);
59
46
  }
60
47
  (0, common_1.emitAgentic)(runtime, hook, progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_101, wallet, Number(index), false);
61
48
  // A fresh wallet's grant nonce starts at 0 and increments per grant.
@@ -64,31 +51,22 @@ async function createWallet(runtime, label, options) {
64
51
  agent: p.agent,
65
52
  grantNonce: BigInt(i),
66
53
  }));
54
+ if (prepared.length > 8)
55
+ throw new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.INVALID_RULE, 'create accepts at most eight initial rules');
67
56
  const calls = [
68
- // Index-bound: reverts (nothing committed) if another creation took this slot.
69
57
  {
70
58
  to: gen.addresses.factory,
71
59
  value: BigInt(0),
72
- data: gen.contracts.encodeDeployWalletAt(owner, index, wallet, label),
60
+ data: gen.contracts.encodeCreateWalletAt(owner, index, wallet, label, prepared.map((p) => p.session)),
73
61
  },
74
- ...prepared.map((p) => ({
75
- to: wallet,
76
- value: BigInt(0),
77
- data: gen.contracts.encodeGrantRules(p.session),
78
- })),
79
62
  ];
80
- const strategy = calls.length === 1
81
- ? 'single'
82
- : runtime.signerIsPushNative()
83
- ? 'push-eoa-batch'
84
- : 'uea-multicall';
85
- (0, common_1.emitAgentic)(runtime, hook, progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_102, wallet, strategy);
63
+ (0, common_1.emitAgentic)(runtime, hook, progress_hook_types_1.PROGRESS_HOOK.AGENTIC_TX_102, wallet, 'single');
86
64
  let tx;
87
65
  try {
88
66
  tx = await (0, common_1.sendOwnerCalls)(runtime, calls, hook);
89
67
  }
90
68
  catch (err) {
91
- const wrapped = await createFailure(runtime, gen, wallet, Number(index), owner, label, err);
69
+ const wrapped = atomicCreateFailure(err);
92
70
  emitFailure(runtime, hook, wrapped);
93
71
  throw wrapped;
94
72
  }
@@ -97,7 +75,7 @@ async function createWallet(runtime, label, options) {
97
75
  ({ logs } = await (0, common_1.confirmedLogs)(runtime, tx));
98
76
  }
99
77
  catch (err) {
100
- const wrapped = await createFailure(runtime, gen, wallet, Number(index), owner, label, err);
78
+ const wrapped = atomicCreateFailure(err);
101
79
  emitFailure(runtime, hook, wrapped);
102
80
  throw wrapped;
103
81
  }
@@ -108,9 +86,9 @@ async function createWallet(runtime, label, options) {
108
86
  if (deployedEv.length !== 1 ||
109
87
  deployedEv[0].wallet !== wallet ||
110
88
  deployedEv[0].index !== index) {
111
- const err = new errors_2.AgenticError(errors_2.AGENTIC_ERROR_CODE.INDEX_RACE, `deployWallet produced ${deployedEv.map((d) => `${d.wallet}#${d.index}`).join(', ') ||
89
+ const err = new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.RECEIPT_MISMATCH, `createWallet produced ${deployedEv.map((d) => `${d.wallet}#${d.index}`).join(', ') ||
112
90
  'no wallet'}, expected ${wallet}#${index}; grants targeted ${wallet}`, {
113
- hint: 'Another deployment by this owner raced this call. Inspect both wallets with client.agentic.list() before retrying.',
91
+ hint: 'The receipt does not describe the requested atomic creation. Inspect the submitted hash before retrying.',
114
92
  details: {
115
93
  expected: wallet,
116
94
  deployed: deployedEv,
@@ -122,7 +100,7 @@ async function createWallet(runtime, label, options) {
122
100
  throw err;
123
101
  }
124
102
  if (!sameIds(granted, predictedIds)) {
125
- const err = new errors_2.AgenticError(errors_2.AGENTIC_ERROR_CODE.RECEIPT_MISMATCH, 'RulesGranted events do not match the requested rules in order', { details: { granted, predicted: predictedIds, txHash: tx.hash } });
103
+ const err = new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.RECEIPT_MISMATCH, 'RulesGranted events do not match the requested rules in order', { details: { granted, predicted: predictedIds, txHash: tx.hash } });
126
104
  emitFailure(runtime, hook, err);
127
105
  throw err;
128
106
  }
@@ -140,129 +118,18 @@ function sameIds(a, b) {
140
118
  return (a.length === b.length &&
141
119
  a.every((x, i) => x.toLowerCase() === b[i].toLowerCase()));
142
120
  }
143
- const RACE_ERRORS = new Set(['IndexMismatch', 'IntentWalletMismatch']);
144
- /**
145
- * Turn a create failure into an exact report. What committed is derived from
146
- * THIS operation's own receipts, never from a later state read; when those
147
- * receipts cannot be fetched the outcome is reported as unknown so callers do
148
- * not retry a creation that may have landed.
149
- */
150
- async function createFailure(runtime, gen, wallet, index, owner, label, err) {
151
- const wrapped = (0, common_1.wrapSendError)(err);
152
- const batch = err instanceof errors_1.PushChainBatchExecutionError ? err : undefined;
153
- const confirmed = (batch?.transactionHashes ?? []);
154
- const pending = batch?.pendingTransactionHash;
155
- const receiptUnavailable = wrapped instanceof errors_2.AgenticError &&
156
- wrapped.code === errors_2.AGENTIC_ERROR_CODE.RECEIPT_UNAVAILABLE;
157
- // The index-bound deploy reverted: another creation took the slot first and
158
- // nothing from this call committed.
159
- const decodedName = wrapped
160
- .decodedError?.name;
161
- if (confirmed.length === 0 &&
162
- !pending &&
163
- decodedName &&
164
- RACE_ERRORS.has(decodedName)) {
165
- return new errors_2.AgenticError(errors_2.AGENTIC_ERROR_CODE.INDEX_RACE, `wallet slot ${index} (${wallet}) was taken by a concurrent creation; nothing was committed`, {
166
- hint: 'Retry agentic.create; it re-reads the next slot.',
167
- details: { wallet, index, committed: false },
121
+ function atomicCreateFailure(error) {
122
+ const wrapped = (0, common_1.wrapSendError)(error);
123
+ if (['IndexMismatch', 'IntentWalletMismatch'].includes(wrapped?.decodedError?.name ?? ''))
124
+ return new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.INDEX_RACE, 'the predicted wallet slot changed; atomic creation committed nothing', {
168
125
  cause: wrapped,
126
+ details: {
127
+ committed: false,
128
+ walletDeployed: false,
129
+ grantedRulesIds: [],
130
+ },
169
131
  });
170
- }
171
- if (confirmed.length === 0 && !pending && !receiptUnavailable) {
172
- // Some send paths flatten the factory revert to a generic execution
173
- // error, losing the IndexMismatch selector. If the owner's next index has
174
- // moved and immutable deployment metadata proves another label owns the
175
- // predicted slot, this call could not have deployed or granted.
176
- try {
177
- const snap = await snapshot_1.Snapshot.at(runtime.reader);
178
- const next = await (0, wallets_1.walletCount)(snap, gen, owner);
179
- if (next > BigInt(index)) {
180
- const competing = await (0, wallets_1.walletInfo)(runtime.reader, gen, wallet);
181
- // label() is mutable in v5: only the immutable deploy event proves
182
- // which creation occupied this slot. A later rename proves nothing.
183
- const logs = await (0, snapshot_1.scanLogs)(runtime.reader, {
184
- address: gen.addresses.factory,
185
- event: gen.contracts.events.walletDeployed,
186
- args: { wallet },
187
- }, gen.startBlock, snap.blockNumber);
188
- const deployed = gen.contracts
189
- .parseWalletDeployed(logs, gen.addresses.factory)
190
- .find((entry) => entry.wallet === wallet);
191
- const competingLabel = deployed?.label;
192
- if (competing.deployed &&
193
- competing.index === index &&
194
- (0, viem_1.getAddress)(competing.owner) === owner &&
195
- competingLabel !== undefined &&
196
- competingLabel !== label) {
197
- return new errors_2.AgenticError(errors_2.AGENTIC_ERROR_CODE.INDEX_RACE, 'wallet slot ' + index + ' was consumed by a concurrent deployment', {
198
- hint: 'Slot ' +
199
- index +
200
- ' belongs to "' +
201
- competingLabel +
202
- '". No wallet or rules from this create call were committed; retry agentic.create to use the next slot.',
203
- details: {
204
- wallet,
205
- index,
206
- committed: false,
207
- competingLabel,
208
- },
209
- cause: wrapped,
210
- });
211
- }
212
- }
213
- }
214
- catch {
215
- // If the owner counter/event cannot be reconciled, preserve the original
216
- // error; never infer that a retry is safe from an incomplete read.
217
- }
218
- // Nothing was confirmed (pre-broadcast failure or a reverted atomic batch).
219
- return wrapped;
220
- }
221
- let walletDeployed = 'unknown';
222
- let grantedRulesIds;
223
- let recoveryError;
224
- if (!receiptUnavailable) {
225
- try {
226
- const logs = [];
227
- for (const hash of confirmed) {
228
- const r = await runtime.reader.getTransactionReceipt({ hash });
229
- if (r.status === 'success')
230
- logs.push(...r.logs);
231
- }
232
- const deployed = gen.contracts
233
- .parseWalletDeployed(logs, gen.addresses.factory)
234
- .some((d) => d.wallet === wallet);
235
- grantedRulesIds = gen.contracts
236
- .parseRulesGranted(logs, wallet)
237
- .map((g) => g.rulesId);
238
- // A pending hash may itself be the deployment; only a confirmed deploy is certain.
239
- walletDeployed = deployed ? true : pending ? 'unknown' : false;
240
- }
241
- catch (e) {
242
- recoveryError = e instanceof Error ? e.message : String(e);
243
- }
244
- }
245
- const hint = walletDeployed === true
246
- ? `Wallet ${wallet} is deployed. Do not call create again; once any pending hash settles, finish with client.agentic.wallet('${wallet}').rules.add(<remaining rules>).`
247
- : walletDeployed === false
248
- ? 'No wallet was deployed by this call; it is safe to retry.'
249
- : 'The outcome is unknown. Do not retry create until the listed hashes are reconciled (client.agentic.list() shows deployed wallets).';
250
- return new errors_2.AgenticError(errors_2.AGENTIC_ERROR_CODE.CREATE_PARTIAL, `agentic.create did not complete: ${wrapped?.message ?? String(err)}`, {
251
- hint,
252
- details: {
253
- wallet,
254
- index,
255
- walletDeployed,
256
- grantedRulesIds,
257
- confirmedHashes: confirmed,
258
- pendingHash: pending,
259
- ...(receiptUnavailable
260
- ? { submitted: wrapped.details }
261
- : {}),
262
- ...(recoveryError ? { recoveryError } : {}),
263
- },
264
- cause: wrapped,
265
- });
132
+ return wrapped;
266
133
  }
267
134
  function emitFailure(runtime, hook, err) {
268
135
  const e = err;
@@ -13,7 +13,7 @@ const common_1 = require("./common");
13
13
  const svm_terms_1 = require("../codec/svm-terms");
14
14
  const session_1 = require("../codec/session");
15
15
  const ids_1 = require("../codec/ids");
16
- const v5_1 = require("../contracts/v5");
16
+ const v6_1 = require("../contracts/v6");
17
17
  const svm_accounts_1 = require("../codec/svm-accounts");
18
18
  const errors_1 = require("../errors");
19
19
  const prc20_metadata_1 = require("../contracts/prc20-metadata");
@@ -45,7 +45,7 @@ function session(gen, wallet, owner, input, now) {
45
45
  actions: [
46
46
  {
47
47
  target: gen.addresses.gateway,
48
- selector: v5_1.SEND_OUTBOUND_SELECTOR,
48
+ selector: v6_1.SEND_OUTBOUND_SELECTOR,
49
49
  initData: (0, session_1.encodeEnvelope)(input.chainNamespace, (0, svm_terms_1.encodeSvmTerms)(input.terms, now)),
50
50
  },
51
51
  ],
@@ -1,14 +1,20 @@
1
- import type { Address } from 'viem';
1
+ import { type Address } from 'viem';
2
2
  import type { RuleCall, ForeignChainNamespace } from '../agentic.types';
3
3
  import type { PresetCategory } from './types';
4
4
  /** Internal catalog: reviewed addresses and explicit calls only; never fetched at runtime. */
5
5
  export interface PresetChainDefinition {
6
6
  chainNamespace: ForeignChainNamespace;
7
7
  allowedCalls: readonly RuleCall[];
8
+ /** Static single-hop routers; incomplete pairs return zero-input-cap review calls. */
9
+ swapRouters?: readonly {
10
+ address: Address;
11
+ app: string;
12
+ }[];
8
13
  /** Exact spenders that need an approval for each non-native supplied asset. */
9
14
  approvals?: readonly {
10
15
  spender: Address;
11
16
  app: string;
17
+ token?: Address;
12
18
  }[];
13
19
  maxGasPerCall?: bigint;
14
20
  }
@@ -17,5 +23,4 @@ export interface PresetDefinition {
17
23
  name: string;
18
24
  chains: readonly PresetChainDefinition[];
19
25
  }
20
- /** No approved app/address catalog yet. Empty categories must be hidden by UIs. */
21
26
  export declare const PRESET_CATALOG: readonly PresetDefinition[];
@@ -1,10 +1,307 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PRESET_CATALOG = void 0;
4
- /** No approved app/address catalog yet. Empty categories must be hidden by UIs. */
4
+ const viem_1 = require("viem");
5
+ /** Mainnet and testnet templates from the October 15 Notion export and protocol sources.
6
+ * Read-only deployment/code evidence and exclusions: plan/agw/research/preset-catalog-2026-10-15/.
7
+ * Mainnet entries are templates only; no mainnet deployment or execution guarantee.
8
+ */
9
+ const address = (value) => (0, viem_1.getAddress)(value.toLowerCase());
10
+ const wallet = 'agentic:wallet';
11
+ const aave = (pool) => [
12
+ ['supply(address,uint256,address,uint16)', 2, 'Supply'],
13
+ ['withdraw(address,uint256,address)', 2, 'Withdraw'],
14
+ ['borrow(address,uint256,uint256,uint16,address)', 4, 'Borrow'],
15
+ ['repay(address,uint256,uint256,address)', 3, 'Repay'],
16
+ ].map(([selector, arg, label]) => ({
17
+ target: pool,
18
+ selector: selector,
19
+ pins: [{ arg: arg, expected: wallet }],
20
+ app: 'Aave V3',
21
+ label: label,
22
+ }));
23
+ const market = (target, app) => [
24
+ 'mint(uint256)',
25
+ 'redeem(uint256)',
26
+ 'redeemUnderlying(uint256)',
27
+ 'borrow(uint256)',
28
+ 'repayBorrow(uint256)',
29
+ ].map((selector) => ({
30
+ target,
31
+ selector: selector,
32
+ app,
33
+ label: selector.split('(')[0],
34
+ }));
35
+ const sepoliaPool = address('0x6Ae43d3271ff6888e7Fc43Fd7321a503ff738951');
36
+ const basePool = address('0x8bAB6d1b75f19e9eD9fCe8b9BD338844fF79aE27');
37
+ const arbitrumPool = address('0xBfC91D59fdAA134A4ED45f7B584cAf96D7792Eff');
38
+ const moonUSDBC = address('0x876852425331a113d8E432eFFB3aC5BEf38f033a');
39
+ const moonWETH = address('0x2F39a349A79492a70E152760ce7123A1933eCf28');
40
+ const venusUSDT = address('0xb7526572FFE56AB9D7489838Bf2E18e3323b441A');
41
+ const venusUSDC = address('0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7');
42
+ const eigen = address('0x2E3D6c0744b10eb0A4e6F679F71554a39Ec47a5D');
43
+ const stETH = address('0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84');
44
+ const wstETH = address('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0');
45
+ const lidoQueue = address('0x889edC2eDab5f40e902b864aD4d7AdE8E412F9B1');
46
+ const mainnetMarkets = (chain) => {
47
+ const entries = chain === 'eip155:8453'
48
+ ? [
49
+ [
50
+ '0xEdc817A28E8B93B03976FBd4a3dDBc9f7D176c22',
51
+ 'Moonwell mUSDC',
52
+ '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
53
+ ],
54
+ [
55
+ '0x628ff693426583D9a7FB391E54366292F509D457',
56
+ 'Moonwell mWETH',
57
+ '0x4200000000000000000000000000000000000006',
58
+ ],
59
+ ]
60
+ : chain === 'eip155:56'
61
+ ? [
62
+ [
63
+ '0xfD5840Cd36d94D7229439859C0112a4185BC0255',
64
+ 'Venus vUSDT',
65
+ '0x55d398326f99059fF775485246999027B3197955',
66
+ ],
67
+ [
68
+ '0xecA88125a5ADbe82614ffC12D0DB554E2e2867C8',
69
+ 'Venus vUSDC',
70
+ '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d',
71
+ ],
72
+ ]
73
+ : [];
74
+ const controller = chain === 'eip155:8453'
75
+ ? '0xfBb21d0380beE3312B33c4353c8936a0F13EF26C'
76
+ : '0xfD36E2c2a6789Db23113685031d7F16329158384';
77
+ return {
78
+ allowedCalls: [
79
+ ...entries.flatMap(([target, app]) => market(address(target), app)),
80
+ ...(entries.length
81
+ ? [
82
+ {
83
+ target: address(controller),
84
+ selector: 'enterMarkets(address[])',
85
+ app: chain === 'eip155:8453' ? 'Moonwell' : 'Venus',
86
+ label: 'Enter markets',
87
+ },
88
+ ]
89
+ : []),
90
+ ],
91
+ approvals: entries.map(([spender, app, token]) => ({
92
+ spender: address(spender),
93
+ app,
94
+ token: address(token),
95
+ })),
96
+ };
97
+ };
5
98
  exports.PRESET_CATALOG = [
6
- { constant: 'DEXES', name: 'Popular DEXes', chains: [] },
7
- { constant: 'LENDING', name: 'Lending', chains: [] },
99
+ {
100
+ constant: 'DEXES',
101
+ name: 'Popular DEXes',
102
+ chains: [
103
+ ['eip155:1', '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45', 'Uniswap V3'],
104
+ [
105
+ 'eip155:8453',
106
+ '0x2626664c2603336E57B271c5C0b26F421741e481',
107
+ 'Uniswap V3',
108
+ ],
109
+ [
110
+ 'eip155:42161',
111
+ '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45',
112
+ 'Uniswap V3',
113
+ ],
114
+ [
115
+ 'eip155:56',
116
+ '0x13f4EA83D0bd40E75C8222255bc855a974568Dd4',
117
+ 'PancakeSwap V3',
118
+ ],
119
+ [
120
+ 'eip155:11155111',
121
+ '0x3bFA4769FB09eefC5a80d6E87c3B9C650f7Ae48E',
122
+ 'Uniswap V3',
123
+ ],
124
+ [
125
+ 'eip155:84532',
126
+ '0x94cC0AaC535CCDB3C01d6787D6413C739ae12bc4',
127
+ 'Uniswap V3',
128
+ ],
129
+ [
130
+ 'eip155:421614',
131
+ '0x101F443B4d1b059569D643917553c771E1b9663E',
132
+ 'Uniswap V3',
133
+ ],
134
+ [
135
+ 'eip155:97',
136
+ '0x9a489505a00cE272eAa5e07Dba6491314CaE3796',
137
+ 'PancakeSwap V3',
138
+ ],
139
+ ].map(([chain, router, app]) => ({
140
+ chainNamespace: chain,
141
+ allowedCalls: [],
142
+ swapRouters: [{ address: address(router), app }],
143
+ approvals: [{ spender: address(router), app }],
144
+ })),
145
+ },
146
+ {
147
+ constant: 'LENDING',
148
+ name: 'Lending',
149
+ chains: [
150
+ ...[
151
+ ['eip155:1', '0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2'],
152
+ ['eip155:8453', '0xA238Dd80C259a72e81d7e4664a9801593F98d1c5'],
153
+ ['eip155:42161', '0x794a61358D6845594F94dc1DB02A252b5b4814aD'],
154
+ ['eip155:56', '0x6807dc923806fE8Fd134338EABCA509979a7e0cB'],
155
+ ].map(([chainNamespace, pool]) => ({
156
+ chainNamespace,
157
+ allowedCalls: [
158
+ ...aave(address(pool)),
159
+ ...mainnetMarkets(chainNamespace).allowedCalls,
160
+ ],
161
+ approvals: [
162
+ { spender: address(pool), app: 'Aave V3' },
163
+ ...(mainnetMarkets(chainNamespace).approvals ?? []),
164
+ ],
165
+ })),
166
+ {
167
+ chainNamespace: 'eip155:11155111',
168
+ allowedCalls: aave(sepoliaPool),
169
+ approvals: [{ spender: sepoliaPool, app: 'Aave V3' }],
170
+ },
171
+ {
172
+ chainNamespace: 'eip155:421614',
173
+ allowedCalls: aave(arbitrumPool),
174
+ approvals: [{ spender: arbitrumPool, app: 'Aave V3' }],
175
+ },
176
+ {
177
+ chainNamespace: 'eip155:84532',
178
+ allowedCalls: [
179
+ ...aave(basePool),
180
+ ...market(moonUSDBC, 'Moonwell mUSDbC'),
181
+ ...market(moonWETH, 'Moonwell mWETH'),
182
+ {
183
+ target: address('0xC72ba45f2Ae134F21DAEb2b7B5fd5De0064Ee9bB'),
184
+ selector: 'enterMarkets(address[])',
185
+ app: 'Moonwell',
186
+ label: 'Enter markets',
187
+ },
188
+ ],
189
+ approvals: [
190
+ { spender: basePool, app: 'Aave V3' },
191
+ {
192
+ spender: moonUSDBC,
193
+ app: 'Moonwell mUSDbC',
194
+ token: address('0x4616975f7E6045FD9737e95bC527e9e14c727BD2'),
195
+ },
196
+ {
197
+ spender: moonWETH,
198
+ app: 'Moonwell mWETH',
199
+ token: address('0x663A6F02d547dFd639BF689FED298712f2FB69Fb'),
200
+ },
201
+ ],
202
+ },
203
+ {
204
+ chainNamespace: 'eip155:97',
205
+ allowedCalls: [
206
+ ...market(venusUSDT, 'Venus vUSDT'),
207
+ ...market(venusUSDC, 'Venus vUSDC'),
208
+ {
209
+ target: address('0x94d1820b2D1c7c7452A163983Dc888CEC546b77D'),
210
+ selector: 'enterMarkets(address[])',
211
+ app: 'Venus',
212
+ label: 'Enter markets',
213
+ },
214
+ ],
215
+ approvals: [
216
+ {
217
+ spender: venusUSDT,
218
+ app: 'Venus vUSDT',
219
+ token: address('0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c'),
220
+ },
221
+ {
222
+ spender: venusUSDC,
223
+ app: 'Venus vUSDC',
224
+ token: address('0x16227D60f7a0e586C66B005219dfc887D13C9531'),
225
+ },
226
+ ],
227
+ },
228
+ ],
229
+ },
230
+ {
231
+ constant: 'STAKING',
232
+ name: 'Staking',
233
+ chains: [
234
+ {
235
+ chainNamespace: 'eip155:1',
236
+ allowedCalls: [
237
+ {
238
+ target: stETH,
239
+ selector: 'submit(address)',
240
+ maxValue: BigInt(0),
241
+ app: 'Lido',
242
+ label: 'Stake ETH (set an explicit value cap)',
243
+ },
244
+ {
245
+ target: wstETH,
246
+ selector: 'wrap(uint256)',
247
+ app: 'Lido wstETH',
248
+ label: 'Wrap stETH',
249
+ },
250
+ {
251
+ target: wstETH,
252
+ selector: 'unwrap(uint256)',
253
+ app: 'Lido wstETH',
254
+ label: 'Unwrap wstETH',
255
+ },
256
+ {
257
+ target: lidoQueue,
258
+ selector: 'requestWithdrawals(uint256[],address)',
259
+ pins: [{ arg: 1, expected: wallet }],
260
+ app: 'Lido withdrawal queue',
261
+ label: 'Request withdrawal',
262
+ },
263
+ {
264
+ target: lidoQueue,
265
+ selector: 'claimWithdrawals(uint256[],uint256[])',
266
+ app: 'Lido withdrawal queue',
267
+ label: 'Claim finalized withdrawals',
268
+ },
269
+ {
270
+ target: lidoQueue,
271
+ selector: 'claimWithdrawal(uint256)',
272
+ app: 'Lido withdrawal queue',
273
+ label: 'Claim finalized withdrawal',
274
+ },
275
+ {
276
+ target: address('0x858646372CC42E1A627fcE94aa7A7033e7CF075A'),
277
+ selector: 'depositIntoStrategy(address,address,uint256)',
278
+ app: 'EigenLayer',
279
+ label: 'Deposit into strategy (withdrawals not included)',
280
+ },
281
+ ],
282
+ approvals: [
283
+ { spender: wstETH, token: stETH, app: 'Lido wstETH' },
284
+ { spender: lidoQueue, token: stETH, app: 'Lido withdrawal queue' },
285
+ {
286
+ spender: address('0x858646372CC42E1A627fcE94aa7A7033e7CF075A'),
287
+ app: 'EigenLayer',
288
+ },
289
+ ],
290
+ },
291
+ {
292
+ chainNamespace: 'eip155:11155111',
293
+ allowedCalls: [
294
+ {
295
+ target: eigen,
296
+ selector: 'depositIntoStrategy(address,address,uint256)',
297
+ app: 'EigenLayer',
298
+ label: 'Deposit into strategy (withdrawals not included)',
299
+ },
300
+ ],
301
+ approvals: [{ spender: eigen, app: 'EigenLayer' }],
302
+ },
303
+ ],
304
+ },
8
305
  { constant: 'PREDICTION', name: 'Prediction markets', chains: [] },
9
306
  ];
10
307
  //# sourceMappingURL=catalog.js.map