@pushchain/core 6.0.27-alpha.0 → 6.0.27-alpha.2
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 +104 -19
- package/CHANGELOG.md +16 -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 +2 -2
- 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/aave-reserves.d.ts +4 -0
- package/src/lib/agentic/presets/aave-reserves.js +147 -0
- package/src/lib/agentic/presets/catalog.d.ts +30 -3
- package/src/lib/agentic/presets/catalog.js +344 -3
- package/src/lib/agentic/presets/index.js +186 -22
- package/src/lib/agentic/presets/operation-limits.d.ts +13 -0
- package/src/lib/agentic/presets/operation-limits.js +111 -0
- package/src/lib/agentic/presets/types.d.ts +44 -9
- 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 +2 -2
- 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
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nativeAsset = exports.assetAddress = void 0;
|
|
4
|
+
exports.applyOperationLimits = applyOperationLimits;
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const assetAddress = (asset) => typeof asset.token === 'string' ? asset.token : asset.token.address;
|
|
7
|
+
exports.assetAddress = assetAddress;
|
|
8
|
+
const nativeAsset = (asset) => (0, exports.assetAddress)(asset) === viem_1.zeroAddress ||
|
|
9
|
+
(typeof asset.token !== 'string' && asset.token.mechanism === 'native');
|
|
10
|
+
exports.nativeAsset = nativeAsset;
|
|
11
|
+
/** Compile reviewed protocol argument positions. No exchange-rate or share guesses. */
|
|
12
|
+
function applyOperationLimits(definitions, assets) {
|
|
13
|
+
const matches = (definition) => {
|
|
14
|
+
const b = definition.budget;
|
|
15
|
+
if (!b)
|
|
16
|
+
return [];
|
|
17
|
+
if (b.kind === 'native-value')
|
|
18
|
+
return assets.filter(exports.nativeAsset);
|
|
19
|
+
if (b.kind === 'fixed-token')
|
|
20
|
+
return assets.filter((a) => !(0, exports.nativeAsset)(a) && (0, viem_1.getAddress)((0, exports.assetAddress)(a)) === (0, viem_1.getAddress)(b.token));
|
|
21
|
+
if (b.kind === 'token-argument')
|
|
22
|
+
return assets.filter((a) => !(0, exports.nativeAsset)(a) &&
|
|
23
|
+
(!b.tokens ||
|
|
24
|
+
b.tokens.some((t) => (0, viem_1.getAddress)(t) === (0, viem_1.getAddress)((0, exports.assetAddress)(a)))));
|
|
25
|
+
return [];
|
|
26
|
+
};
|
|
27
|
+
const previewAll = !definitions.some((d) => matches(d).length > 0);
|
|
28
|
+
const calls = [];
|
|
29
|
+
const disabledCalls = [], excludedCalls = [];
|
|
30
|
+
const knownTokens = new Set();
|
|
31
|
+
let enabled = false;
|
|
32
|
+
for (const definition of definitions) {
|
|
33
|
+
const { budget, ...call } = definition;
|
|
34
|
+
if (!budget || budget.kind === 'setup') {
|
|
35
|
+
calls.push(call);
|
|
36
|
+
if (!budget)
|
|
37
|
+
enabled = true; // Non-budgeted internal fixture entries only.
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const info = {
|
|
41
|
+
target: call.target,
|
|
42
|
+
selector: call.selector,
|
|
43
|
+
...(call.app ? { app: call.app } : {}),
|
|
44
|
+
};
|
|
45
|
+
if (budget.kind === 'unsupported') {
|
|
46
|
+
excludedCalls.push({
|
|
47
|
+
...info,
|
|
48
|
+
reason: budget.reason,
|
|
49
|
+
...(budget.alternative ? { alternative: budget.alternative } : {}),
|
|
50
|
+
});
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (budget.kind === 'fixed-token')
|
|
54
|
+
knownTokens.add((0, viem_1.getAddress)(budget.token));
|
|
55
|
+
if (budget.kind === 'native-value')
|
|
56
|
+
knownTokens.add(viem_1.zeroAddress);
|
|
57
|
+
if (budget.kind === 'token-argument')
|
|
58
|
+
budget.tokens?.forEach((t) => knownTokens.add((0, viem_1.getAddress)(t)));
|
|
59
|
+
const selected = matches(definition);
|
|
60
|
+
if (!selected.length && !previewAll) {
|
|
61
|
+
excludedCalls.push({
|
|
62
|
+
...info,
|
|
63
|
+
reason: 'UNSELECTED_TOKEN',
|
|
64
|
+
...(budget.kind === 'fixed-token'
|
|
65
|
+
? { token: (0, viem_1.getAddress)(budget.token) }
|
|
66
|
+
: {}),
|
|
67
|
+
});
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
for (const asset of selected.length ? selected : [undefined]) {
|
|
71
|
+
const maximum = asset?.maxPerCall ?? BigInt(0);
|
|
72
|
+
const pins = [...(call.pins ?? [])];
|
|
73
|
+
if (budget.kind === 'token-argument' && asset)
|
|
74
|
+
pins.push({
|
|
75
|
+
arg: budget.tokenArg,
|
|
76
|
+
expected: (0, viem_1.getAddress)((0, exports.assetAddress)(asset)),
|
|
77
|
+
});
|
|
78
|
+
if (budget.kind !== 'native-value')
|
|
79
|
+
pins.push({ arg: budget.amountArg, max: maximum });
|
|
80
|
+
calls.push({
|
|
81
|
+
...call,
|
|
82
|
+
...(pins.length ? { pins } : {}),
|
|
83
|
+
...(budget.kind === 'native-value' ? { maxValue: maximum } : {}),
|
|
84
|
+
});
|
|
85
|
+
if (maximum > BigInt(0))
|
|
86
|
+
enabled = true;
|
|
87
|
+
else
|
|
88
|
+
disabledCalls.push({
|
|
89
|
+
...info,
|
|
90
|
+
reason: asset
|
|
91
|
+
? 'ZERO_CAP'
|
|
92
|
+
: assets.length
|
|
93
|
+
? 'UNSELECTED_TOKEN'
|
|
94
|
+
: 'TOKEN_REQUIRED',
|
|
95
|
+
...(asset
|
|
96
|
+
? { token: (0, exports.assetAddress)(asset) }
|
|
97
|
+
: budget.kind === 'fixed-token'
|
|
98
|
+
? { token: (0, viem_1.getAddress)(budget.token) }
|
|
99
|
+
: {}),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
calls,
|
|
105
|
+
enabled,
|
|
106
|
+
disabledCalls,
|
|
107
|
+
excludedCalls,
|
|
108
|
+
knownTokens: [...knownTokens],
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=operation-limits.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Address } from 'viem';
|
|
2
|
-
import type { Rule, RuleAsset, ForeignChainNamespace } from '../agentic.types';
|
|
3
|
-
export type PresetCategory = 'DEXES' | 'LENDING' | 'PREDICTION';
|
|
2
|
+
import type { Rule, RuleAsset, RuleCall, ForeignChainNamespace } from '../agentic.types';
|
|
3
|
+
export type PresetCategory = 'DEXES' | 'LENDING' | 'STAKING' | 'PREDICTION';
|
|
4
4
|
export interface Preset {
|
|
5
5
|
type: 'CATEGORY';
|
|
6
6
|
constant: PresetCategory;
|
|
@@ -15,30 +15,65 @@ export type PresetRuleTemplate = Omit<Rule, 'agent' | 'validUntil'> & {
|
|
|
15
15
|
export interface PresetAsset {
|
|
16
16
|
chainNamespace?: ForeignChainNamespace;
|
|
17
17
|
token: RuleAsset['token'];
|
|
18
|
-
/**
|
|
18
|
+
/** Per allowed operation and per Push outbound, in raw token units. Omitted = 0.
|
|
19
|
+
* Does not aggregate multiple destination calls in one transaction. */
|
|
19
20
|
maxPerCall?: bigint;
|
|
21
|
+
/** Cumulative Push-outbound amount only; not lifetime activity on destination-held assets. Omitted = 0. */
|
|
20
22
|
maxTotal?: bigint;
|
|
21
23
|
}
|
|
22
24
|
export interface PresetOptions {
|
|
25
|
+
/** Explicit Push-PC gas budget per outbound; omitted = zero. */
|
|
26
|
+
maxGasPerCall?: bigint;
|
|
23
27
|
chainNamespace?: ForeignChainNamespace;
|
|
24
28
|
agent?: Address;
|
|
25
29
|
validUntil?: number;
|
|
30
|
+
/** DEX swaps with fewer than two tokens are zero-input-cap review templates.
|
|
31
|
+
* Call get again with a complete pair to generate token pins and amount limits. */
|
|
26
32
|
assets?: PresetAsset[];
|
|
27
33
|
}
|
|
28
34
|
export interface ReadyPresetOptions extends PresetOptions {
|
|
29
35
|
agent: Address;
|
|
30
36
|
validUntil: number;
|
|
31
37
|
}
|
|
38
|
+
/** Offline configuration only: does not check deployment, reserves, balances or liquidity. */
|
|
39
|
+
export interface PresetConfigurationIssue {
|
|
40
|
+
code: 'AGENT_REQUIRED' | 'EXPIRY_REQUIRED' | 'GAS_BUDGET_REQUIRED' | 'ASSETS_REQUIRED' | 'TOKEN_PAIR_REQUIRED' | 'NO_ENABLED_OPERATION';
|
|
41
|
+
message: string;
|
|
42
|
+
}
|
|
43
|
+
export interface PresetCallIssue {
|
|
44
|
+
target: string;
|
|
45
|
+
selector: RuleCall['selector'];
|
|
46
|
+
app?: string;
|
|
47
|
+
reason: 'TOKEN_REQUIRED' | 'ZERO_CAP' | 'UNSELECTED_TOKEN' | 'SHARE_AMOUNT' | 'DYNAMIC_AMOUNT' | 'POSITION_AMOUNT';
|
|
48
|
+
token?: string;
|
|
49
|
+
alternative?: RuleCall['selector'];
|
|
50
|
+
}
|
|
51
|
+
export interface PresetChainReadiness {
|
|
52
|
+
chainNamespace: ForeignChainNamespace;
|
|
53
|
+
ready: boolean;
|
|
54
|
+
issues: PresetConfigurationIssue[];
|
|
55
|
+
/** Calls present in the rule but disabled by a zero amount/value maximum. */
|
|
56
|
+
disabledCalls: PresetCallIssue[];
|
|
57
|
+
/** Calls deliberately omitted, including operations with incompatible amount units. */
|
|
58
|
+
excludedCalls: PresetCallIssue[];
|
|
59
|
+
/** Known fixed-token/reserve addresses in this catalog, not selected defaults. */
|
|
60
|
+
knownTokens: string[];
|
|
61
|
+
/** Selected tokens with a zero Push-outbound budget; destination-held assets are separate. */
|
|
62
|
+
zeroBridgeLimits: string[];
|
|
63
|
+
}
|
|
64
|
+
export interface PresetResult<T extends PresetRuleTemplate = PresetRuleTemplate> {
|
|
65
|
+
rules: T[];
|
|
66
|
+
readiness: {
|
|
67
|
+
ready: boolean;
|
|
68
|
+
chains: PresetChainReadiness[];
|
|
69
|
+
};
|
|
70
|
+
}
|
|
32
71
|
export interface AgenticPresets {
|
|
33
72
|
list(options?: {
|
|
34
73
|
type?: 'CATEGORY';
|
|
35
74
|
}): {
|
|
36
75
|
presets: Preset[];
|
|
37
76
|
};
|
|
38
|
-
get(preset: PresetCategory, options: ReadyPresetOptions):
|
|
39
|
-
|
|
40
|
-
};
|
|
41
|
-
get(preset: PresetCategory, options?: PresetOptions): {
|
|
42
|
-
rules: PresetRuleTemplate[];
|
|
43
|
-
};
|
|
77
|
+
get(preset: PresetCategory, options: ReadyPresetOptions): PresetResult<Rule>;
|
|
78
|
+
get(preset: PresetCategory, options?: PresetOptions): PresetResult;
|
|
44
79
|
}
|
|
@@ -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
|
-
export type { Preset, PresetCategory, PresetAsset, PresetOptions, ReadyPresetOptions, PresetRuleTemplate, AgenticPresets, } from './agentic';
|
|
29
|
+
export type { Preset, PresetCategory, PresetAsset, PresetOptions, ReadyPresetOptions, PresetRuleTemplate, PresetResult, PresetChainReadiness, PresetConfigurationIssue, PresetCallIssue, 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
|