@agenticprimitives/chain-state-viem 0.0.0-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/LICENSE +21 -0
- package/README.md +40 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.d.ts +27 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +74 -0
- package/dist/provider.js.map +1 -0
- package/package.json +57 -0
- package/spec.md +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Agentic Trust Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# @agenticprimitives/chain-state-viem
|
|
2
|
+
|
|
3
|
+
The viem-backed `ChainProvider` for [`@agenticprimitives/chain-state`](../chain-state).
|
|
4
|
+
|
|
5
|
+
`chain-state` is pure — its resilient `ChainAuthorityReader` takes *injected* providers. This package is
|
|
6
|
+
the concrete provider: it performs the authority `eth_call`s (via viem) and reports the block each read was
|
|
7
|
+
pinned to, so every answer carries evidence. `readContract` / `getCode` / `getBlock` only — never
|
|
8
|
+
`eth_getLogs` ([ADR-0012](../../docs/architecture/decisions/0012-no-eth-getlogs-in-product-read-paths.md)).
|
|
9
|
+
|
|
10
|
+
It mirrors the exact reads `delegation/token.ts` performs, so the chain-state port is behavior-equivalent
|
|
11
|
+
when the verify path is rewired through it (spec 289 §5).
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { createChainAuthorityReader } from '@agenticprimitives/chain-state';
|
|
17
|
+
import { createViemChainProvider } from '@agenticprimitives/chain-state-viem';
|
|
18
|
+
|
|
19
|
+
const reader = createChainAuthorityReader({
|
|
20
|
+
chainId: 8453,
|
|
21
|
+
providers: [
|
|
22
|
+
createViemChainProvider({ source: 'alchemy', rpcUrl: rpcA, delegationManager, universalSignatureValidator }),
|
|
23
|
+
createViemChainProvider({ source: 'infura', rpcUrl: rpcB, delegationManager, universalSignatureValidator }),
|
|
24
|
+
],
|
|
25
|
+
revocationFreshnessMs: 12_000,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const { revoked, evidence } = await reader.isDelegationRevoked(delegationHash);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The reads:
|
|
32
|
+
- `readRevoked` → `DelegationManager.isRevoked(bytes32)`
|
|
33
|
+
- `readSignatureValid` → connection-agnostic: EOA → local ECDSA recover; contract → `UniversalSignatureValidator.isValidSig` (ERC-1271 / ERC-6492)
|
|
34
|
+
- `readSessionAccepted` → `isAcceptedSessionDelegation(bytes32)` on the principal account
|
|
35
|
+
|
|
36
|
+
The viem client is injectable (`client`) for tests; otherwise it's built from `rpcUrl`.
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const PACKAGE_NAME: "@agenticprimitives/chain-state-viem";
|
|
2
|
+
export declare const PACKAGE_STATUS: "w1-adapter";
|
|
3
|
+
export declare const SPEC_REF: "specs/289-chain-state-authority-port.md";
|
|
4
|
+
export { createViemChainProvider } from './provider.js';
|
|
5
|
+
export type { ViemPublicClientLike, CreateViemChainProviderOpts } from './provider.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,EAAG,qCAA8C,CAAC;AAC3E,eAAO,MAAM,cAAc,EAAG,YAAqB,CAAC;AACpD,eAAO,MAAM,QAAQ,EAAG,yCAAkD,CAAC;AAE3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,YAAY,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @agenticprimitives/chain-state-viem — viem adapter for the chain-state port.
|
|
2
|
+
// See ../../specs/289-chain-state-authority-port.md.
|
|
3
|
+
export const PACKAGE_NAME = '@agenticprimitives/chain-state-viem';
|
|
4
|
+
export const PACKAGE_STATUS = 'w1-adapter';
|
|
5
|
+
export const SPEC_REF = 'specs/289-chain-state-authority-port.md';
|
|
6
|
+
export { createViemChainProvider } from './provider.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,qDAAqD;AAErD,MAAM,CAAC,MAAM,YAAY,GAAG,qCAA8C,CAAC;AAC3E,MAAM,CAAC,MAAM,cAAc,GAAG,YAAqB,CAAC;AACpD,MAAM,CAAC,MAAM,QAAQ,GAAG,yCAAkD,CAAC;AAE3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Address, type Hex } from 'viem';
|
|
2
|
+
import type { ChainProvider } from '@agenticprimitives/chain-state';
|
|
3
|
+
/** The slice of a viem public client this provider needs (so tests inject a fake). */
|
|
4
|
+
export interface ViemPublicClientLike {
|
|
5
|
+
getBlock(args?: {
|
|
6
|
+
blockTag?: 'latest';
|
|
7
|
+
}): Promise<{
|
|
8
|
+
number: bigint;
|
|
9
|
+
hash: Hex;
|
|
10
|
+
}>;
|
|
11
|
+
getCode(args: {
|
|
12
|
+
address: Address;
|
|
13
|
+
}): Promise<Hex | undefined>;
|
|
14
|
+
readContract(args: unknown): Promise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface CreateViemChainProviderOpts {
|
|
17
|
+
/** Provider id → goes into ChainAuthorityEvidence.source. */
|
|
18
|
+
source: string;
|
|
19
|
+
delegationManager: Address;
|
|
20
|
+
universalSignatureValidator: Address;
|
|
21
|
+
/** Build a client from this RPC URL when `client` is not injected. */
|
|
22
|
+
rpcUrl?: string;
|
|
23
|
+
/** Inject a client (tests / custom transports). */
|
|
24
|
+
client?: ViemPublicClientLike;
|
|
25
|
+
}
|
|
26
|
+
export declare function createViemChainProvider(opts: CreateViemChainProviderOpts): ChainProvider;
|
|
27
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAWA,OAAO,EAA4B,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AACxE,OAAO,KAAK,EACV,aAAa,EAId,MAAM,gCAAgC,CAAC;AAcxC,sFAAsF;AACtF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;IACjF,OAAO,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC,CAAC;IAC9D,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,2BAA2B;IAC1C,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,OAAO,CAAC;IAC3B,2BAA2B,EAAE,OAAO,CAAC;IACrC,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,2BAA2B,GAAG,aAAa,CA8DxF"}
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// viem-backed ChainProvider for chain-state (spec 289). The concrete adapter the
|
|
2
|
+
// resilient ChainAuthorityReader wraps: each read does ONE `readContract`-
|
|
3
|
+
// equivalent `eth_call`, pinned to a block, and reports the block (for evidence).
|
|
4
|
+
// No log scans — `readContract`/`getCode`/`getBlock` only (ADR-0012).
|
|
5
|
+
//
|
|
6
|
+
// Mirrors the exact reads `delegation/token.ts` performs, so the chain-state port
|
|
7
|
+
// is behavior-equivalent when the verify path is rewired through it (spec 289 §5):
|
|
8
|
+
// - isRevoked(bytes32) on the DelegationManager
|
|
9
|
+
// - connection-agnostic signature validation (EOA ECDSA / ERC-1271 / ERC-6492)
|
|
10
|
+
// - isAcceptedSessionDelegation(bytes32) on the principal account
|
|
11
|
+
import { createPublicClient, http } from 'viem';
|
|
12
|
+
const IS_REVOKED_ABI = [
|
|
13
|
+
{ type: 'function', name: 'isRevoked', stateMutability: 'view', inputs: [{ name: 'delegationHash', type: 'bytes32' }], outputs: [{ type: 'bool' }] },
|
|
14
|
+
];
|
|
15
|
+
const UNIVERSAL_SIG_VALIDATOR_ABI = [
|
|
16
|
+
{ type: 'function', name: 'isValidSig', stateMutability: 'view', inputs: [{ name: 'signer', type: 'address' }, { name: 'hash', type: 'bytes32' }, { name: 'sig', type: 'bytes' }], outputs: [{ name: '', type: 'bool' }] },
|
|
17
|
+
];
|
|
18
|
+
const ACCEPTED_SESSION_DELEGATION_ABI = [
|
|
19
|
+
{ type: 'function', name: 'isAcceptedSessionDelegation', stateMutability: 'view', inputs: [{ name: 'sessionDelegationHash', type: 'bytes32' }], outputs: [{ name: '', type: 'bool' }] },
|
|
20
|
+
];
|
|
21
|
+
export function createViemChainProvider(opts) {
|
|
22
|
+
const client = opts.client ??
|
|
23
|
+
createPublicClient({ transport: http(opts.rpcUrl) });
|
|
24
|
+
// Pin a block so the read + its evidence agree.
|
|
25
|
+
const pinned = async (read) => {
|
|
26
|
+
const block = await client.getBlock({ blockTag: 'latest' });
|
|
27
|
+
const value = await read(block.number);
|
|
28
|
+
return { value, blockNumber: block.number, blockHash: block.hash };
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
source: opts.source,
|
|
32
|
+
readRevoked(hash) {
|
|
33
|
+
return pinned(async (blockNumber) => (await client.readContract({
|
|
34
|
+
address: opts.delegationManager,
|
|
35
|
+
abi: IS_REVOKED_ABI,
|
|
36
|
+
functionName: 'isRevoked',
|
|
37
|
+
args: [hash],
|
|
38
|
+
blockNumber,
|
|
39
|
+
})));
|
|
40
|
+
},
|
|
41
|
+
readSignatureValid(input) {
|
|
42
|
+
return pinned(async (blockNumber) => {
|
|
43
|
+
// ONE block-pinned observation of BOTH facts (spec 289 §5 W3):
|
|
44
|
+
// - `valid` ALWAYS through the UniversalSignatureValidator — the same surface
|
|
45
|
+
// token.ts uses. `isValidSig` is connection-agnostic: ECDSA fallback for an
|
|
46
|
+
// EOA, ERC-1271 for a deployed SA, ERC-6492 for a COUNTERFACTUAL SA. We do
|
|
47
|
+
// NOT branch validity on bytecode (the old getCode-branch wrongly rejected
|
|
48
|
+
// undeployed 6492 signers by routing them to local ECDSA).
|
|
49
|
+
// - `deployed` = signer has bytecode, surfaced as a FACT for the consumer's
|
|
50
|
+
// `requireDeployed` policy (delegation/token.ts) — the provider never decides it.
|
|
51
|
+
const code = await client.getCode({ address: input.signer });
|
|
52
|
+
const deployed = !!code && code !== '0x' && code.length > 2;
|
|
53
|
+
const valid = (await client.readContract({
|
|
54
|
+
address: opts.universalSignatureValidator,
|
|
55
|
+
abi: UNIVERSAL_SIG_VALIDATOR_ABI,
|
|
56
|
+
functionName: 'isValidSig',
|
|
57
|
+
args: [input.signer, input.digest, input.signature],
|
|
58
|
+
blockNumber,
|
|
59
|
+
}));
|
|
60
|
+
return { valid, deployed };
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
readSessionAccepted(principal, hash) {
|
|
64
|
+
return pinned(async (blockNumber) => (await client.readContract({
|
|
65
|
+
address: principal,
|
|
66
|
+
abi: ACCEPTED_SESSION_DELEGATION_ABI,
|
|
67
|
+
functionName: 'isAcceptedSessionDelegation',
|
|
68
|
+
args: [hash],
|
|
69
|
+
blockNumber,
|
|
70
|
+
})));
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,2EAA2E;AAC3E,kFAAk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G,CAAC,CAAC;gBAC5D,MAAM,KAAK,GAAG,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC;oBACvC,OAAO,EAAE,IAAI,CAAC,2BAA2B;oBACzC,GAAG,EAAE,2BAA2B;oBAChC,YAAY,EAAE,YAAY;oBAC1B,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC;oBACnD,WAAW;iBACZ,CAAC,CAAY,CAAC;gBACf,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;YAC7B,CAAC,CAAC,CAAC;QACL,CAAC;QAED,mBAAmB,CAAC,SAAkB,EAAE,IAAS;YAC/C,OAAO,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,CAClC,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC;gBACzB,OAAO,EAAE,SAAS;gBAClB,GAAG,EAAE,+BAA+B;gBACpC,YAAY,EAAE,6BAA6B;gBAC3C,IAAI,EAAE,CAAC,IAAI,CAAC;gBACZ,WAAW;aACZ,CAAC,CAAY,CACf,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agenticprimitives/chain-state-viem",
|
|
3
|
+
"version": "0.0.0-alpha.1",
|
|
4
|
+
"description": "viem-backed ChainProvider adapter for @agenticprimitives/chain-state: readContract-only isRevoked / connection-agnostic signature validation / isAcceptedSessionDelegation reads, pinned to a block for evidence.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/agentictrustlabs/agenticprimitives.git",
|
|
9
|
+
"directory": "packages/chain-state-viem"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/agentictrustlabs/agenticprimitives/tree/master/packages/chain-state-viem",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/agentictrustlabs/agenticprimitives/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"LICENSE",
|
|
26
|
+
"dist",
|
|
27
|
+
"spec.md",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"viem": "^2.52.2",
|
|
35
|
+
"@agenticprimitives/chain-state": "0.0.0-alpha.1"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"viem": "^2.52.2",
|
|
39
|
+
"vitest": "^4.1.8",
|
|
40
|
+
"@agenticprimitives/chain-state": "0.0.0-alpha.1"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"agentic",
|
|
44
|
+
"primitives",
|
|
45
|
+
"chain",
|
|
46
|
+
"viem",
|
|
47
|
+
"adapter"
|
|
48
|
+
],
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc -p tsconfig.build.json",
|
|
51
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
52
|
+
"test": "vitest run",
|
|
53
|
+
"test:unit": "vitest run test/unit --passWithNoTests",
|
|
54
|
+
"test:watch": "vitest",
|
|
55
|
+
"clean": "rm -rf dist"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/spec.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @agenticprimitives/chain-state-viem — spec
|
|
2
|
+
|
|
3
|
+
The full design lives in
|
|
4
|
+
[`../../specs/289-chain-state-authority-port.md`](../../specs/289-chain-state-authority-port.md), backed by
|
|
5
|
+
[ADR-0042](../../docs/architecture/decisions/0042-chain-state-is-the-chain-read-authority-port.md).
|
|
6
|
+
|
|
7
|
+
This package is the viem-backed `ChainProvider` adapter for [`chain-state`](../chain-state). chain-state's
|
|
8
|
+
core is pure (injected providers + the resilience layer); this provides the concrete authority reads:
|
|
9
|
+
`DelegationManager.isRevoked`, connection-agnostic signature validation (EOA local ECDSA / contract
|
|
10
|
+
`UniversalSignatureValidator` ERC-1271/6492), and `isAcceptedSessionDelegation` on the principal account.
|
|
11
|
+
Each read is pinned to a block so the wrapping reader can attach `ChainAuthorityEvidence`. `readContract` /
|
|
12
|
+
`getCode` / `getBlock` only — never `eth_getLogs` (ADR-0012; `eth_getLogs` is a forbidden term).
|
|
13
|
+
|
|
14
|
+
It mirrors the exact reads `delegation/token.ts` performs today, so the verify path is behavior-equivalent
|
|
15
|
+
when rewired through the chain-state port (spec 289 §5). The viem client is injectable so the provider is
|
|
16
|
+
unit-testable without a chain. Imports `chain-state` (types) + `viem`; it never imports the authority/
|
|
17
|
+
transport packages (no back-edge into delegation/mcp-runtime).
|
|
18
|
+
|
|
19
|
+
Status: `w1-adapter` — the three reads + block-pinned evidence + the connection-agnostic signature path.
|
|
20
|
+
Later: the spec 289 §5 rewire that routes `delegation/token.ts`'s read sites + spec 287's ERC-1271 path
|
|
21
|
+
through `chain-state` using this provider (a core-auth change tracked as its own wave).
|