@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.
- package/AGW.md +49 -17
- package/CHANGELOG.md +10 -0
- package/package.json +1 -1
- package/src/lib/agentic/agentic.types.d.ts +8 -3
- package/src/lib/agentic/capabilities.d.ts +1 -1
- package/src/lib/agentic/capabilities.js +1 -1
- package/src/lib/agentic/codec/abi-layout.d.ts +5 -0
- package/src/lib/agentic/codec/abi-layout.js +50 -3
- package/src/lib/agentic/codec/defaults.d.ts +2 -2
- package/src/lib/agentic/codec/defaults.js +2 -2
- package/src/lib/agentic/codec/ids.d.ts +1 -1
- package/src/lib/agentic/codec/ids.js +1 -1
- package/src/lib/agentic/codec/native.d.ts +4 -6
- package/src/lib/agentic/codec/native.js +27 -14
- package/src/lib/agentic/codec/pins.d.ts +20 -0
- package/src/lib/agentic/codec/pins.js +29 -0
- package/src/lib/agentic/codec/rules.d.ts +1 -1
- package/src/lib/agentic/codec/rules.js +3 -3
- package/src/lib/agentic/codec/session.d.ts +2 -2
- package/src/lib/agentic/codec/session.js +3 -3
- package/src/lib/agentic/codec/svm-terms.d.ts +1 -1
- package/src/lib/agentic/codec/svm-terms.js +7 -3
- package/src/lib/agentic/codec/universal-terms.d.ts +15 -0
- package/src/lib/agentic/codec/universal-terms.js +2 -0
- package/src/lib/agentic/codec/universal.js +22 -6
- package/src/lib/agentic/constants.d.ts +1 -0
- package/src/lib/agentic/constants.js +1 -0
- package/src/lib/agentic/contracts/abi/{v5 → v6}/agent-validator.js +1 -1
- package/src/lib/agentic/contracts/abi/{v5 → v6}/agw-factory.d.ts +299 -0
- package/src/lib/agentic/contracts/abi/{v5 → v6}/agw-factory.js +393 -2
- package/src/lib/agentic/contracts/abi/{v5 → v6}/agw.d.ts +96 -1
- package/src/lib/agentic/contracts/abi/{v5 → v6}/agw.js +128 -3
- package/src/lib/agentic/contracts/abi/{v5 → v6}/index.d.ts +1 -1
- package/src/lib/agentic/contracts/abi/{v5 → v6}/index.js +3 -3
- package/src/lib/agentic/contracts/abi/{v5 → v6}/smart-session.js +1 -1
- package/src/lib/agentic/contracts/abi/{v5 → v6}/universal-rules-policy.d.ts +329 -308
- package/src/lib/agentic/contracts/abi/{v5 → v6}/universal-rules-policy.js +396 -369
- package/src/lib/agentic/contracts/donut-v6.d.ts +11 -0
- package/src/lib/agentic/contracts/donut-v6.js +15 -0
- package/src/lib/agentic/contracts/{v5.d.ts → v6.d.ts} +800 -384
- package/src/lib/agentic/contracts/{v5.js → v6.js} +60 -33
- package/src/lib/agentic/deployments.d.ts +5 -5
- package/src/lib/agentic/deployments.js +19 -19
- package/src/lib/agentic/errors.d.ts +1 -7
- package/src/lib/agentic/errors.js +1 -9
- package/src/lib/agentic/execution/outbound.d.ts +4 -4
- package/src/lib/agentic/execution/outbound.js +5 -5
- package/src/lib/agentic/execution/send.js +3 -11
- package/src/lib/agentic/execution/svm-outbound.d.ts +1 -1
- package/src/lib/agentic/execution/svm-payload.js +1 -1
- package/src/lib/agentic/execution/svm-public.js +1 -7
- package/src/lib/agentic/execution/svm-send.d.ts +1 -1
- package/src/lib/agentic/execution/svm-send.js +0 -3
- package/src/lib/agentic/index.d.ts +1 -1
- package/src/lib/agentic/management/common.js +7 -5
- package/src/lib/agentic/management/create.d.ts +1 -13
- package/src/lib/agentic/management/create.js +24 -157
- package/src/lib/agentic/management/svm.js +2 -2
- package/src/lib/agentic/presets/catalog.d.ts +7 -2
- package/src/lib/agentic/presets/catalog.js +300 -3
- package/src/lib/agentic/presets/index.js +93 -18
- package/src/lib/agentic/presets/types.d.ts +5 -1
- package/src/lib/agentic/public-rule.d.ts +2 -2
- package/src/lib/agentic/public-rule.js +24 -40
- package/src/lib/agentic/reads/rules.js +27 -11
- package/src/lib/agentic/reads/svm.d.ts +1 -1
- package/src/lib/agentic/reads/svm.js +2 -2
- package/src/lib/agentic/response.js +7 -7
- package/src/lib/agentic/revert.js +5 -5
- package/src/lib/agentic/runtime.js +12 -3
- package/src/lib/agentic/utils.js +1 -1
- package/src/lib/constants/index.d.ts +1 -0
- package/src/lib/index.d.ts +1 -1
- package/src/lib/push-chain/push-chain.d.ts +1 -0
- package/src/lib/agentic/contracts/donut-v5.d.ts +0 -11
- package/src/lib/agentic/contracts/donut-v5.js +0 -15
- /package/src/lib/agentic/contracts/abi/{v5 → v6}/agent-validator.d.ts +0 -0
- /package/src/lib/agentic/contracts/abi/{v5 → v6}/smart-session.d.ts +0 -0
|
@@ -20,12 +20,19 @@ function copyCall(call) {
|
|
|
20
20
|
...call,
|
|
21
21
|
...(call.pins
|
|
22
22
|
? {
|
|
23
|
-
pins: call.pins.map((
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
pins: call.pins.map((pin) => {
|
|
24
|
+
if (pin.account !== undefined)
|
|
25
|
+
return {
|
|
26
|
+
...pin,
|
|
27
|
+
...(pin.token && typeof pin.token === 'object'
|
|
28
|
+
? { token: { ...pin.token } }
|
|
29
|
+
: {}),
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
...pin,
|
|
33
|
+
arg: typeof pin.arg === 'number' ? pin.arg : [...pin.arg],
|
|
34
|
+
};
|
|
35
|
+
}),
|
|
29
36
|
}
|
|
30
37
|
: {}),
|
|
31
38
|
};
|
|
@@ -45,6 +52,7 @@ function buildPresetApi(catalog) {
|
|
|
45
52
|
...c,
|
|
46
53
|
allowedCalls: c.allowedCalls.map(copyCall),
|
|
47
54
|
approvals: c.approvals?.map((a) => ({ ...a })),
|
|
55
|
+
swapRouters: c.swapRouters?.map((r) => ({ ...r })),
|
|
48
56
|
})),
|
|
49
57
|
}));
|
|
50
58
|
if (new Set(entries.map((e) => e.constant)).size !== entries.length ||
|
|
@@ -78,6 +86,8 @@ function buildPresetApi(catalog) {
|
|
|
78
86
|
options.validUntil <= Math.floor(Date.now() / 1000) ||
|
|
79
87
|
options.validUntil >= 2 ** 48))
|
|
80
88
|
throw invalid('preset validUntil must be a future uint48 timestamp');
|
|
89
|
+
if (options.maxGasPerCall !== undefined)
|
|
90
|
+
cap(options.maxGasPerCall, 'maxGasPerCall');
|
|
81
91
|
if (options.assets !== undefined && !Array.isArray(options.assets))
|
|
82
92
|
throw invalid('preset assets must be an array');
|
|
83
93
|
const chains = options.chainNamespace === undefined
|
|
@@ -117,7 +127,65 @@ function buildPresetApi(catalog) {
|
|
|
117
127
|
}
|
|
118
128
|
const rules = chains.map((chain) => {
|
|
119
129
|
const calls = chain.allowedCalls.map(copyCall);
|
|
120
|
-
|
|
130
|
+
if (chain.swapRouters?.length) {
|
|
131
|
+
const tokens = assets.get(chain.chainNamespace) ?? [];
|
|
132
|
+
if (tokens.some((a) => tokenAddress(a.token) === viem_1.zeroAddress ||
|
|
133
|
+
(typeof a.token !== 'string' && a.token.mechanism === 'native')))
|
|
134
|
+
throw invalid('DEX token pins require explicit ERC20 addresses; use wrapped-native tokens instead of the native marker');
|
|
135
|
+
// Keep discovery useful before a swap pair is selected. These review
|
|
136
|
+
// calls cannot spend input tokens: the amount maximum is explicitly zero.
|
|
137
|
+
// Re-run get with both tokens to generate the executable pair pins.
|
|
138
|
+
if (tokens.length < 2)
|
|
139
|
+
for (const router of chain.swapRouters)
|
|
140
|
+
for (const exactInput of [true, false])
|
|
141
|
+
calls.push({
|
|
142
|
+
target: router.address,
|
|
143
|
+
selector: `${exactInput ? 'exactInputSingle' : 'exactOutputSingle'}((address,address,uint24,address,uint256,uint256,uint160))`,
|
|
144
|
+
pins: [
|
|
145
|
+
...(tokens.length
|
|
146
|
+
? [
|
|
147
|
+
{
|
|
148
|
+
arg: [0, 0],
|
|
149
|
+
expected: (0, viem_1.getAddress)(tokenAddress(tokens[0].token)),
|
|
150
|
+
},
|
|
151
|
+
]
|
|
152
|
+
: []),
|
|
153
|
+
{ arg: [0, 3], expected: 'agentic:wallet' },
|
|
154
|
+
{ arg: [0, exactInput ? 4 : 5], max: BigInt(0) },
|
|
155
|
+
],
|
|
156
|
+
app: router.app,
|
|
157
|
+
label: `${exactInput ? 'Swap exact input' : 'Swap exact output'} (select two tokens to enable)`,
|
|
158
|
+
});
|
|
159
|
+
for (const router of chain.swapRouters)
|
|
160
|
+
for (const input of tokens)
|
|
161
|
+
for (const output of tokens) {
|
|
162
|
+
if (tokenAddress(input.token).toLowerCase() ===
|
|
163
|
+
tokenAddress(output.token).toLowerCase())
|
|
164
|
+
continue;
|
|
165
|
+
for (const exactInput of [true, false])
|
|
166
|
+
calls.push({
|
|
167
|
+
target: router.address,
|
|
168
|
+
selector: `${exactInput ? 'exactInputSingle' : 'exactOutputSingle'}((address,address,uint24,address,uint256,uint256,uint160))`,
|
|
169
|
+
pins: [
|
|
170
|
+
{
|
|
171
|
+
arg: [0, 0],
|
|
172
|
+
expected: (0, viem_1.getAddress)(tokenAddress(input.token)),
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
arg: [0, 1],
|
|
176
|
+
expected: (0, viem_1.getAddress)(tokenAddress(output.token)),
|
|
177
|
+
},
|
|
178
|
+
{ arg: [0, 3], expected: 'agentic:wallet' },
|
|
179
|
+
{ arg: [0, exactInput ? 4 : 5], max: input.maxPerCall },
|
|
180
|
+
],
|
|
181
|
+
app: router.app,
|
|
182
|
+
label: exactInput
|
|
183
|
+
? 'Swap exact input'
|
|
184
|
+
: 'Swap exact output',
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const approvals = new Set();
|
|
121
189
|
for (const asset of assets.get(chain.chainNamespace) ?? []) {
|
|
122
190
|
const token = tokenAddress(asset.token);
|
|
123
191
|
if (token === viem_1.zeroAddress ||
|
|
@@ -127,14 +195,15 @@ function buildPresetApi(catalog) {
|
|
|
127
195
|
for (const approval of chain.approvals ?? []) {
|
|
128
196
|
if (!chain.chainNamespace.startsWith('eip155:'))
|
|
129
197
|
throw (0, errors_1.capabilityUnavailable)('presetApproval', 'Solana approvals require a separately reviewed instruction template');
|
|
198
|
+
if (approval.token &&
|
|
199
|
+
(0, viem_1.getAddress)(token) !== (0, viem_1.getAddress)(approval.token))
|
|
200
|
+
continue;
|
|
130
201
|
const spender = (0, viem_1.getAddress)(approval.spender);
|
|
131
202
|
const target = (0, viem_1.getAddress)(token);
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
134
|
-
throw (0, errors_1.capabilityUnavailable)('presetApproval', 'multiple spenders for one token need a reviewed policy representation; no unrestricted approval is generated');
|
|
135
|
-
if (previous)
|
|
203
|
+
const approvalKey = `${target}:${spender}`;
|
|
204
|
+
if (approvals.has(approvalKey))
|
|
136
205
|
continue;
|
|
137
|
-
approvals.
|
|
206
|
+
approvals.add(approvalKey);
|
|
138
207
|
calls.push({
|
|
139
208
|
target,
|
|
140
209
|
selector: 'approve(address,uint256)',
|
|
@@ -149,7 +218,9 @@ function buildPresetApi(catalog) {
|
|
|
149
218
|
}
|
|
150
219
|
if (!calls.length || calls.length > 32)
|
|
151
220
|
throw (0, errors_1.capabilityUnavailable)('presetCalls', 'preset must contain 1..32 allowed calls including approvals');
|
|
152
|
-
|
|
221
|
+
if (calls.reduce((n, c) => n + (c.pins?.length ?? 0), 0) > 32)
|
|
222
|
+
throw (0, errors_1.capabilityUnavailable)('presetPins', 'preset expansion exceeds 32 pins; reduce the token list or split rules across wallets');
|
|
223
|
+
const pairs = new Map();
|
|
153
224
|
for (const call of calls) {
|
|
154
225
|
if (!/^[A-Za-z_$][\w$]*\(.*\)$/.test(call.selector))
|
|
155
226
|
throw invalid('preset selectors must be full signatures');
|
|
@@ -159,9 +230,11 @@ function buildPresetApi(catalog) {
|
|
|
159
230
|
const pair = `${chain.chainNamespace.startsWith('eip155:')
|
|
160
231
|
? call.target.toLowerCase()
|
|
161
232
|
: call.target}:${selector}`;
|
|
162
|
-
if (pairs.has(pair))
|
|
163
|
-
throw (0, errors_1.capabilityUnavailable)('presetCalls', '
|
|
164
|
-
pairs.
|
|
233
|
+
if (pairs.has(pair) && !chain.chainNamespace.startsWith('eip155:'))
|
|
234
|
+
throw (0, errors_1.capabilityUnavailable)('presetCalls', 'Solana does not support alternative entries for one program/instruction');
|
|
235
|
+
if (pairs.has(pair) && (!call.pins?.length || !pairs.get(pair)))
|
|
236
|
+
throw (0, errors_1.capabilityUnavailable)('presetCalls', 'an unpinned alternative would bypass restrictions for this target/function');
|
|
237
|
+
pairs.set(pair, !!call.pins?.length);
|
|
165
238
|
}
|
|
166
239
|
return {
|
|
167
240
|
chainNamespace: chain.chainNamespace,
|
|
@@ -175,8 +248,10 @@ function buildPresetApi(catalog) {
|
|
|
175
248
|
...(options.assets !== undefined
|
|
176
249
|
? { assets: assets.get(chain.chainNamespace) ?? [] }
|
|
177
250
|
: {}),
|
|
178
|
-
...(chain.maxGasPerCall !== undefined
|
|
179
|
-
? {
|
|
251
|
+
...((options.maxGasPerCall ?? chain.maxGasPerCall) !== undefined
|
|
252
|
+
? {
|
|
253
|
+
maxGasPerCall: cap(options.maxGasPerCall ?? chain.maxGasPerCall, 'maxGasPerCall'),
|
|
254
|
+
}
|
|
180
255
|
: {}),
|
|
181
256
|
};
|
|
182
257
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Address } from 'viem';
|
|
2
2
|
import type { Rule, RuleAsset, ForeignChainNamespace } from '../agentic.types';
|
|
3
|
-
export type PresetCategory = 'DEXES' | 'LENDING' | 'PREDICTION';
|
|
3
|
+
export type PresetCategory = 'DEXES' | 'LENDING' | 'STAKING' | 'PREDICTION';
|
|
4
4
|
export interface Preset {
|
|
5
5
|
type: 'CATEGORY';
|
|
6
6
|
constant: PresetCategory;
|
|
@@ -20,9 +20,13 @@ export interface PresetAsset {
|
|
|
20
20
|
maxTotal?: bigint;
|
|
21
21
|
}
|
|
22
22
|
export interface PresetOptions {
|
|
23
|
+
/** Explicit Push-PC gas budget per outbound; omitted = zero. */
|
|
24
|
+
maxGasPerCall?: bigint;
|
|
23
25
|
chainNamespace?: ForeignChainNamespace;
|
|
24
26
|
agent?: Address;
|
|
25
27
|
validUntil?: number;
|
|
28
|
+
/** DEX swaps with fewer than two tokens are zero-input-cap review templates.
|
|
29
|
+
* Call get again with a complete pair to generate token pins and amount limits. */
|
|
26
30
|
assets?: PresetAsset[];
|
|
27
31
|
}
|
|
28
32
|
export interface ReadyPresetOptions extends PresetOptions {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type Address } from 'viem';
|
|
2
|
-
import type { Rule, RuleInput, InternalRule } from './agentic.types';
|
|
2
|
+
import type { Rule, RuleInput, InternalRule, ArgumentPath } from './agentic.types';
|
|
3
3
|
import type { AgenticRuntime } from './runtime';
|
|
4
4
|
export declare const WALLET: "agentic:wallet";
|
|
5
5
|
/** Mark authored inputs for normalization after the wallet address is fixed. */
|
|
6
6
|
export declare function publicRules(rules: readonly RuleInput[]): InternalRule[];
|
|
7
7
|
export declare function isPublicRule(rule: InternalRule): boolean;
|
|
8
|
-
export declare function evmPinOffset(selector: Rule['allowedCalls'][number]['selector'], arg:
|
|
8
|
+
export declare function evmPinOffset(selector: Rule['allowedCalls'][number]['selector'], arg: ArgumentPath): number;
|
|
9
9
|
export declare function normalizePublicRule(input: InternalRule, wallet: Address, runtime: AgenticRuntime): Promise<InternalRule>;
|
|
@@ -28,6 +28,7 @@ exports.publicRules = publicRules;
|
|
|
28
28
|
exports.isPublicRule = isPublicRule;
|
|
29
29
|
exports.evmPinOffset = evmPinOffset;
|
|
30
30
|
exports.normalizePublicRule = normalizePublicRule;
|
|
31
|
+
const pins_1 = require("./codec/pins");
|
|
31
32
|
const web3_js_1 = require("@solana/web3.js");
|
|
32
33
|
const viem_1 = require("viem");
|
|
33
34
|
const errors_1 = require("./errors");
|
|
@@ -64,21 +65,22 @@ function uint(value, name) {
|
|
|
64
65
|
return value;
|
|
65
66
|
}
|
|
66
67
|
function evmPinOffset(selector, arg) {
|
|
67
|
-
if (!Number.isInteger(arg) || arg < 0 || 4 + 32 * arg + 32 > 65535)
|
|
68
|
-
throw invalid('pin arg is outside the supported calldata range');
|
|
69
68
|
const parsed = (0, selectors_1.parseSelector)(selector);
|
|
70
69
|
if (parsed.valueOnly)
|
|
71
70
|
throw invalid('value-only calls cannot have argument pins');
|
|
72
|
-
if (
|
|
73
|
-
return
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
if (parsed.inputs)
|
|
72
|
+
return (0, abi_layout_1.argumentLocation)(parsed.inputs, arg, 'pin').offset;
|
|
73
|
+
if (typeof arg !== 'number' ||
|
|
74
|
+
!Number.isSafeInteger(arg) ||
|
|
75
|
+
arg < 0 ||
|
|
76
|
+
4 + 32 * arg + 32 > 65535)
|
|
77
|
+
throw invalid('a raw selector needs a valid scalar ABI word index');
|
|
78
|
+
return 4 + 32 * arg;
|
|
77
79
|
}
|
|
78
80
|
function expectedWord(selector, arg, value) {
|
|
79
81
|
const parsed = (0, selectors_1.parseSelector)(selector);
|
|
80
82
|
if (parsed.inputs)
|
|
81
|
-
return (0, abi_layout_1.encodeArgWord)(parsed.inputs
|
|
83
|
+
return (0, abi_layout_1.encodeArgWord)((0, abi_layout_1.argumentLocation)(parsed.inputs, arg, 'pin').param, value, 'pin');
|
|
82
84
|
if (typeof value === 'bigint')
|
|
83
85
|
return (0, viem_1.numberToHex)(uint(value, 'pin.expected'), { size: 32 });
|
|
84
86
|
if (typeof value === 'string' && (0, viem_1.isAddress)(value, { strict: false }))
|
|
@@ -151,19 +153,17 @@ async function normalizePublicRule(input, wallet, runtime) {
|
|
|
151
153
|
if (r.chainNamespace === runtime.pushChainNamespace)
|
|
152
154
|
throw invalid('omit chainNamespace for Push rules');
|
|
153
155
|
if (native && r.allowedCalls.length > 8)
|
|
154
|
-
throw (0, errors_1.capabilityUnavailable)('nativeActions', 'the deployed
|
|
156
|
+
throw (0, errors_1.capabilityUnavailable)('nativeActions', 'the deployed v6 wallet permits at most eight native actions');
|
|
155
157
|
if (native && (r.assets !== undefined || r.maxGasPerCall !== undefined))
|
|
156
158
|
throw invalid('native rules do not carry assets or maxGasPerCall');
|
|
157
159
|
const own = native
|
|
158
160
|
? wallet
|
|
159
|
-
: (await runtime.resolveCEA(wallet, r.chainNamespace)).cea;
|
|
161
|
+
: (0, viem_1.getAddress)((await runtime.resolveCEA(wallet, r.chainNamespace)).cea);
|
|
160
162
|
const nativeActions = [];
|
|
161
163
|
const calls = [];
|
|
162
164
|
for (const call of r.allowedCalls) {
|
|
163
165
|
const pins = call.pins ?? [];
|
|
164
|
-
|
|
165
|
-
const eq = [];
|
|
166
|
-
let beneficiaryOffset;
|
|
166
|
+
const wirePins = [];
|
|
167
167
|
const occupied = new Set();
|
|
168
168
|
for (const pin of pins) {
|
|
169
169
|
if ('account' in pin)
|
|
@@ -172,44 +172,28 @@ async function normalizePublicRule(input, wallet, runtime) {
|
|
|
172
172
|
if (occupied.has(offset))
|
|
173
173
|
throw invalid('duplicate pin argument');
|
|
174
174
|
occupied.add(offset);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
else if ('max' in pin) {
|
|
183
|
-
if (amount)
|
|
184
|
-
throw (0, errors_1.capabilityUnavailable)('nativeMaxPins', 'v5 supports one max pin per native call');
|
|
185
|
-
amount = {
|
|
186
|
-
offset,
|
|
187
|
-
maxPerCall: uint(pin.max, 'pin.max'),
|
|
188
|
-
maxTotal: defaults_1.UINT256_MAX,
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
eq.push({
|
|
193
|
-
offset,
|
|
194
|
-
expected: expectedWord(call.selector, pin.arg, pin.expected === exports.WALLET ? own : pin.expected),
|
|
195
|
-
});
|
|
196
|
-
}
|
|
175
|
+
wirePins.push({
|
|
176
|
+
offset,
|
|
177
|
+
op: 'max' in pin ? 1 : 0,
|
|
178
|
+
value: 'max' in pin
|
|
179
|
+
? (0, viem_1.numberToHex)(uint(pin.max, 'pin.max'), { size: 32 })
|
|
180
|
+
: expectedWord(call.selector, pin.arg, pin.expected === exports.WALLET ? own : pin.expected),
|
|
181
|
+
});
|
|
197
182
|
}
|
|
198
183
|
if (native)
|
|
199
184
|
nativeActions.push({
|
|
200
185
|
target: (0, viem_1.getAddress)(call.target),
|
|
201
186
|
selector: call.selector,
|
|
202
|
-
|
|
203
|
-
amount,
|
|
187
|
+
wirePins,
|
|
204
188
|
maxValuePerCall: call.maxValue ?? BigInt(0),
|
|
205
189
|
maxValueTotal: defaults_1.UINT256_MAX,
|
|
206
|
-
maxCalls:
|
|
190
|
+
maxCalls: pins_1.UNLIMITED_CALLS,
|
|
207
191
|
});
|
|
208
192
|
else
|
|
209
193
|
calls.push({
|
|
210
194
|
target: (0, viem_1.getAddress)(call.target),
|
|
211
195
|
selector: call.selector,
|
|
212
|
-
|
|
196
|
+
pins: wirePins,
|
|
213
197
|
maxValue: call.maxValue ?? BigInt(0),
|
|
214
198
|
});
|
|
215
199
|
}
|
|
@@ -302,7 +286,7 @@ function svmRule(rule, cea) {
|
|
|
302
286
|
],
|
|
303
287
|
};
|
|
304
288
|
return {
|
|
305
|
-
maxAccounts:
|
|
289
|
+
maxAccounts: pins_1.ANY_ACCOUNT_COUNT,
|
|
306
290
|
program: call.target,
|
|
307
291
|
instruction: { idl, name },
|
|
308
292
|
accounts: accounts.map((p) => ({
|
|
@@ -171,9 +171,23 @@ async function decodeActiveRule(snap, gen, wallet, rule, pushChainNamespace) {
|
|
|
171
171
|
target: c.target,
|
|
172
172
|
selector: c.selector,
|
|
173
173
|
maxValue: c.maxValue,
|
|
174
|
-
pins:
|
|
175
|
-
|
|
176
|
-
|
|
174
|
+
pins: [
|
|
175
|
+
...c.pins.map((p) => p.op === 1
|
|
176
|
+
? { arg: storedArg(p.offset), max: BigInt(p.value) }
|
|
177
|
+
: {
|
|
178
|
+
arg: storedArg(p.offset),
|
|
179
|
+
expected: p.value.toLowerCase() ===
|
|
180
|
+
`0x${cfg.expectedCEA
|
|
181
|
+
.slice(2)
|
|
182
|
+
.toLowerCase()
|
|
183
|
+
.padStart(64, '0')}`
|
|
184
|
+
? public_rule_1.WALLET
|
|
185
|
+
: p.value,
|
|
186
|
+
}),
|
|
187
|
+
...(c.hasBeneficiary
|
|
188
|
+
? [{ arg: storedArg(c.beneficiaryOffset), expected: public_rule_1.WALLET }]
|
|
189
|
+
: []),
|
|
190
|
+
],
|
|
177
191
|
})),
|
|
178
192
|
},
|
|
179
193
|
};
|
|
@@ -188,7 +202,7 @@ async function decodeActiveRule(snap, gen, wallet, rule, pushChainNamespace) {
|
|
|
188
202
|
}
|
|
189
203
|
const decoded = (0, native_1.nativeActionTermsToRule)(configs, rule.agent);
|
|
190
204
|
if (configs.some((c) => c.maxValueTotal !== defaults_1.UINT256_MAX ||
|
|
191
|
-
Number(c.maxCalls) !==
|
|
205
|
+
Number(c.maxCalls) !== 0xffffffff ||
|
|
192
206
|
(c.amount.enabled && c.amount.maxTotal !== defaults_1.UINT256_MAX) ||
|
|
193
207
|
Number(c.validUntil) !== decoded.validUntil)) {
|
|
194
208
|
throw (0, errors_1.capabilityUnavailable)('nativeRuleRead', 'stored lifetime limits or differing action expiries cannot be represented by section-6 rules without losing constraints');
|
|
@@ -198,13 +212,15 @@ async function decodeActiveRule(snap, gen, wallet, rule, pushChainNamespace) {
|
|
|
198
212
|
selector: c.selector === '0xffffffff' ? 'value-only' : c.selector,
|
|
199
213
|
maxValue: c.maxValuePerCall,
|
|
200
214
|
pins: [
|
|
201
|
-
...c.pins.map((p) =>
|
|
202
|
-
arg: storedArg(p.offset),
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
215
|
+
...c.pins.map((p) => p.op === 1
|
|
216
|
+
? { arg: storedArg(p.offset), max: BigInt(p.value) }
|
|
217
|
+
: {
|
|
218
|
+
arg: storedArg(p.offset),
|
|
219
|
+
expected: p.value.toLowerCase() ===
|
|
220
|
+
`0x${wallet.slice(2).toLowerCase().padStart(64, '0')}`
|
|
221
|
+
? public_rule_1.WALLET
|
|
222
|
+
: p.value,
|
|
223
|
+
}),
|
|
208
224
|
...(c.amount.enabled
|
|
209
225
|
? [{ arg: storedArg(c.amount.offset), max: c.amount.maxPerCall }]
|
|
210
226
|
: []),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Internal lossless SVM state shared by public reads and execution. */
|
|
2
2
|
import type { Address, Hex } from 'viem';
|
|
3
3
|
import type { AgenticGeneration } from '../deployments';
|
|
4
|
-
import type { SvmConfigRead } from '../contracts/
|
|
4
|
+
import type { SvmConfigRead } from '../contracts/v6';
|
|
5
5
|
import { type ActiveRule } from './rules';
|
|
6
6
|
import type { Snapshot } from './snapshot';
|
|
7
7
|
export interface SvmRuleSnapshot {
|
|
@@ -4,7 +4,7 @@ exports.readSvmRule = readSvmRule;
|
|
|
4
4
|
exports.readSvmConfig = readSvmConfig;
|
|
5
5
|
const errors_1 = require("../errors");
|
|
6
6
|
const ids_1 = require("../codec/ids");
|
|
7
|
-
const
|
|
7
|
+
const v6_1 = require("../contracts/v6");
|
|
8
8
|
const svm_terms_1 = require("../codec/svm-terms");
|
|
9
9
|
const rules_1 = require("./rules");
|
|
10
10
|
async function readSvmRule(snap, gen, wallet, rulesId, pushChainNamespace) {
|
|
@@ -15,7 +15,7 @@ async function readSvmRule(snap, gen, wallet, rulesId, pushChainNamespace) {
|
|
|
15
15
|
}
|
|
16
16
|
async function readSvmConfig(snap, gen, wallet, active, pushChainNamespace) {
|
|
17
17
|
const chain = (0, rules_1.chainFromHash)(active.chainHash, pushChainNamespace);
|
|
18
|
-
const expectedAction = (0, ids_1.actionId)(gen.addresses.gateway,
|
|
18
|
+
const expectedAction = (0, ids_1.actionId)(gen.addresses.gateway, v6_1.SEND_OUTBOUND_SELECTOR);
|
|
19
19
|
if (active.mode !== 0 ||
|
|
20
20
|
active.vm !== 1 ||
|
|
21
21
|
!chain?.startsWith('solana:') ||
|
|
@@ -15,7 +15,7 @@ const helpers_1 = require("../orchestrator/internals/helpers");
|
|
|
15
15
|
const account_1 = require("../universal/account/account");
|
|
16
16
|
const chain_3 = require("./chain");
|
|
17
17
|
const abi_1 = require("../constants/abi");
|
|
18
|
-
const
|
|
18
|
+
const v6_1 = require("./contracts/v6");
|
|
19
19
|
const deployments_1 = require("./deployments");
|
|
20
20
|
/**
|
|
21
21
|
* Present an AGW send as the wallet's own transaction: `from` is the AGW and
|
|
@@ -83,7 +83,7 @@ async function adaptTrackedResponse(runtime, resp) {
|
|
|
83
83
|
const batch = await adaptNativeAgentBatch(runtime, resp);
|
|
84
84
|
if (batch)
|
|
85
85
|
return batch;
|
|
86
|
-
const decoded =
|
|
86
|
+
const decoded = v6_1.v6.decodeWalletCall(resp.data);
|
|
87
87
|
if (!decoded ||
|
|
88
88
|
(decoded.kind !== 'execute' && decoded.kind !== 'executeAsAgent'))
|
|
89
89
|
return resp;
|
|
@@ -107,7 +107,7 @@ async function adaptTrackedResponse(runtime, resp) {
|
|
|
107
107
|
: undefined;
|
|
108
108
|
const calls = decoded.calls;
|
|
109
109
|
const outbound = calls.find((c) => (0, viem_2.getAddress)(c.target) === gen.addresses.gateway &&
|
|
110
|
-
c.data.toLowerCase().startsWith(
|
|
110
|
+
c.data.toLowerCase().startsWith(v6_1.SEND_OUTBOUND_SELECTOR));
|
|
111
111
|
if (outbound) {
|
|
112
112
|
const out = decodeOutbound(outbound.data);
|
|
113
113
|
const chain = await tokenChain(runtime, out.token);
|
|
@@ -204,7 +204,7 @@ async function adaptTrackedResponse(runtime, resp) {
|
|
|
204
204
|
/** Decode only supported sender-account batches, never an arbitrary forwarding helper. */
|
|
205
205
|
async function adaptNativeAgentBatch(runtime, resp) {
|
|
206
206
|
let outer;
|
|
207
|
-
const isUea = resp.data.toLowerCase().startsWith(
|
|
207
|
+
const isUea = resp.data.toLowerCase().startsWith(v6_1.UEA_MULTICALL_PREFIX);
|
|
208
208
|
try {
|
|
209
209
|
if (isUea) {
|
|
210
210
|
const [entries] = (0, viem_2.decodeAbiParameters)([
|
|
@@ -224,7 +224,7 @@ async function adaptNativeAgentBatch(runtime, resp) {
|
|
|
224
224
|
}));
|
|
225
225
|
}
|
|
226
226
|
else {
|
|
227
|
-
const batch =
|
|
227
|
+
const batch = v6_1.v6.decodeWalletCall(resp.data);
|
|
228
228
|
if (batch?.kind !== 'execute' || batch.mode !== `0x01${'00'.repeat(31)}`)
|
|
229
229
|
return;
|
|
230
230
|
outer = batch.calls;
|
|
@@ -232,7 +232,7 @@ async function adaptNativeAgentBatch(runtime, resp) {
|
|
|
232
232
|
if (outer.length < 2 ||
|
|
233
233
|
outer.some((c) => c.value !== BigInt(0) || c.target !== outer[0].target))
|
|
234
234
|
return;
|
|
235
|
-
const inner = outer.map((c) =>
|
|
235
|
+
const inner = outer.map((c) => v6_1.v6.decodeWalletCall(c.data));
|
|
236
236
|
const first = inner[0];
|
|
237
237
|
if (first?.kind !== 'executeAsAgent' || first.calls.length !== 1)
|
|
238
238
|
return;
|
|
@@ -305,7 +305,7 @@ function decodeOutbound(data) {
|
|
|
305
305
|
const { args } = (0, viem_2.decodeFunctionData)({ abi: abi_1.UNIVERSAL_GATEWAY_PC, data });
|
|
306
306
|
const req = args?.[0];
|
|
307
307
|
let calls = [];
|
|
308
|
-
if (req.payload.toLowerCase().startsWith(
|
|
308
|
+
if (req.payload.toLowerCase().startsWith(v6_1.UEA_MULTICALL_PREFIX)) {
|
|
309
309
|
try {
|
|
310
310
|
const [decodedCalls] = (0, viem_2.decodeAbiParameters)([
|
|
311
311
|
{
|
|
@@ -5,14 +5,14 @@ exports.decodeAgwErrorData = decodeAgwErrorData;
|
|
|
5
5
|
exports.decodeAgenticRevert = decodeAgenticRevert;
|
|
6
6
|
const viem_1 = require("viem");
|
|
7
7
|
const utils_1 = require("viem/utils");
|
|
8
|
-
const
|
|
8
|
+
const v6_1 = require("./contracts/abi/v6");
|
|
9
9
|
/** URP reverts reached through the engine are truncated to this wrapper. */
|
|
10
10
|
exports.POLICY_CHECK_REVERTED_SELECTOR = '0xf4270752';
|
|
11
11
|
const ERROR_ABIS = [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
v6_1.AGW_ABI,
|
|
13
|
+
v6_1.UNIVERSAL_RULES_POLICY_ABI,
|
|
14
|
+
v6_1.AGW_FACTORY_ABI,
|
|
15
|
+
v6_1.SMART_SESSION_ABI,
|
|
16
16
|
];
|
|
17
17
|
/** selector → error name across the AGW/URP/factory/engine ABIs. */
|
|
18
18
|
const ERROR_NAMES = new Map(ERROR_ABIS.flatMap((abi) => abi
|
|
@@ -86,9 +86,18 @@ function createAgenticRuntime(orchestrator, isReadOnly) {
|
|
|
86
86
|
const r = await (0, cea_utils_1.getCEAAddress)(account, chain, orchestrator.getRpcUrls()[chain]?.[0]);
|
|
87
87
|
return { cea: (0, viem_1.getAddress)(r.cea), isDeployed: r.isDeployed };
|
|
88
88
|
},
|
|
89
|
-
resolvePrc20: (token, chain) =>
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
resolvePrc20: (token, chain) => {
|
|
90
|
+
if (!token)
|
|
91
|
+
return (0, viem_1.getAddress)((0, helpers_1.getNativePRC20ForChain)(chain, network));
|
|
92
|
+
// Native ETH shares a symbol/address across chains. A plain token must
|
|
93
|
+
// resolve within the known destination, never the first global match.
|
|
94
|
+
if (typeof token === 'object' && 'prc20Address' in token) {
|
|
95
|
+
if (!('sourceChain' in token) || token.sourceChain !== chain)
|
|
96
|
+
throw new errors_2.AgenticError(errors_2.AGENTIC_ERROR_CODE.ASSET_CHAIN_MISMATCH, 'Push token source chain must match the destination chain');
|
|
97
|
+
return (0, viem_1.getAddress)((0, prc20_address_1.getPRC20Address)(token, { network }).address);
|
|
98
|
+
}
|
|
99
|
+
return (0, viem_1.getAddress)((0, prc20_address_1.getPRC20Address)({ chain, address: typeof token === 'string' ? token : token.address }, { network }).address);
|
|
100
|
+
},
|
|
92
101
|
nowSeconds: () => Math.floor(Date.now() / 1000),
|
|
93
102
|
};
|
|
94
103
|
}
|
package/src/lib/agentic/utils.js
CHANGED
|
@@ -62,7 +62,7 @@ exports.internalAgenticUtils = {
|
|
|
62
62
|
rulesPolicy: (0, viem_1.getAddress)(ctx.rulesPolicy),
|
|
63
63
|
gateway: ctx.gateway,
|
|
64
64
|
universal: ctx.universal,
|
|
65
|
-
capabilities: deployments_1.
|
|
65
|
+
capabilities: deployments_1.V6_CAPABILITIES,
|
|
66
66
|
nowSeconds: ctx.nowSeconds ?? Math.floor(Date.now() / 1000),
|
|
67
67
|
}).map((p) => (0, session_1.encodeSession)(p.session));
|
|
68
68
|
},
|
package/src/lib/index.d.ts
CHANGED
|
@@ -24,6 +24,6 @@ export { PushChainExecutionError, PushChainBatchExecutionError, } from './orches
|
|
|
24
24
|
export type { DecodedErrorPayload } from './orchestrator/internals/errors';
|
|
25
25
|
export type { PushChainInitializeOptions } from './push-chain/push-chain';
|
|
26
26
|
export { AGENTIC_ERROR_CODE, AgenticError, AgenticRevertError, } from './agentic';
|
|
27
|
-
export type { AgenticAddress, AgenticDoor, AgenticErrorCode, AgenticHex, AgenticNamespace, AgenticProgressHook, AgenticTxMetadata, AgenticWallet, AllowedCall, AssetCap, Checkpoint, CheckpointKind, CreateOptions, CreateResult, ForeignChainNamespace, DecodedSolanaRule, Rule, RuleInput, Pin, Spent, WalletMarker, RulesRecord, Selector, WalletInfo, WalletSummary, } from './agentic';
|
|
27
|
+
export type { AgenticAddress, AgenticDoor, AgenticErrorCode, AgenticHex, AgenticNamespace, AgenticProgressHook, AgenticTxMetadata, AgenticWallet, AllowedCall, AssetCap, Checkpoint, CheckpointKind, CreateOptions, CreateResult, ForeignChainNamespace, DecodedSolanaRule, Rule, RuleInput, Pin, Spent, WalletMarker, ArgumentPath, RulesRecord, Selector, WalletInfo, WalletSummary, } from './agentic';
|
|
28
28
|
export { PushChain };
|
|
29
29
|
export type { Preset, PresetCategory, PresetAsset, PresetOptions, ReadyPresetOptions, PresetRuleTemplate, AgenticPresets, } from './agentic';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/** Source 2e61e13; code/proxy wiring checked at Donut block 23991912. */
|
|
2
|
-
export declare const V5_SOURCE_COMMIT = "2e61e133e641b4e0e1ddbdc9306b0903b60e4dbb";
|
|
3
|
-
export declare const DONUT_V5_START_BLOCK: bigint;
|
|
4
|
-
export declare const DONUT_V5_ADDRESSES: {
|
|
5
|
-
readonly factory: "0x8137F96A50EBF41d904e3678c84c391a0D1BCcc5";
|
|
6
|
-
readonly walletImplementation: "0x4D459Da499C14548aa16c46c57fD92880A88EBb4";
|
|
7
|
-
readonly sessionEngine: "0x165A5E6782f39D30B38c7D97e1303e4CB2aD102a";
|
|
8
|
-
readonly rulesPolicy: "0x603E7f0aF6e1aAFf46DDfb28b1e99364f8BC59af";
|
|
9
|
-
readonly sessionValidator: "0x068EE2388475A98EE1f5a434C58bFF3444fffFe6";
|
|
10
|
-
readonly gateway: "0x00000000000000000000000000000000000000C1";
|
|
11
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DONUT_V5_ADDRESSES = exports.DONUT_V5_START_BLOCK = exports.V5_SOURCE_COMMIT = void 0;
|
|
4
|
-
/** Source 2e61e13; code/proxy wiring checked at Donut block 23991912. */
|
|
5
|
-
exports.V5_SOURCE_COMMIT = '2e61e133e641b4e0e1ddbdc9306b0903b60e4dbb';
|
|
6
|
-
exports.DONUT_V5_START_BLOCK = BigInt(23989983);
|
|
7
|
-
exports.DONUT_V5_ADDRESSES = {
|
|
8
|
-
factory: '0x8137F96A50EBF41d904e3678c84c391a0D1BCcc5',
|
|
9
|
-
walletImplementation: '0x4D459Da499C14548aa16c46c57fD92880A88EBb4',
|
|
10
|
-
sessionEngine: '0x165A5E6782f39D30B38c7D97e1303e4CB2aD102a',
|
|
11
|
-
rulesPolicy: '0x603E7f0aF6e1aAFf46DDfb28b1e99364f8BC59af',
|
|
12
|
-
sessionValidator: '0x068EE2388475A98EE1f5a434C58bFF3444fffFe6',
|
|
13
|
-
gateway: '0x00000000000000000000000000000000000000C1',
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=donut-v5.js.map
|
|
File without changes
|
|
File without changes
|