Migrate agent-registry from v1 to v2 (audited, Conway-compliant)

Repoint REGISTRY_SCRIPT_CBOR + REGISTRY_POLICY_ID from
5dd5118943d5aa7329696181252a6565a27dbf2c6de92b02a6aae361 (v1) to
be1a0a2912da180757ed3cd61b56bb8eab0188c19dc3c0e3912d2c01 (v2),
deployed to Vector mainnet via TX
3c53fa482245a82f88a39e90191a90cce3b6f09f6e28613bc53d35a0c3ba8587.

v2 enforces indefinite-length CBOR (D8 79 9F ... FF) for the
OutputReference inside the asset-name derivation, matching Aiken's
builtin.serialise_data() on Conway. Lucid's Data.to(new Constr(...))
emits definite-length arrays (D8 79 82 ...), so deriveNftAssetName is
hand-rolled from cborUint + cborBytes primitives. Verified byte-for-byte
against pycardano OutputReference.to_cbor() and agent-sdk-py
plutus_serialise_data across 5 test vectors (see new
test/derive-asset-name.test.ts).

governance.ts: AGENT_REGISTRY_POLICY env-fallback updated to v2.

Datum/redeemer schemas are unchanged between v1 and v2 — no other
tx-building changes required.

Follow-up: agent-sdk-ts at /home/david/code/agent-sdk-ts still ships
v1 constants and the pre-Conway Lucid asset-name derivation; needs the
same migration before consumers can use v2 from that SDK.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
david
2026-04-15 18:49:53 +02:00
parent 7a335f21fc
commit bda3c30747
3 changed files with 87 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

@@ -20,7 +20,7 @@ const VECTOR_KOIOS_URL = process.env.VECTOR_KOIOS_URL || 'https://koios.vector.t
const VECTOR_EXPLORER_URL = process.env.VECTOR_EXPLORER_URL || 'https://vector.testnet.apexscan.org';
// Agent Registry policy ID (shared across all modules)
const AGENT_REGISTRY_POLICY = process.env.AGENT_REGISTRY_POLICY || '5dd5118943d5aa7329696181252a6565a27dbf2c6de92b02a6aae361';
const AGENT_REGISTRY_POLICY = process.env.AGENT_REGISTRY_POLICY || 'be1a0a2912da180757ed3cd61b56bb8eab0188c19dc3c0e3912d2c01';
// Governance contract hashes (from deploy_state.json)
// These should be set via env vars in production

View File

@@ -0,0 +1,43 @@
import { describe, test } from 'node:test';
import assert from 'node:assert/strict';
import { deriveNftAssetName } from '../src/vector/agent-network.ts';
// Parity vectors — verified against pycardano OutputReference.to_cbor() and
// agent-sdk-py plutus_serialise_data(0, [tx_hash_bytes, idx]). All three
// implementations produce identical bytes for the v2 contract on Conway.
// See plan file for the verification run output.
const VECTORS: Array<{ tx: string; idx: number; expected: string }> = [
{
tx: '00'.repeat(32),
idx: 0,
expected: 'a2e5e227858e84f1a8f9b0c1246e6cbc9336d707d43ba43d0e1cb7c51c45f4c9',
},
{
tx: '2703182e4d1151a32b7bcfc2362c91278bcac66a49a840d217ae5cb49f8b3649',
idx: 0,
expected: '24ed834d88890ce35e81a6b9c4f988fad3d8a0284db6f3e641416f44f5e95d75',
},
{
tx: 'ff'.repeat(32),
idx: 23,
expected: 'df229a221c5a84f48c06d5b28a98deb6ea678c369ab166400e88dd3d2bdc7b9f',
},
{
tx: 'ab'.repeat(32),
idx: 24,
expected: '3ddd07517205dd8a745887c33a09da0e4a5d63dca1f151ceeedaeeda0551c52b',
},
{
tx: '01'.repeat(32),
idx: 256,
expected: 'e626a305779e4c1e74b7719d302d0fbc1b722ab33bd52da4c23e6b8cd1bd04ec',
},
];
describe('deriveNftAssetName — Conway indefinite-CBOR parity', () => {
for (const { tx, idx, expected } of VECTORS) {
test(`tx=${tx.slice(0, 8)}… idx=${idx}`, () => {
assert.equal(deriveNftAssetName(tx, idx), expected);
});
}
});