otto-intel-mcp 0.1.2 → 0.1.4
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/README.md +76 -18
- package/dist/account-userop-policy-definition.d.ts +14 -0
- package/dist/account-userop-policy-definition.js +12 -0
- package/dist/account-userop-policy-relation.d.ts +371 -0
- package/dist/account-userop-policy-relation.js +87 -0
- package/dist/adapter/cdp-signer.d.ts +76 -9
- package/dist/adapter/cdp-signer.js +274 -33
- package/dist/adapter/evm-call-failure.d.ts +29 -0
- package/dist/adapter/evm-call-failure.js +109 -0
- package/dist/adapter/refusal.d.ts +1 -1
- package/dist/adapter/refusal.js +13 -0
- package/dist/adapter/route-simulator.d.ts +91 -0
- package/dist/adapter/route-simulator.js +143 -0
- package/dist/adapter-cdp-index.d.ts +1 -1
- package/dist/executable-equities.d.ts +55 -0
- package/dist/executable-equities.js +116 -0
- package/dist/executable-yield-markets.d.ts +261 -0
- package/dist/executable-yield-markets.js +154 -0
- package/dist/execution-account-gas-quote.d.ts +141 -0
- package/dist/execution-account-gas-quote.js +443 -0
- package/dist/execution-account-gas-review.d.ts +123 -0
- package/dist/execution-account-gas-review.js +104 -0
- package/dist/execution-account-gas-runtime.d.ts +33 -0
- package/dist/execution-account-gas-runtime.js +131 -0
- package/dist/execution-account-gas-view.d.ts +936 -0
- package/dist/execution-account-gas-view.js +56 -0
- package/dist/execution-config.d.ts +3 -0
- package/dist/execution-config.js +4 -0
- package/dist/execution-delegated-definition.d.ts +7 -6
- package/dist/execution-delegated-definition.js +13 -2
- package/dist/execution-delegation-admin-definition.d.ts +127 -5
- package/dist/execution-delegation-admin-definition.js +155 -5
- package/dist/execution-delegation-admin.d.ts +48 -2
- package/dist/execution-delegation-admin.js +422 -12
- package/dist/execution-delegation-cap-store.d.ts +386 -0
- package/dist/execution-delegation-cap-store.js +1150 -0
- package/dist/execution-delegation-exit-definition.d.ts +309 -0
- package/dist/execution-delegation-exit-definition.js +204 -0
- package/dist/execution-delegation-exit-store.d.ts +114 -0
- package/dist/execution-delegation-exit-store.js +671 -0
- package/dist/execution-delegation-exit.d.ts +4 -0
- package/dist/execution-delegation-exit.js +614 -0
- package/dist/execution-delegation-finality.d.ts +22 -0
- package/dist/execution-delegation-finality.js +90 -0
- package/dist/execution-delegation-operation-store.d.ts +129 -0
- package/dist/execution-delegation-operation-store.js +1107 -0
- package/dist/execution-delegation-operations-definition.d.ts +282 -0
- package/dist/execution-delegation-operations-definition.js +117 -0
- package/dist/execution-delegation-operations.d.ts +6 -0
- package/dist/execution-delegation-operations.js +282 -0
- package/dist/execution-delegation-policy.d.ts +154 -8
- package/dist/execution-delegation-policy.js +273 -40
- package/dist/execution-delegation.d.ts +51 -0
- package/dist/execution-delegation.js +441 -31
- package/dist/execution-errors.d.ts +1 -1
- package/dist/execution-errors.js +122 -0
- package/dist/execution-index.d.ts +7 -2
- package/dist/execution-index.js +7 -2
- package/dist/execution-journal-schema.d.ts +96 -0
- package/dist/execution-journal-schema.js +368 -0
- package/dist/execution-journal-tables.d.ts +14 -0
- package/dist/execution-journal-tables.js +227 -0
- package/dist/execution-policy-compatibility.d.ts +34 -0
- package/dist/execution-policy-compatibility.js +76 -0
- package/dist/execution-registration.d.ts +54 -2
- package/dist/execution-registration.js +151 -5
- package/dist/execution-sponsored-account-profile.d.ts +32 -0
- package/dist/execution-sponsored-account-profile.js +59 -0
- package/dist/execution-sponsored-account.d.ts +1519 -0
- package/dist/execution-sponsored-account.js +222 -0
- package/dist/execution-sponsored-definition.d.ts +1713 -0
- package/dist/execution-sponsored-definition.js +185 -0
- package/dist/execution-sponsored-gas-policy.d.ts +27 -0
- package/dist/execution-sponsored-gas-policy.js +110 -0
- package/dist/execution-sponsored-hosted.d.ts +3 -0
- package/dist/execution-sponsored-hosted.js +71 -0
- package/dist/execution-sponsored-index.d.ts +1322 -0
- package/dist/execution-sponsored-index.js +102 -0
- package/dist/execution-sponsored-mcp-definition.d.ts +1662 -0
- package/dist/execution-sponsored-mcp-definition.js +94 -0
- package/dist/execution-sponsored-receipt.d.ts +47 -0
- package/dist/execution-sponsored-receipt.js +74 -0
- package/dist/execution-sponsored-registration.d.ts +14 -0
- package/dist/execution-sponsored-registration.js +77 -0
- package/dist/execution-sponsored-runtime.d.ts +84 -0
- package/dist/execution-sponsored-runtime.js +149 -0
- package/dist/execution-sponsored-settlement.d.ts +15 -0
- package/dist/execution-sponsored-settlement.js +88 -0
- package/dist/execution-sponsored-store.d.ts +67 -0
- package/dist/execution-sponsored-store.js +517 -0
- package/dist/execution-sponsored-transport.d.ts +90 -0
- package/dist/execution-sponsored-transport.js +180 -0
- package/dist/execution-tool-definitions.d.ts +21 -21
- package/dist/execution-tool-definitions.js +0 -7
- package/dist/execution-tools.d.ts +53 -1
- package/dist/execution-tools.js +171 -13
- package/dist/execution-worker-guard.d.ts +28 -0
- package/dist/execution-worker-guard.js +124 -0
- package/dist/hybrid-yield-index.d.ts +10 -0
- package/dist/hybrid-yield-index.js +11 -0
- package/dist/hybrid-yield-markets.d.ts +96 -0
- package/dist/hybrid-yield-markets.js +124 -0
- package/dist/hybrid-yield.d.ts +411 -0
- package/dist/hybrid-yield.js +155 -0
- package/dist/hyperliquid-order-builder.js +4 -0
- package/dist/lifi-execution-client.d.ts +6 -0
- package/dist/lifi-execution-client.js +3 -0
- package/dist/lp-userop-account.d.ts +461 -0
- package/dist/lp-userop-account.js +417 -0
- package/dist/lp-userop-authority.d.ts +49 -0
- package/dist/lp-userop-authority.js +211 -0
- package/dist/lp-userop-definition.d.ts +233 -0
- package/dist/lp-userop-definition.js +85 -0
- package/dist/lp-userop-hosted.d.ts +3 -0
- package/dist/lp-userop-hosted.js +73 -0
- package/dist/lp-userop-index.d.ts +1569 -0
- package/dist/lp-userop-index.js +112 -0
- package/dist/lp-userop-mcp-definition.d.ts +1220 -0
- package/dist/lp-userop-mcp-definition.js +46 -0
- package/dist/lp-userop-operation.d.ts +1230 -0
- package/dist/lp-userop-operation.js +140 -0
- package/dist/lp-userop-registration.d.ts +14 -0
- package/dist/lp-userop-registration.js +70 -0
- package/dist/lp-userop-settlement.d.ts +89 -0
- package/dist/lp-userop-settlement.js +184 -0
- package/dist/lp-userop.d.ts +643 -0
- package/dist/lp-userop.js +343 -0
- package/dist/native-yield-account-definition.d.ts +1192 -0
- package/dist/native-yield-account-definition.js +232 -0
- package/dist/native-yield-account-gas.d.ts +58 -0
- package/dist/native-yield-account-gas.js +228 -0
- package/dist/native-yield-account-index.d.ts +23 -0
- package/dist/native-yield-account-index.js +28 -0
- package/dist/native-yield-account-policy.d.ts +168 -0
- package/dist/native-yield-account-policy.js +525 -0
- package/dist/native-yield-account-rpc.d.ts +8 -0
- package/dist/native-yield-account-rpc.js +128 -0
- package/dist/native-yield-account-runtime.d.ts +71 -0
- package/dist/native-yield-account-runtime.js +125 -0
- package/dist/native-yield-account-store.d.ts +40 -0
- package/dist/native-yield-account-store.js +307 -0
- package/dist/native-yield-account.d.ts +662 -0
- package/dist/native-yield-account.js +371 -0
- package/dist/native-yield-consent-store.d.ts +20 -0
- package/dist/native-yield-consent-store.js +317 -0
- package/dist/native-yield-definition.d.ts +288 -0
- package/dist/native-yield-definition.js +105 -0
- package/dist/native-yield-reader.d.ts +4 -0
- package/dist/native-yield-reader.js +137 -0
- package/dist/native-yield-settlement.d.ts +48 -0
- package/dist/native-yield-settlement.js +167 -0
- package/dist/native-yield-simulation.d.ts +18 -0
- package/dist/native-yield-simulation.js +45 -0
- package/dist/native-yield-userop-account.d.ts +675 -0
- package/dist/native-yield-userop-account.js +357 -0
- package/dist/native-yield-userop-authority.d.ts +214 -0
- package/dist/native-yield-userop-authority.js +296 -0
- package/dist/native-yield-userop-definition.d.ts +331 -0
- package/dist/native-yield-userop-definition.js +105 -0
- package/dist/native-yield-userop-hosted.d.ts +3 -0
- package/dist/native-yield-userop-hosted.js +71 -0
- package/dist/native-yield-userop-index.d.ts +1522 -0
- package/dist/native-yield-userop-index.js +142 -0
- package/dist/native-yield-userop-mcp-definition.d.ts +1356 -0
- package/dist/native-yield-userop-mcp-definition.js +50 -0
- package/dist/native-yield-userop-operation.d.ts +845 -0
- package/dist/native-yield-userop-operation.js +127 -0
- package/dist/native-yield-userop-policy.d.ts +23 -0
- package/dist/native-yield-userop-policy.js +25 -0
- package/dist/native-yield-userop-registration.d.ts +17 -0
- package/dist/native-yield-userop-registration.js +76 -0
- package/dist/native-yield-userop-settlement.d.ts +8 -0
- package/dist/native-yield-userop-settlement.js +79 -0
- package/dist/native-yield-userop-simulation.d.ts +18 -0
- package/dist/native-yield-userop-simulation.js +34 -0
- package/dist/native-yield-userop.d.ts +35 -0
- package/dist/native-yield-userop.js +156 -0
- package/dist/native-yield-verify.d.ts +30 -0
- package/dist/native-yield-verify.js +141 -0
- package/dist/native-yield.d.ts +17 -0
- package/dist/native-yield.js +119 -0
- package/dist/stdio-main.js +0 -0
- package/dist/stock-buy-definition.d.ts +338 -0
- package/dist/stock-buy-definition.js +127 -0
- package/dist/stock-buy-oracle.d.ts +8 -0
- package/dist/stock-buy-oracle.js +22 -0
- package/dist/stock-buy.d.ts +17 -0
- package/dist/stock-buy.js +164 -0
- package/dist/tool-definitions.d.ts +3 -1
- package/dist/tool-definitions.js +55 -2
- package/dist/vendor/lp-v3/lp-v3-atomic-contract.d.ts +445 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-contract.js +90 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-evidence.d.ts +14 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-evidence.js +82 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-index.d.ts +80 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-index.js +19 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-plan.d.ts +43 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-plan.js +112 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-read-contract.d.ts +312 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-read-contract.js +41 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-read-index.d.ts +3 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-read-index.js +3 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-read-rpc.d.ts +49 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-read-rpc.js +88 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-read.d.ts +17 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-read.js +232 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-settlement.d.ts +105 -0
- package/dist/vendor/lp-v3/lp-v3-atomic-settlement.js +162 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-contract.d.ts +606 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-contract.js +59 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-index.d.ts +168 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-index.js +23 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-observation.d.ts +32 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-observation.js +228 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-plan.d.ts +11 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-plan.js +91 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-reconcile.d.ts +9 -0
- package/dist/vendor/lp-v3/lp-v3-collect-protocol-reconcile.js +124 -0
- package/dist/vendor/lp-v3/lp-v3-contract.d.ts +538 -0
- package/dist/vendor/lp-v3/lp-v3-contract.js +137 -0
- package/dist/vendor/lp-v3/lp-v3-evidence.d.ts +25 -0
- package/dist/vendor/lp-v3/lp-v3-evidence.js +168 -0
- package/dist/vendor/lp-v3/lp-v3-plan.d.ts +22 -0
- package/dist/vendor/lp-v3/lp-v3-plan.js +135 -0
- package/dist/vendor/lp-v3/types.d.ts +131 -0
- package/dist/vendor/lp-v3/types.js +6 -0
- package/dist/vendor/lp-v3/v4-math.d.ts +18 -0
- package/dist/vendor/lp-v3/v4-math.js +90 -0
- package/dist/yield-deposit-definition.d.ts +374 -0
- package/dist/yield-deposit-definition.js +123 -0
- package/dist/yield-deposit.d.ts +16 -0
- package/dist/yield-deposit.js +149 -0
- package/dist/yield-route-semantics.d.ts +27 -0
- package/dist/yield-route-semantics.js +71 -0
- package/dist/yield-withdraw-definition.d.ts +357 -0
- package/dist/yield-withdraw-definition.js +90 -0
- package/dist/yield-withdraw.d.ts +11 -0
- package/dist/yield-withdraw.js +122 -0
- package/package.json +239 -7
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** SHA-256 over the canonical JSON of a policy rule list. */
|
|
2
|
+
export declare function policyRulesDigest(rules: unknown): string;
|
|
3
|
+
export interface LegacyCompatibleCompositePolicyPin {
|
|
4
|
+
readonly policyId: string;
|
|
5
|
+
readonly policyName: string;
|
|
6
|
+
readonly policyDigest: string;
|
|
7
|
+
readonly legacyRulesDigest: string;
|
|
8
|
+
readonly nativeRulesDigest: string;
|
|
9
|
+
readonly legacyRuleCount: number;
|
|
10
|
+
}
|
|
11
|
+
export interface LegacyCompatibleCompositePolicyRecord {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly description?: string;
|
|
14
|
+
readonly scope: string;
|
|
15
|
+
readonly rules: unknown;
|
|
16
|
+
}
|
|
17
|
+
export interface LegacyCompatibleCompositeIdentity {
|
|
18
|
+
readonly policyId: string;
|
|
19
|
+
readonly policyName: string;
|
|
20
|
+
readonly policyDigest: string;
|
|
21
|
+
readonly legacyRulesDigest: string;
|
|
22
|
+
readonly nativeRulesDigest: string;
|
|
23
|
+
readonly legacyRuleCount: number;
|
|
24
|
+
readonly nativeRuleCount: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Exact compatibility identities only. This does not change a provider policy or activate a new rail.
|
|
28
|
+
* The Muse identity preserves the five v2 rules; its separate provider-acceptance gate stays closed.
|
|
29
|
+
*/
|
|
30
|
+
export declare const MODEL_B_COMPOSITE_V3_COMPATIBILITY_PINS: readonly LegacyCompatibleCompositePolicyPin[];
|
|
31
|
+
/** Pure validator used by activation review and focused mutation tests. */
|
|
32
|
+
export declare function validateLegacyCompatibleCompositePolicy(policy: LegacyCompatibleCompositePolicyRecord, pin: LegacyCompatibleCompositePolicyPin, expectedLegacyRulesDigest: string, expectedLegacyRuleCount: number): LegacyCompatibleCompositeIdentity | null;
|
|
33
|
+
/** Production lookup. There is deliberately no runtime or environment pin injection seam. */
|
|
34
|
+
export declare function readBackPinnedLegacyCompatibleCompositePolicy(policy: LegacyCompatibleCompositePolicyRecord, expectedLegacyRulesDigest: string, expectedLegacyRuleCount: number): LegacyCompatibleCompositeIdentity | null;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Exact, compile-time compatibility pins for projecting a composite policy to legacy callers. */
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
/** Sorted keys, undefined dropped, hex strings lowercased; arrays retain their order. */
|
|
4
|
+
function canonical(value) {
|
|
5
|
+
if (Array.isArray(value))
|
|
6
|
+
return value.map(canonical);
|
|
7
|
+
if (value !== null && typeof value === 'object') {
|
|
8
|
+
const out = {};
|
|
9
|
+
for (const key of Object.keys(value).sort()) {
|
|
10
|
+
const item = value[key];
|
|
11
|
+
if (item !== undefined)
|
|
12
|
+
out[key] = canonical(item);
|
|
13
|
+
}
|
|
14
|
+
return out;
|
|
15
|
+
}
|
|
16
|
+
if (typeof value === 'string' && /^0x[0-9a-fA-F]+$/.test(value))
|
|
17
|
+
return value.toLowerCase();
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
/** SHA-256 over the canonical JSON of a policy rule list. */
|
|
21
|
+
export function policyRulesDigest(rules) {
|
|
22
|
+
return createHash('sha256').update(JSON.stringify(canonical(rules))).digest('hex');
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Exact compatibility identities only. This does not change a provider policy or activate a new rail.
|
|
26
|
+
* The Muse identity preserves the five v2 rules; its separate provider-acceptance gate stays closed.
|
|
27
|
+
*/
|
|
28
|
+
export const MODEL_B_COMPOSITE_V3_COMPATIBILITY_PINS = Object.freeze([Object.freeze({
|
|
29
|
+
policyId: 'df85c39c-9f86-462f-a4cd-409b24ba243a',
|
|
30
|
+
policyName: 'OTTO model b and research fence v1',
|
|
31
|
+
policyDigest: 'e17570b83e1a573dcb1506ccf3d28f2dd50a8d76d1331ddebc7b78d349094aee',
|
|
32
|
+
legacyRulesDigest: '426165e3fe1631d8d8dca5f52ab3ccc78bb2d63ab2e12c73b7c077e6d49941d8',
|
|
33
|
+
nativeRulesDigest: '2061be246a4ac84121026afa78c74e54644f007804d255933762dd3e7e2afa9f',
|
|
34
|
+
legacyRuleCount: 5,
|
|
35
|
+
})]);
|
|
36
|
+
const DIGEST = /^[0-9a-f]{64}$/;
|
|
37
|
+
/** Pure validator used by activation review and focused mutation tests. */
|
|
38
|
+
export function validateLegacyCompatibleCompositePolicy(policy, pin, expectedLegacyRulesDigest, expectedLegacyRuleCount) {
|
|
39
|
+
if (policy.scope !== 'project' ||
|
|
40
|
+
policy.id !== pin.policyId ||
|
|
41
|
+
policy.description !== pin.policyName ||
|
|
42
|
+
!Array.isArray(policy.rules) ||
|
|
43
|
+
!Number.isSafeInteger(expectedLegacyRuleCount) ||
|
|
44
|
+
expectedLegacyRuleCount <= 0 ||
|
|
45
|
+
pin.legacyRuleCount !== expectedLegacyRuleCount ||
|
|
46
|
+
!DIGEST.test(expectedLegacyRulesDigest) ||
|
|
47
|
+
!DIGEST.test(pin.policyDigest) ||
|
|
48
|
+
!DIGEST.test(pin.legacyRulesDigest) ||
|
|
49
|
+
!DIGEST.test(pin.nativeRulesDigest) ||
|
|
50
|
+
pin.legacyRulesDigest !== expectedLegacyRulesDigest ||
|
|
51
|
+
policy.rules.length <= expectedLegacyRuleCount)
|
|
52
|
+
return null;
|
|
53
|
+
const legacyRules = policy.rules.slice(0, expectedLegacyRuleCount);
|
|
54
|
+
const nativeRules = policy.rules.slice(expectedLegacyRuleCount);
|
|
55
|
+
if (policyRulesDigest(policy.rules) !== pin.policyDigest ||
|
|
56
|
+
policyRulesDigest(legacyRules) !== expectedLegacyRulesDigest ||
|
|
57
|
+
policyRulesDigest(nativeRules) !== pin.nativeRulesDigest)
|
|
58
|
+
return null;
|
|
59
|
+
return Object.freeze({
|
|
60
|
+
policyId: pin.policyId,
|
|
61
|
+
policyName: pin.policyName,
|
|
62
|
+
policyDigest: pin.policyDigest,
|
|
63
|
+
legacyRulesDigest: pin.legacyRulesDigest,
|
|
64
|
+
nativeRulesDigest: pin.nativeRulesDigest,
|
|
65
|
+
legacyRuleCount: pin.legacyRuleCount,
|
|
66
|
+
nativeRuleCount: nativeRules.length,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/** Production lookup. There is deliberately no runtime or environment pin injection seam. */
|
|
70
|
+
export function readBackPinnedLegacyCompatibleCompositePolicy(policy, expectedLegacyRulesDigest, expectedLegacyRuleCount) {
|
|
71
|
+
const matches = MODEL_B_COMPOSITE_V3_COMPATIBILITY_PINS
|
|
72
|
+
.map((pin) => validateLegacyCompatibleCompositePolicy(policy, pin, expectedLegacyRulesDigest, expectedLegacyRuleCount))
|
|
73
|
+
.filter((match) => match !== null);
|
|
74
|
+
return matches.length === 1 ? matches[0] : null;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=execution-policy-compatibility.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
-
import { ensureDelegationFence, readDelegationStatus, revokeDelegation } from './execution-delegation-admin.js';
|
|
3
|
+
import { ensureDelegationFence, readDelegationStatus, reserveDelegationCap, revokeDelegation } from './execution-delegation-admin.js';
|
|
4
4
|
import { type ExecutionToolDefinition } from './execution-tool-definitions.js';
|
|
5
5
|
import { type ExecutionToolRuntime } from './execution-tools.js';
|
|
6
6
|
export declare const EXECUTION_TOOL_ANNOTATIONS: Readonly<{
|
|
@@ -11,6 +11,7 @@ export declare const EXECUTION_TOOL_ANNOTATIONS: Readonly<{
|
|
|
11
11
|
}>;
|
|
12
12
|
export declare function executionErrorResult(error: unknown): CallToolResult;
|
|
13
13
|
export declare function callExecutionDefinition(runtime: ExecutionToolRuntime, definition: ExecutionToolDefinition, rawInput: unknown, signal?: AbortSignal): Promise<CallToolResult>;
|
|
14
|
+
export declare function callYieldDefinition(prepare: (runtime: ExecutionToolRuntime, rawInput: unknown, signal?: AbortSignal) => Promise<unknown>, runtime: ExecutionToolRuntime, rawInput: unknown, signal?: AbortSignal): Promise<CallToolResult>;
|
|
14
15
|
/** A failure that is not a refusal is an upstream fault; nothing of it is relayed. */
|
|
15
16
|
export declare function delegatedErrorResult(error: unknown): CallToolResult;
|
|
16
17
|
/** The caller comes ONLY from the request headers; a value placed in the arguments is never consulted. */
|
|
@@ -47,7 +48,7 @@ declare const DELEGATION_ADMIN_TOOLS: readonly [{
|
|
|
47
48
|
readonly definition: Readonly<{
|
|
48
49
|
name: "otto_delegation_status";
|
|
49
50
|
title: "Read one end user's delegation status (token-bound)";
|
|
50
|
-
description: `Read back, for the end user identified by a CDP access token, their CDP accounts, whether the Model-B fence is present, and whether an active delegation reads back (with its expiry). Arguments: { accessToken } \u2014 the server resolves the user from the token; a client-sent user id is refused. Output is bound to that user; nothing about any other user is returned. ${string}`;
|
|
51
|
+
description: `Read back, for the end user identified by a CDP access token, their CDP accounts, whether the Model-B fence is present, and whether an active delegation reads back (with its expiry and the per-swap cap recorded for it). Arguments: { accessToken } \u2014 the server resolves the user from the token; a client-sent user id is refused. delegation.per_swap_cap_usd is the number THIS user chose at mint time; it is ABSENT when no cap is recorded for the grant, which means the delegated send will refuse it \u2014 say so rather than showing the shared ceiling. fence.per_swap_cap_usd is that shared ceiling and is never a per-user number. Output is bound to that user; nothing about any other user is returned. ${string}`;
|
|
51
52
|
inputSchema: import("zod").ZodObject<{}, import("zod/v4/core").$loose>;
|
|
52
53
|
strictInputSchema: import("zod").ZodObject<{
|
|
53
54
|
accessToken: import("zod").ZodString;
|
|
@@ -64,8 +65,11 @@ declare const DELEGATION_ADMIN_TOOLS: readonly [{
|
|
|
64
65
|
delegation: import("zod").ZodObject<{
|
|
65
66
|
active: import("zod").ZodBoolean;
|
|
66
67
|
expires_at: import("zod").ZodOptional<import("zod").ZodString>;
|
|
68
|
+
per_swap_cap_usd: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
67
69
|
}, import("zod/v4/core").$strict>;
|
|
68
70
|
revocation_requested_here: import("zod").ZodBoolean;
|
|
71
|
+
ruleset_version: import("zod").ZodNumber;
|
|
72
|
+
mint_enabled: import("zod").ZodBoolean;
|
|
69
73
|
}, import("zod/v4/core").$strict>;
|
|
70
74
|
annotations: Readonly<{
|
|
71
75
|
readOnlyHint: true;
|
|
@@ -104,8 +108,56 @@ declare const DELEGATION_ADMIN_TOOLS: readonly [{
|
|
|
104
108
|
}>;
|
|
105
109
|
}>;
|
|
106
110
|
readonly run: typeof revokeDelegation;
|
|
111
|
+
}, {
|
|
112
|
+
readonly definition: Readonly<{
|
|
113
|
+
name: "otto_delegation_cap";
|
|
114
|
+
title: "Confirm an in-flight legacy Model B cap (new reservations retired)";
|
|
115
|
+
description: `Legacy Model B cap confirmation. New { phase: "reserve" } requests are retired and refused before any claim or reservation is written. { phase: "confirm", accessToken, mintKey } remains available for a permission already minted against a prior reservation: the server re-reads CDP and confirms only the exact still-current claim and reserved expiry. A mismatch or Stop overlap remains unconfirmed; a fresh explicit Stop handles the current grant. Without a confirmed per-user cap, delegated sends refuse. This tool does not issue new permissions. ${string}`;
|
|
116
|
+
inputSchema: import("zod").ZodObject<{}, import("zod/v4/core").$loose>;
|
|
117
|
+
strictInputSchema: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
118
|
+
phase: import("zod").ZodLiteral<"reserve">;
|
|
119
|
+
accessToken: import("zod").ZodString;
|
|
120
|
+
perSwapCapUsd: import("zod").ZodNumber;
|
|
121
|
+
requestedDays: import("zod").ZodNumber;
|
|
122
|
+
mintKey: import("zod").ZodString;
|
|
123
|
+
}, import("zod/v4/core").$strict>, import("zod").ZodObject<{
|
|
124
|
+
phase: import("zod").ZodLiteral<"confirm">;
|
|
125
|
+
accessToken: import("zod").ZodString;
|
|
126
|
+
mintKey: import("zod").ZodString;
|
|
127
|
+
}, import("zod/v4/core").$strict>], "phase">;
|
|
128
|
+
outputSchema: import("zod").ZodObject<{
|
|
129
|
+
phase: import("zod").ZodEnum<{
|
|
130
|
+
reserve: "reserve";
|
|
131
|
+
confirm: "confirm";
|
|
132
|
+
}>;
|
|
133
|
+
user_id: import("zod").ZodString;
|
|
134
|
+
expires_at: import("zod").ZodString;
|
|
135
|
+
mint_expires_at: import("zod").ZodOptional<import("zod").ZodString>;
|
|
136
|
+
per_swap_cap_usd: import("zod").ZodNumber;
|
|
137
|
+
state: import("zod").ZodEnum<{
|
|
138
|
+
revoked: "revoked";
|
|
139
|
+
superseded: "superseded";
|
|
140
|
+
reserved: "reserved";
|
|
141
|
+
confirmed_active: "confirmed_active";
|
|
142
|
+
expired: "expired";
|
|
143
|
+
legacy: "legacy";
|
|
144
|
+
}>;
|
|
145
|
+
ruleset_version: import("zod").ZodNumber;
|
|
146
|
+
recorded: import("zod").ZodBoolean;
|
|
147
|
+
}, import("zod/v4/core").$strict>;
|
|
148
|
+
annotations: Readonly<{
|
|
149
|
+
readOnlyHint: false;
|
|
150
|
+
destructiveHint: false;
|
|
151
|
+
idempotentHint: true;
|
|
152
|
+
openWorldHint: true;
|
|
153
|
+
}>;
|
|
154
|
+
}>;
|
|
155
|
+
readonly run: typeof reserveDelegationCap;
|
|
107
156
|
}];
|
|
108
157
|
export declare function callDelegationAdminDefinition(runtime: ExecutionToolRuntime, run: (typeof DELEGATION_ADMIN_TOOLS)[number]['run'], rawInput: unknown, headers: Readonly<Record<string, string | string[] | undefined>> | undefined): Promise<CallToolResult>;
|
|
158
|
+
export declare function callDelegationOperationsDefinition(runtime: ExecutionToolRuntime, rawInput: unknown, headers: Readonly<Record<string, string | string[] | undefined>> | undefined): Promise<CallToolResult>;
|
|
159
|
+
export declare function callDelegationReconcileDefinition(runtime: ExecutionToolRuntime, rawInput: unknown, headers: Readonly<Record<string, string | string[] | undefined>> | undefined): Promise<CallToolResult>;
|
|
160
|
+
export declare function callDelegationExitDefinition(runtime: ExecutionToolRuntime, rawInput: unknown, headers: Readonly<Record<string, string | string[] | undefined>> | undefined): Promise<CallToolResult>;
|
|
109
161
|
export interface ExecutionCallAdmission {
|
|
110
162
|
run(call: () => Promise<CallToolResult>): Promise<CallToolResult>;
|
|
111
163
|
}
|
|
@@ -1,10 +1,26 @@
|
|
|
1
|
+
import { callLpUserOp } from './lp-userop-registration.js';
|
|
2
|
+
import { LP_USEROP_TOOL_DEFINITION } from './lp-userop-mcp-definition.js';
|
|
3
|
+
import { callNativeYieldUserOp } from './native-yield-userop-registration.js';
|
|
4
|
+
import { NATIVE_USEROP_TOOL_DEFINITION } from './native-yield-userop-mcp-definition.js';
|
|
5
|
+
import { callSponsoredAccount } from './execution-sponsored-registration.js';
|
|
6
|
+
import { SPONSORED_TOOL_DEFINITION } from './execution-sponsored-mcp-definition.js';
|
|
1
7
|
import { ExecutionRefusal, isExecutionRefusal } from './execution-errors.js';
|
|
2
8
|
import { DELEGATED_EXECUTION_TOOL_DEFINITION, DELEGATED_TOOL_ANNOTATIONS, } from './execution-delegated-definition.js';
|
|
3
9
|
import { callerFromHeaders, submitUnderDelegation } from './execution-delegation.js';
|
|
4
|
-
import { DELEGATION_FENCE_STATUS_TOOL_DEFINITION, DELEGATION_FENCE_TOOL_DEFINITION, DELEGATION_REVOKE_TOOL_DEFINITION, DELEGATION_STATUS_TOOL_DEFINITION, } from './execution-delegation-admin-definition.js';
|
|
5
|
-
import { ensureDelegationFence, readDelegationFenceStatus, readDelegationStatus, revokeDelegation, } from './execution-delegation-admin.js';
|
|
10
|
+
import { DELEGATION_CAP_TOOL_DEFINITION, DELEGATION_FENCE_STATUS_TOOL_DEFINITION, DELEGATION_FENCE_TOOL_DEFINITION, DELEGATION_REVOKE_TOOL_DEFINITION, DELEGATION_STATUS_TOOL_DEFINITION, } from './execution-delegation-admin-definition.js';
|
|
11
|
+
import { ensureDelegationFence, readDelegationFenceStatus, readDelegationStatus, reserveDelegationCap, revokeDelegation, } from './execution-delegation-admin.js';
|
|
12
|
+
import { DELEGATION_OPERATIONS_TOOL_DEFINITION, DELEGATION_RECONCILE_TOOL_DEFINITION, } from './execution-delegation-operations-definition.js';
|
|
13
|
+
import { readDelegationOperations, reconcileDelegationOperation } from './execution-delegation-operations.js';
|
|
14
|
+
import { DELEGATION_EXIT_TOOL_DEFINITION, } from './execution-delegation-exit-definition.js';
|
|
15
|
+
import { runDelegationExit } from './execution-delegation-exit.js';
|
|
6
16
|
import { EXECUTION_TOOL_DEFINITIONS, } from './execution-tool-definitions.js';
|
|
7
|
-
import {
|
|
17
|
+
import { YIELD_DEPOSIT_TOOL_DEFINITION } from './yield-deposit-definition.js';
|
|
18
|
+
import { prepareYieldDeposit } from './yield-deposit.js';
|
|
19
|
+
import { STOCK_BUY_TOOL_DEFINITION } from './stock-buy-definition.js';
|
|
20
|
+
import { prepareStockBuy } from './stock-buy.js';
|
|
21
|
+
import { YIELD_WITHDRAW_TOOL_DEFINITION } from './yield-withdraw-definition.js';
|
|
22
|
+
import { prepareYieldWithdraw } from './yield-withdraw.js';
|
|
23
|
+
import { prepareBridge, preparePolymarketOrder, prepareSwap, } from './execution-tools.js';
|
|
8
24
|
export const EXECUTION_TOOL_ANNOTATIONS = Object.freeze({
|
|
9
25
|
readOnlyHint: true,
|
|
10
26
|
destructiveHint: false,
|
|
@@ -39,13 +55,25 @@ export async function callExecutionDefinition(runtime, definition, rawInput, sig
|
|
|
39
55
|
case 'otto_prepare_polymarket_order':
|
|
40
56
|
return successResult(await preparePolymarketOrder(runtime, rawInput, signal));
|
|
41
57
|
case 'otto_prepare_perp_order':
|
|
42
|
-
|
|
58
|
+
throw new ExecutionRefusal('HYPERLIQUID_RETIRED', 'Hyperliquid trading is retired from public MCP; existing-account recovery uses the protected recovery interface');
|
|
43
59
|
}
|
|
44
60
|
}
|
|
45
61
|
catch (error) {
|
|
46
62
|
return executionErrorResult(error);
|
|
47
63
|
}
|
|
48
64
|
}
|
|
65
|
+
export async function callYieldDefinition(prepare, runtime, rawInput, signal) {
|
|
66
|
+
try {
|
|
67
|
+
const output = await prepare(runtime, rawInput, signal);
|
|
68
|
+
return {
|
|
69
|
+
content: [{ type: 'text', text: stringify(output) }],
|
|
70
|
+
structuredContent: output,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
return executionErrorResult(error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
49
77
|
function delegatedSuccessResult(result) {
|
|
50
78
|
return {
|
|
51
79
|
content: [{ type: 'text', text: stringify(result) }],
|
|
@@ -72,6 +100,7 @@ const DELEGATION_ADMIN_TOOLS = [
|
|
|
72
100
|
{ definition: DELEGATION_FENCE_TOOL_DEFINITION, run: ensureDelegationFence },
|
|
73
101
|
{ definition: DELEGATION_STATUS_TOOL_DEFINITION, run: readDelegationStatus },
|
|
74
102
|
{ definition: DELEGATION_REVOKE_TOOL_DEFINITION, run: revokeDelegation },
|
|
103
|
+
{ definition: DELEGATION_CAP_TOOL_DEFINITION, run: reserveDelegationCap },
|
|
75
104
|
];
|
|
76
105
|
export async function callDelegationAdminDefinition(runtime, run, rawInput, headers) {
|
|
77
106
|
try {
|
|
@@ -85,6 +114,42 @@ export async function callDelegationAdminDefinition(runtime, run, rawInput, head
|
|
|
85
114
|
return delegatedErrorResult(error);
|
|
86
115
|
}
|
|
87
116
|
}
|
|
117
|
+
export async function callDelegationOperationsDefinition(runtime, rawInput, headers) {
|
|
118
|
+
try {
|
|
119
|
+
const result = await readDelegationOperations(runtime, rawInput, callerFromHeaders(headers));
|
|
120
|
+
return {
|
|
121
|
+
content: [{ type: 'text', text: stringify(result) }],
|
|
122
|
+
structuredContent: result,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
return delegatedErrorResult(error);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export async function callDelegationReconcileDefinition(runtime, rawInput, headers) {
|
|
130
|
+
try {
|
|
131
|
+
const result = await reconcileDelegationOperation(runtime, rawInput, callerFromHeaders(headers));
|
|
132
|
+
return {
|
|
133
|
+
content: [{ type: 'text', text: stringify(result) }],
|
|
134
|
+
structuredContent: result,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
return delegatedErrorResult(error);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export async function callDelegationExitDefinition(runtime, rawInput, headers) {
|
|
142
|
+
try {
|
|
143
|
+
const result = await runDelegationExit(runtime, rawInput, callerFromHeaders(headers));
|
|
144
|
+
return {
|
|
145
|
+
content: [{ type: 'text', text: stringify(result) }],
|
|
146
|
+
structuredContent: result,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
return delegatedErrorResult(error);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
88
153
|
export function registerExecutionTools(server, runtime, admission) {
|
|
89
154
|
// The freshness window is stated in the description from the runtime's OWN config — never a literal:
|
|
90
155
|
// the 0.1.1 docs said "10 minutes" (the ceiling) while every hosted envelope carried 5 (the default),
|
|
@@ -107,9 +172,49 @@ export function registerExecutionTools(server, runtime, admission) {
|
|
|
107
172
|
return admission ? admission.run(call) : call();
|
|
108
173
|
});
|
|
109
174
|
}
|
|
175
|
+
// The Yield Copilot deposit constructor: registered where the delegated services are (it needs the
|
|
176
|
+
// rig's Base client for the vault's previewDeposit), read-only like every other prepare tool.
|
|
177
|
+
// Registered wherever the delegated set is; without a vault reader the tool refuses by name.
|
|
178
|
+
if (runtime.delegation) {
|
|
179
|
+
for (const yieldTool of [
|
|
180
|
+
{ definition: YIELD_DEPOSIT_TOOL_DEFINITION, prepare: prepareYieldDeposit },
|
|
181
|
+
{ definition: YIELD_WITHDRAW_TOOL_DEFINITION, prepare: prepareYieldWithdraw },
|
|
182
|
+
// The tokenized-stock buy constructor rides the same registration block: it needs the rig's
|
|
183
|
+
// Base client for the equity's Chainlink mark; without a reader it refuses by name.
|
|
184
|
+
{ definition: STOCK_BUY_TOOL_DEFINITION, prepare: prepareStockBuy },
|
|
185
|
+
]) {
|
|
186
|
+
const { definition, prepare } = yieldTool;
|
|
187
|
+
server.registerTool(definition.name, {
|
|
188
|
+
title: definition.title,
|
|
189
|
+
description: definition.description + freshness,
|
|
190
|
+
inputSchema: definition.inputSchema,
|
|
191
|
+
outputSchema: definition.outputSchema,
|
|
192
|
+
annotations: EXECUTION_TOOL_ANNOTATIONS,
|
|
193
|
+
}, (input, extra) => {
|
|
194
|
+
const call = () => callYieldDefinition(prepare, runtime, input, extra.signal);
|
|
195
|
+
return admission ? admission.run(call) : call();
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
110
199
|
// The one tool that submits: registered only when the runtime carries the delegated services, with
|
|
111
200
|
// its own (non-read-only) annotations, through the same per-identity admission as the prepare tools.
|
|
112
201
|
if (runtime.delegation) {
|
|
202
|
+
const sponsored = SPONSORED_TOOL_DEFINITION;
|
|
203
|
+
server.registerTool(sponsored.name, {
|
|
204
|
+
title: sponsored.title, description: sponsored.description, inputSchema: sponsored.inputSchema,
|
|
205
|
+
outputSchema: sponsored.outputSchema, annotations: sponsored.annotations,
|
|
206
|
+
}, (input, extra) => {
|
|
207
|
+
const call = () => callSponsoredAccount(runtime, input, extra.requestInfo?.headers);
|
|
208
|
+
return admission ? admission.run(call) : call();
|
|
209
|
+
});
|
|
210
|
+
const nativeUserOp = NATIVE_USEROP_TOOL_DEFINITION;
|
|
211
|
+
server.registerTool(nativeUserOp.name, {
|
|
212
|
+
title: nativeUserOp.title, description: nativeUserOp.description, inputSchema: nativeUserOp.inputSchema,
|
|
213
|
+
outputSchema: nativeUserOp.outputSchema, annotations: nativeUserOp.annotations,
|
|
214
|
+
}, (input, extra) => {
|
|
215
|
+
const call = () => callNativeYieldUserOp(runtime, input, extra.requestInfo?.headers);
|
|
216
|
+
return admission ? admission.run(call) : call();
|
|
217
|
+
});
|
|
113
218
|
const definition = DELEGATED_EXECUTION_TOOL_DEFINITION;
|
|
114
219
|
server.registerTool(definition.name, {
|
|
115
220
|
title: definition.title,
|
|
@@ -148,7 +253,7 @@ export function registerExecutionTools(server, runtime, admission) {
|
|
|
148
253
|
return admission ? admission.run(call) : call();
|
|
149
254
|
});
|
|
150
255
|
}
|
|
151
|
-
// The
|
|
256
|
+
// The four admin tools: fence ensure-by-digest, token-bound status, developer-side revoke and cap state.
|
|
152
257
|
for (const { definition: admin, run } of DELEGATION_ADMIN_TOOLS) {
|
|
153
258
|
server.registerTool(admin.name, {
|
|
154
259
|
title: admin.title,
|
|
@@ -161,6 +266,47 @@ export function registerExecutionTools(server, runtime, admission) {
|
|
|
161
266
|
return admission ? admission.run(call) : call();
|
|
162
267
|
});
|
|
163
268
|
}
|
|
269
|
+
const operations = DELEGATION_OPERATIONS_TOOL_DEFINITION;
|
|
270
|
+
server.registerTool(operations.name, {
|
|
271
|
+
title: operations.title,
|
|
272
|
+
description: operations.description,
|
|
273
|
+
inputSchema: operations.inputSchema,
|
|
274
|
+
outputSchema: operations.outputSchema,
|
|
275
|
+
annotations: operations.annotations,
|
|
276
|
+
}, (input, extra) => {
|
|
277
|
+
const call = () => callDelegationOperationsDefinition(runtime, input, extra.requestInfo?.headers);
|
|
278
|
+
return admission ? admission.run(call) : call();
|
|
279
|
+
});
|
|
280
|
+
const reconcile = DELEGATION_RECONCILE_TOOL_DEFINITION;
|
|
281
|
+
server.registerTool(reconcile.name, {
|
|
282
|
+
title: reconcile.title,
|
|
283
|
+
description: reconcile.description,
|
|
284
|
+
inputSchema: reconcile.inputSchema,
|
|
285
|
+
outputSchema: reconcile.outputSchema,
|
|
286
|
+
annotations: reconcile.annotations,
|
|
287
|
+
}, (input, extra) => {
|
|
288
|
+
const call = () => callDelegationReconcileDefinition(runtime, input, extra.requestInfo?.headers);
|
|
289
|
+
return admission ? admission.run(call) : call();
|
|
290
|
+
});
|
|
291
|
+
const exit = DELEGATION_EXIT_TOOL_DEFINITION;
|
|
292
|
+
server.registerTool(exit.name, {
|
|
293
|
+
title: exit.title,
|
|
294
|
+
description: exit.description,
|
|
295
|
+
inputSchema: exit.inputSchema,
|
|
296
|
+
outputSchema: exit.outputSchema,
|
|
297
|
+
annotations: exit.annotations,
|
|
298
|
+
}, (input, extra) => {
|
|
299
|
+
const call = () => callDelegationExitDefinition(runtime, input, extra.requestInfo?.headers);
|
|
300
|
+
return admission ? admission.run(call) : call();
|
|
301
|
+
});
|
|
302
|
+
const lpUserOp = LP_USEROP_TOOL_DEFINITION;
|
|
303
|
+
server.registerTool(lpUserOp.name, {
|
|
304
|
+
title: lpUserOp.title, description: lpUserOp.description, inputSchema: lpUserOp.inputSchema,
|
|
305
|
+
outputSchema: lpUserOp.outputSchema, annotations: lpUserOp.annotations,
|
|
306
|
+
}, (input, extra) => {
|
|
307
|
+
const call = () => callLpUserOp(runtime, input, extra.requestInfo?.headers);
|
|
308
|
+
return admission ? admission.run(call) : call();
|
|
309
|
+
});
|
|
164
310
|
}
|
|
165
311
|
}
|
|
166
312
|
//# sourceMappingURL=execution-registration.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Fixed-block, read-only proof for the reviewed same-address sponsored account family. */
|
|
2
|
+
import { type Address, type Hex, type PublicClient } from 'viem';
|
|
3
|
+
export declare const SPONSORED_ACCOUNT_PROXY: `0x${string}`;
|
|
4
|
+
export declare const SPONSORED_ACCOUNT_IMPLEMENTATION: `0x${string}`;
|
|
5
|
+
export declare const SPONSORED_ACCOUNT_ENTRY_POINT: `0x${string}`;
|
|
6
|
+
export declare const SPONSORED_ACCOUNT_IMPLEMENTATION_SLOT: `0x${string}`;
|
|
7
|
+
/** The caller must first validate its own strict, reviewed source/terms schema. */
|
|
8
|
+
export interface SponsoredAccountProfile {
|
|
9
|
+
readonly chainId: number;
|
|
10
|
+
readonly account: Address;
|
|
11
|
+
readonly delegate: Address;
|
|
12
|
+
readonly delegateCodeHash: string;
|
|
13
|
+
readonly implementation: Address;
|
|
14
|
+
readonly implementationCodeHash: string;
|
|
15
|
+
readonly entryPoint: Address;
|
|
16
|
+
readonly entryPointCodeHash: string;
|
|
17
|
+
readonly paymaster: Address;
|
|
18
|
+
readonly paymasterCodeHash: string;
|
|
19
|
+
readonly ownerProfile: {
|
|
20
|
+
readonly ownerAtIndex0: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export type SponsoredAccountProfileFailure = 'CHAIN' | 'CODE' | 'IMPLEMENTATION_CHANGED' | 'OWNER_PROFILE_CHANGED' | 'ENTRY_POINT_CHANGED' | 'REORG';
|
|
24
|
+
export declare class SponsoredAccountProfileError extends Error {
|
|
25
|
+
readonly reason: SponsoredAccountProfileFailure;
|
|
26
|
+
constructor(reason: SponsoredAccountProfileFailure);
|
|
27
|
+
}
|
|
28
|
+
/** No transport, grant or journal authority is created by these public-chain reads. */
|
|
29
|
+
export declare function assertSponsoredAccountProfile(client: PublicClient, terms: SponsoredAccountProfile, blockNumber: bigint, blockHash: Hex, additionalCodePins?: readonly {
|
|
30
|
+
readonly address: Address;
|
|
31
|
+
readonly codeHash: string;
|
|
32
|
+
}[]): Promise<void>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** Fixed-block, read-only proof for the reviewed same-address sponsored account family. */
|
|
2
|
+
import { getAddress, keccak256, parseAbi, stringToHex, toHex } from 'viem';
|
|
3
|
+
export const SPONSORED_ACCOUNT_PROXY = getAddress('0x7702cb554e6bFb442cb743A7dF23154544a7176C');
|
|
4
|
+
export const SPONSORED_ACCOUNT_IMPLEMENTATION = getAddress('0x000100abaad02f1cfC8Bbe32bD5a564817339E72');
|
|
5
|
+
export const SPONSORED_ACCOUNT_ENTRY_POINT = getAddress('0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789');
|
|
6
|
+
export const SPONSORED_ACCOUNT_IMPLEMENTATION_SLOT = toHex(BigInt(keccak256(stringToHex('eip1967.proxy.implementation'))) - 1n, { size: 32 });
|
|
7
|
+
const ACCOUNT_ABI = parseAbi([
|
|
8
|
+
'function nextOwnerIndex() view returns(uint256)',
|
|
9
|
+
'function ownerCount() view returns(uint256)',
|
|
10
|
+
'function ownerAtIndex(uint256 index) view returns(bytes)',
|
|
11
|
+
'function isOwnerAddress(address account) view returns(bool)',
|
|
12
|
+
'function entryPoint() view returns(address)',
|
|
13
|
+
]);
|
|
14
|
+
export class SponsoredAccountProfileError extends Error {
|
|
15
|
+
reason;
|
|
16
|
+
constructor(reason) {
|
|
17
|
+
super(`SPONSORED_ACCOUNT_PROFILE_${reason}`);
|
|
18
|
+
this.reason = reason;
|
|
19
|
+
this.name = 'SponsoredAccountProfileError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function ensure(value, reason) {
|
|
23
|
+
if (!value)
|
|
24
|
+
throw new SponsoredAccountProfileError(reason);
|
|
25
|
+
}
|
|
26
|
+
const same = (left, right) => left.toLowerCase() === right.toLowerCase();
|
|
27
|
+
/** No transport, grant or journal authority is created by these public-chain reads. */
|
|
28
|
+
export async function assertSponsoredAccountProfile(client, terms, blockNumber, blockHash, additionalCodePins = []) {
|
|
29
|
+
ensure(await client.getChainId() === terms.chainId, 'CHAIN');
|
|
30
|
+
const targets = [
|
|
31
|
+
[terms.delegate, terms.delegateCodeHash], [terms.entryPoint, terms.entryPointCodeHash],
|
|
32
|
+
[terms.implementation, terms.implementationCodeHash], [terms.paymaster, terms.paymasterCodeHash],
|
|
33
|
+
...additionalCodePins.map(pin => [pin.address, pin.codeHash]),
|
|
34
|
+
];
|
|
35
|
+
const [ownerCode, ...codes] = await Promise.all([
|
|
36
|
+
client.getCode({ address: terms.account, blockNumber }),
|
|
37
|
+
...targets.map(([address]) => client.getCode({ address, blockNumber })),
|
|
38
|
+
]);
|
|
39
|
+
ensure(ownerCode?.toLowerCase() === '0xef0100' + terms.delegate.slice(2).toLowerCase() &&
|
|
40
|
+
codes.every((code, index) => code && code !== '0x' && same(keccak256(code), targets[index][1])), 'CODE');
|
|
41
|
+
// The EOA's slot is its delegated execution context; the proxy singleton's slot is unrelated.
|
|
42
|
+
const implementationSlot = await client.getStorageAt({ address: terms.account,
|
|
43
|
+
slot: SPONSORED_ACCOUNT_IMPLEMENTATION_SLOT, blockNumber });
|
|
44
|
+
ensure(implementationSlot?.toLowerCase() === '0x' + '0'.repeat(24) + terms.implementation.slice(2).toLowerCase(), 'IMPLEMENTATION_CHANGED');
|
|
45
|
+
const [nextOwnerIndex, ownerCount, ownerAtIndex0, isOwnerAddress, implementationEntryPoint, accountEntryPoint] = await Promise.all([
|
|
46
|
+
client.readContract({ address: terms.account, abi: ACCOUNT_ABI, functionName: 'nextOwnerIndex', blockNumber }),
|
|
47
|
+
client.readContract({ address: terms.account, abi: ACCOUNT_ABI, functionName: 'ownerCount', blockNumber }),
|
|
48
|
+
client.readContract({ address: terms.account, abi: ACCOUNT_ABI, functionName: 'ownerAtIndex', args: [0n], blockNumber }),
|
|
49
|
+
client.readContract({ address: terms.account, abi: ACCOUNT_ABI, functionName: 'isOwnerAddress', args: [terms.account], blockNumber }),
|
|
50
|
+
client.readContract({ address: terms.implementation, abi: ACCOUNT_ABI, functionName: 'entryPoint', blockNumber }),
|
|
51
|
+
client.readContract({ address: terms.account, abi: ACCOUNT_ABI, functionName: 'entryPoint', blockNumber }),
|
|
52
|
+
]);
|
|
53
|
+
ensure(nextOwnerIndex === 1n && ownerCount === 1n && same(ownerAtIndex0, terms.ownerProfile.ownerAtIndex0) &&
|
|
54
|
+
isOwnerAddress === true, 'OWNER_PROFILE_CHANGED');
|
|
55
|
+
ensure(same(implementationEntryPoint, terms.entryPoint) && same(accountEntryPoint, terms.entryPoint), 'ENTRY_POINT_CHANGED');
|
|
56
|
+
const anchor = await client.getBlock({ blockNumber });
|
|
57
|
+
ensure(anchor.number === blockNumber && anchor.hash === blockHash, 'REORG');
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=execution-sponsored-account-profile.js.map
|