@provian/mcp 1.2.2 → 1.3.0
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/CHANGELOG.md +7 -3
- package/README.md +1 -1
- package/dist/core/egress-guard.d.ts +39 -0
- package/dist/core/egress-guard.d.ts.map +1 -0
- package/dist/core/egress-guard.js +303 -0
- package/dist/core/egress-guard.js.map +1 -0
- package/dist/core/guarded-fetch.d.ts +46 -0
- package/dist/core/guarded-fetch.d.ts.map +1 -0
- package/dist/core/guarded-fetch.js +236 -0
- package/dist/core/guarded-fetch.js.map +1 -0
- package/dist/core/pinned-agent.d.ts +61 -0
- package/dist/core/pinned-agent.d.ts.map +1 -0
- package/dist/core/pinned-agent.js +125 -0
- package/dist/core/pinned-agent.js.map +1 -0
- package/dist/core/pinned-connection.d.ts +15 -0
- package/dist/core/pinned-connection.d.ts.map +1 -0
- package/dist/core/pinned-connection.js +172 -0
- package/dist/core/pinned-connection.js.map +1 -0
- package/dist/core/protocol-pointer-pin.generated.d.ts +6 -0
- package/dist/core/protocol-pointer-pin.generated.d.ts.map +1 -0
- package/dist/core/protocol-pointer-pin.generated.js +6 -0
- package/dist/core/protocol-pointer-pin.generated.js.map +1 -0
- package/dist/core/protocol-pointer.d.ts +25 -0
- package/dist/core/protocol-pointer.d.ts.map +1 -0
- package/dist/core/protocol-pointer.js +132 -0
- package/dist/core/protocol-pointer.js.map +1 -0
- package/dist/core/protocol-runtime.d.ts +4 -0
- package/dist/core/protocol-runtime.d.ts.map +1 -0
- package/dist/core/protocol-runtime.js +31 -0
- package/dist/core/protocol-runtime.js.map +1 -0
- package/dist/core/tools.d.ts +1 -14
- package/dist/core/tools.d.ts.map +1 -1
- package/dist/core/tools.js +35 -56
- package/dist/core/tools.js.map +1 -1
- package/package.json +5 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pinned-connection.js","sourceRoot":"","sources":["../../src/core/pinned-connection.ts"],"names":[],"mappings":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AE;YAC/C,IAAI,QAAQ,CAAC,UAAU,KAAK,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBAAC,MAAM,CAAC,IAAI,KAAK,CAAC,6BAA6B,CAAC,EAAE,IAAI,CAAC,CAAC;gBAAC,OAAO;YAAC,CAAC;YACrI,qFAAqF;YACrF,qDAAqD;YACrD,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YAClD,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ;gBAAE,MAAM,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,IAAA,eAAI,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;;gBAClI,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-pointer-pin.generated.d.ts","sourceRoot":"","sources":["../../src/core/protocol-pointer-pin.generated.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAA6K,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PROTOCOL_POINTER_PIN = void 0;
|
|
4
|
+
// Generated from config/protocol-pointer.json; never a current-contract address fallback.
|
|
5
|
+
exports.PROTOCOL_POINTER_PIN = Object.freeze({ "chainId": 8453, "address": "0x619eae740ce56c5a8edbb2b047e58369281ddad7", "runtimeHash": "0x2648893ab83577f448cee74590d37439ffb8f8e6703ef6c72c176d9b50a4f0a7" });
|
|
6
|
+
//# sourceMappingURL=protocol-pointer-pin.generated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-pointer-pin.generated.js","sourceRoot":"","sources":["../../src/core/protocol-pointer-pin.generated.ts"],"names":[],"mappings":";;;AAAA,0FAA0F;AAC7E,QAAA,oBAAoB,GAAoF,MAAM,CAAC,MAAM,CAAC,EAAC,SAAS,EAAC,IAAI,EAAC,SAAS,EAAC,4CAA4C,EAAC,aAAa,EAAC,oEAAoE,EAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const PROTOCOL_COMPONENTS: readonly ["kernel", "eligibilityVerifier", "beneficiaryVerifier", "escrow", "promises", "projectPool", "bonds", "court", "recoursePool", "settlement"];
|
|
2
|
+
export type ProtocolComponent = typeof PROTOCOL_COMPONENTS[number];
|
|
3
|
+
export interface PointerRpc {
|
|
4
|
+
request(method: string, params: readonly unknown[]): Promise<unknown>;
|
|
5
|
+
}
|
|
6
|
+
export interface ProtocolDeployment {
|
|
7
|
+
readonly pointer: string;
|
|
8
|
+
readonly revision: bigint;
|
|
9
|
+
readonly manifestHash: string;
|
|
10
|
+
readonly blockHash: string;
|
|
11
|
+
readonly addresses: Readonly<Record<ProtocolComponent, string>>;
|
|
12
|
+
readonly runtimeHashes: readonly string[];
|
|
13
|
+
}
|
|
14
|
+
/** Checks only protocol retirement; it imposes no restriction on ordinary
|
|
15
|
+
* recipients or an agent's spending choices. The caller must freshly resolve
|
|
16
|
+
* the deployment and recheck its manifest before signing. */
|
|
17
|
+
export declare function assertNoRetiredProtocolAddresses(rpcs: readonly [PointerRpc, PointerRpc], deployment: ProtocolDeployment, addresses: readonly string[]): Promise<void>;
|
|
18
|
+
/** No relay response, deployment-file fallback or cached address can authorize a transaction.
|
|
19
|
+
* Callers supply two independently operated chain transports and the permanent pointer pin. */
|
|
20
|
+
export declare function resolveProtocolDeployment(rpcs: readonly [PointerRpc, PointerRpc], pointer: string, pointerRuntimeHash: string, minimumRevision?: bigint): Promise<ProtocolDeployment>;
|
|
21
|
+
/** Historical end-of-block evidence only; never authorizes a new operation.
|
|
22
|
+
* Callers verify finality separately and account for publication log order when
|
|
23
|
+
* a receipt and a pointer change occur within the same block. */
|
|
24
|
+
export declare function resolveHistoricalProtocolDeployment(rpcs: readonly [PointerRpc, PointerRpc], pointer: string, pointerRuntimeHash: string, block: number, blockHash: string): Promise<ProtocolDeployment>;
|
|
25
|
+
//# sourceMappingURL=protocol-pointer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-pointer.d.ts","sourceRoot":"","sources":["../../src/core/protocol-pointer.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,wJACqD,CAAC;AACtF,MAAM,MAAM,iBAAiB,GAAG,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;AACnE,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACvE;AACD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,CAAC;IAChE,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C;AAUD;;6DAE6D;AAC7D,wBAAsB,gCAAgC,CAAC,IAAI,EAAE,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC,EAC5F,UAAU,EAAE,kBAAkB,EAAE,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAM7E;AAkBD;+FAC+F;AAC/F,wBAAsB,yBAAyB,CAAC,IAAI,EAAE,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC,EACrF,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,eAAe,SAAK,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAEhG;AACD;;iEAEiE;AACjE,wBAAsB,mCAAmC,CAAC,IAAI,EAAE,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC,EAC/F,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAG5G"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PROTOCOL_COMPONENTS = void 0;
|
|
4
|
+
exports.assertNoRetiredProtocolAddresses = assertNoRetiredProtocolAddresses;
|
|
5
|
+
exports.resolveProtocolDeployment = resolveProtocolDeployment;
|
|
6
|
+
exports.resolveHistoricalProtocolDeployment = resolveHistoricalProtocolDeployment;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
exports.PROTOCOL_COMPONENTS = ['kernel', 'eligibilityVerifier', 'beneficiaryVerifier', 'escrow',
|
|
9
|
+
'promises', 'projectPool', 'bonds', 'court', 'recoursePool', 'settlement'];
|
|
10
|
+
const iface = new ethers_1.Interface([
|
|
11
|
+
'function current() view returns (uint256,bytes32,address[10],bytes32[10])',
|
|
12
|
+
'function requireCurrent(uint256,uint256,address) view',
|
|
13
|
+
'function retired(address) view returns(bool)',
|
|
14
|
+
]);
|
|
15
|
+
function hex(value) {
|
|
16
|
+
if (typeof value !== 'string' || !/^0x(?:[0-9a-fA-F]{2})*$/.test(value))
|
|
17
|
+
throw new Error('protocol_pointer_invalid_rpc');
|
|
18
|
+
return value.toLowerCase();
|
|
19
|
+
}
|
|
20
|
+
/** Checks only protocol retirement; it imposes no restriction on ordinary
|
|
21
|
+
* recipients or an agent's spending choices. The caller must freshly resolve
|
|
22
|
+
* the deployment and recheck its manifest before signing. */
|
|
23
|
+
async function assertNoRetiredProtocolAddresses(rpcs, deployment, addresses) {
|
|
24
|
+
for (const address of new Set(addresses.map(ethers_1.getAddress))) {
|
|
25
|
+
const encoded = await agreement(rpcs, 'eth_call', [{ to: deployment.pointer,
|
|
26
|
+
data: iface.encodeFunctionData('retired', [address]) }, { blockHash: deployment.blockHash, requireCanonical: true }]);
|
|
27
|
+
if (iface.decodeFunctionResult('retired', hex(encoded))[0] !== false)
|
|
28
|
+
throw new Error('protocol_contract_retired');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function quantity(value) {
|
|
32
|
+
if (typeof value !== 'string' || !/^0x[0-9a-fA-F]+$/.test(value))
|
|
33
|
+
throw new Error('protocol_pointer_invalid_rpc');
|
|
34
|
+
return BigInt(value);
|
|
35
|
+
}
|
|
36
|
+
function normalized(value) {
|
|
37
|
+
if (Array.isArray(value))
|
|
38
|
+
return value.map(normalized);
|
|
39
|
+
if (value && typeof value === 'object') {
|
|
40
|
+
const record = value;
|
|
41
|
+
return Object.fromEntries(Object.keys(record).sort().map(key => [key, normalized(record[key])]));
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
async function agreement(rpcs, method, params) {
|
|
46
|
+
const values = await Promise.all(rpcs.map(rpc => rpc.request(method, params)));
|
|
47
|
+
if (JSON.stringify(normalized(values[0])) !== JSON.stringify(normalized(values[1])))
|
|
48
|
+
throw new Error('protocol_pointer_rpc_disagreement');
|
|
49
|
+
return values[0];
|
|
50
|
+
}
|
|
51
|
+
/** No relay response, deployment-file fallback or cached address can authorize a transaction.
|
|
52
|
+
* Callers supply two independently operated chain transports and the permanent pointer pin. */
|
|
53
|
+
async function resolveProtocolDeployment(rpcs, pointer, pointerRuntimeHash, minimumRevision = 0n) {
|
|
54
|
+
return resolveDeployment(rpcs, pointer, pointerRuntimeHash, minimumRevision);
|
|
55
|
+
}
|
|
56
|
+
/** Historical end-of-block evidence only; never authorizes a new operation.
|
|
57
|
+
* Callers verify finality separately and account for publication log order when
|
|
58
|
+
* a receipt and a pointer change occur within the same block. */
|
|
59
|
+
async function resolveHistoricalProtocolDeployment(rpcs, pointer, pointerRuntimeHash, block, blockHash) {
|
|
60
|
+
if (!Number.isSafeInteger(block) || block < 0 || !/^0x[0-9a-f]{64}$/.test(blockHash))
|
|
61
|
+
throw Error('protocol_pointer_invalid_block');
|
|
62
|
+
return resolveDeployment(rpcs, pointer, pointerRuntimeHash, 0n, { height: BigInt(block), hash: blockHash });
|
|
63
|
+
}
|
|
64
|
+
async function resolveDeployment(rpcs, pointer, pointerRuntimeHash, minimumRevision, historical) {
|
|
65
|
+
pointer = (0, ethers_1.getAddress)(pointer);
|
|
66
|
+
if (quantity(await agreement(rpcs, 'eth_chainId', [])) !== 8453n)
|
|
67
|
+
throw new Error('protocol_pointer_wrong_chain');
|
|
68
|
+
const heights = historical ? [historical.height, historical.height]
|
|
69
|
+
: await Promise.all(rpcs.map(async (rpc) => quantity(await rpc.request('eth_blockNumber', []))));
|
|
70
|
+
const height = heights[0] < heights[1] ? heights[0] : heights[1];
|
|
71
|
+
const block = await agreement(rpcs, 'eth_getBlockByNumber', [`0x${height.toString(16)}`, false]);
|
|
72
|
+
if (!block || typeof block !== 'object' || !('hash' in block) || !('number' in block)
|
|
73
|
+
|| quantity(block.number) !== height)
|
|
74
|
+
throw new Error('protocol_pointer_invalid_block');
|
|
75
|
+
const blockHash = hex(block.hash);
|
|
76
|
+
if (blockHash.length !== 66 || (historical && blockHash !== historical.hash))
|
|
77
|
+
throw new Error('protocol_pointer_invalid_block');
|
|
78
|
+
const pin = { blockHash, requireCanonical: true };
|
|
79
|
+
const code = hex(await agreement(rpcs, 'eth_getCode', [pointer, pin]));
|
|
80
|
+
if (code === '0x' || (0, ethers_1.keccak256)(code) !== pointerRuntimeHash.toLowerCase())
|
|
81
|
+
throw new Error('protocol_pointer_runtime_mismatch');
|
|
82
|
+
const data = iface.encodeFunctionData('current');
|
|
83
|
+
const encoded = hex(await agreement(rpcs, 'eth_call', [{ to: pointer, data }, pin]));
|
|
84
|
+
const decoded = iface.decodeFunctionResult('current', encoded);
|
|
85
|
+
const revision = BigInt(decoded[0]);
|
|
86
|
+
if (revision === 0n || revision < minimumRevision)
|
|
87
|
+
throw new Error('protocol_pointer_rollback');
|
|
88
|
+
const addresses = Array.from(decoded[2]).map(ethers_1.getAddress);
|
|
89
|
+
const hashes = Array.from(decoded[3]);
|
|
90
|
+
if (new Set(addresses).size !== exports.PROTOCOL_COMPONENTS.length)
|
|
91
|
+
throw new Error('protocol_pointer_duplicate_component');
|
|
92
|
+
const manifestHash = (0, ethers_1.keccak256)(ethers_1.AbiCoder.defaultAbiCoder().encode(['uint256', 'address', 'uint256', 'address[10]', 'bytes32[10]'], [8453, pointer, revision, addresses, hashes]));
|
|
93
|
+
if (manifestHash !== decoded[1])
|
|
94
|
+
throw new Error('protocol_pointer_manifest_mismatch');
|
|
95
|
+
await Promise.all(addresses.map(async (address, index) => {
|
|
96
|
+
if (index === 2 && address === '0x0000000000000000000000000000000000000000' && hashes[index] === `0x${'00'.repeat(32)}`)
|
|
97
|
+
return;
|
|
98
|
+
const runtime = hex(await agreement(rpcs, 'eth_getCode', [address, pin]));
|
|
99
|
+
if (runtime === '0x' || (0, ethers_1.keccak256)(runtime) !== hashes[index])
|
|
100
|
+
throw new Error('protocol_component_runtime_mismatch');
|
|
101
|
+
await agreement(rpcs, 'eth_call', [{ to: pointer,
|
|
102
|
+
data: iface.encodeFunctionData('requireCurrent', [revision, index, address]) }, pin]);
|
|
103
|
+
}));
|
|
104
|
+
// A set of authentic bytecodes can still be wired to different kernels.
|
|
105
|
+
const links = [
|
|
106
|
+
[1, 'KERNEL', 0], [3, 'pvt', 0], [4, 'pvt', 0], [5, 'pvt', 0], [6, 'pvt', 0], [7, 'pvt', 0],
|
|
107
|
+
[3, 'epochClock', 0], [4, 'epochClock', 0], [5, 'epochClock', 0], [6, 'epochClock', 0], [7, 'epochClock', 0],
|
|
108
|
+
[8, 'token', 0], [8, 'settlement', 9], [9, 'kernel', 0], [9, 'pool', 8],
|
|
109
|
+
[0, 'protocolPointer', pointer], [8, 'pointer', pointer], [9, 'pointer', pointer],
|
|
110
|
+
];
|
|
111
|
+
await Promise.all(links.map(async ([source, getter, expected]) => {
|
|
112
|
+
const binding = new ethers_1.Interface([`function ${getter}() view returns(address)`]);
|
|
113
|
+
const result = hex(await agreement(rpcs, 'eth_call', [{ to: addresses[source], data: binding.encodeFunctionData(getter) }, pin]));
|
|
114
|
+
const actual = (0, ethers_1.getAddress)(binding.decodeFunctionResult(getter, result)[0]);
|
|
115
|
+
if (actual !== (typeof expected === 'number' ? addresses[expected] : expected))
|
|
116
|
+
throw new Error('protocol_component_binding_mismatch');
|
|
117
|
+
}));
|
|
118
|
+
// Reject a newer pointer seen by either provider while the pinned read ran.
|
|
119
|
+
if (!historical) {
|
|
120
|
+
const latest = await agreement(rpcs, 'eth_call', [{ to: pointer, data }, 'latest']);
|
|
121
|
+
if (hex(latest) !== encoded)
|
|
122
|
+
throw new Error('protocol_pointer_changed');
|
|
123
|
+
}
|
|
124
|
+
const canonical = await agreement(rpcs, 'eth_getBlockByNumber', [`0x${height.toString(16)}`, false]);
|
|
125
|
+
if (!canonical || typeof canonical !== 'object' || !('hash' in canonical)
|
|
126
|
+
|| hex(canonical.hash) !== blockHash)
|
|
127
|
+
throw new Error('protocol_pointer_reorg');
|
|
128
|
+
return { pointer, revision, manifestHash, blockHash,
|
|
129
|
+
addresses: Object.fromEntries(exports.PROTOCOL_COMPONENTS.map((key, i) => [key, addresses[i]])),
|
|
130
|
+
runtimeHashes: hashes };
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=protocol-pointer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-pointer.js","sourceRoot":"","sources":["../../src/core/protocol-pointer.ts"],"names":[],"mappings":";;;AA4BA,4EAOC;AAoBD,8DAGC;AAID,kFAIC;AAlED,mCAAoE;AAEvD,QAAA,mBAAmB,GAAG,CAAC,QAAQ,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,QAAQ;IAClG,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,CAAU,CAAC;AAatF,MAAM,KAAK,GAAG,IAAI,kBAAS,CAAC;IAC1B,2EAA2E;IAC3E,uDAAuD;IACvD,8CAA8C;CAC/C,CAAC,CAAC;AACH,SAAS,GAAG,CAAC,KAAc;IACzB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACzH,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;AAC7B,CAAC;AACD;;6DAE6D;AACtD,KAAK,UAAU,gCAAgC,CAAC,IAAuC,EAC5F,UAA8B,EAAE,SAA4B;IAC5D,KAAK,MAAM,OAAO,IAAI,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,mBAAU,CAAC,CAAC,EAAE,CAAC;QACzD,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,UAAU,CAAC,OAAO;gBACzE,IAAI,EAAE,KAAK,CAAC,kBAAkB,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE,gBAA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,CAAC,CAAC,QAAQ,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzI,CAAC,CAAC,CAAC,CAAC;IACJ,4EAA4E;IAC5E,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;QACpF,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC3E,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,sBAAsB,EAAE,CAAC,KAAK,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;IACrG,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,IAAI,SAAS,CAAC;WACpE,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAClF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS;QACjD,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,2BAAmB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAsC;QAC5H,aAAa,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ProtocolDeployment } from './protocol-pointer';
|
|
2
|
+
/** Plans are independently resolved on chain. Relay credentials are never sent to RPCs. */
|
|
3
|
+
export declare function currentProtocolDeployment(): Promise<ProtocolDeployment>;
|
|
4
|
+
//# sourceMappingURL=protocol-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-runtime.d.ts","sourceRoot":"","sources":["../../src/core/protocol-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAA8C,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAazG,2FAA2F;AAC3F,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAM7E"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.currentProtocolDeployment = currentProtocolDeployment;
|
|
4
|
+
const guarded_fetch_1 = require("./guarded-fetch");
|
|
5
|
+
const protocol_pointer_pin_generated_1 = require("./protocol-pointer-pin.generated");
|
|
6
|
+
const protocol_pointer_1 = require("./protocol-pointer");
|
|
7
|
+
const endpoints = ['https://mainnet.base.org', 'https://base.drpc.org'];
|
|
8
|
+
let minimumRevision = 0n;
|
|
9
|
+
function rpc(url) {
|
|
10
|
+
return { async request(method, params) {
|
|
11
|
+
const response = await (0, guarded_fetch_1.guardedFetch)(url, { method: 'POST', headers: { 'content-type': 'application/json' },
|
|
12
|
+
body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }), signal: AbortSignal.timeout(20000) });
|
|
13
|
+
if (!response.ok)
|
|
14
|
+
throw new Error('protocol_rpc_unavailable');
|
|
15
|
+
const reply = await response.json();
|
|
16
|
+
if (!reply || typeof reply !== 'object' || 'error' in reply || !('result' in reply))
|
|
17
|
+
throw new Error('protocol_rpc_invalid');
|
|
18
|
+
return reply.result;
|
|
19
|
+
} };
|
|
20
|
+
}
|
|
21
|
+
/** Plans are independently resolved on chain. Relay credentials are never sent to RPCs. */
|
|
22
|
+
async function currentProtocolDeployment() {
|
|
23
|
+
const { address, runtimeHash } = protocol_pointer_pin_generated_1.PROTOCOL_POINTER_PIN;
|
|
24
|
+
if (!address || !runtimeHash)
|
|
25
|
+
throw new Error('protocol_pointer_not_deployed');
|
|
26
|
+
const deployment = await (0, protocol_pointer_1.resolveProtocolDeployment)([rpc(endpoints[0]), rpc(endpoints[1])], address, runtimeHash, minimumRevision);
|
|
27
|
+
if (deployment.revision > minimumRevision)
|
|
28
|
+
minimumRevision = deployment.revision;
|
|
29
|
+
return deployment;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=protocol-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-runtime.js","sourceRoot":"","sources":["../../src/core/protocol-runtime.ts"],"names":[],"mappings":";;AAgBA,8DAMC;AAtBD,mDAA+C;AAC/C,qFAAwE;AACxE,yDAAyG;AACzG,MAAM,SAAS,GAAG,CAAC,0BAA0B,EAAE,uBAAuB,CAAU,CAAC;AACjF,IAAI,eAAe,GAAG,EAAE,CAAC;AACzB,SAAS,GAAG,CAAC,GAAW;IACtB,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM;YACnC,MAAM,QAAQ,GAAG,MAAM,IAAA,4BAAY,EAAC,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBACxG,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,KAAM,CAAC,EAAE,CAAC,CAAC;YAC1G,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAC9D,MAAM,KAAK,GAAY,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC7C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;YAC7H,OAAO,KAAK,CAAC,MAAM,CAAC;QACtB,CAAC,EAAE,CAAC;AACN,CAAC;AACD,2FAA2F;AACpF,KAAK,UAAU,yBAAyB;IAC7C,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,qDAAoB,CAAC;IACtD,IAAI,CAAC,OAAO,IAAI,CAAC,WAAW;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC/E,MAAM,UAAU,GAAG,MAAM,IAAA,4CAAyB,EAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC;IAClI,IAAI,UAAU,CAAC,QAAQ,GAAG,eAAe;QAAE,eAAe,GAAG,UAAU,CAAC,QAAQ,CAAC;IACjF,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
package/dist/core/tools.d.ts
CHANGED
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
import { type PeFact } from './presentation';
|
|
63
63
|
import type { ProvianToolDef, ToolContext, ToolResult } from './types';
|
|
64
64
|
/** Version reported by both transports. Keep in sync with provian-mcp/package.json. */
|
|
65
|
-
export declare const PROVIAN_MCP_VERSION = "1.
|
|
65
|
+
export declare const PROVIAN_MCP_VERSION = "1.3.0";
|
|
66
66
|
export declare const PROVIAN_MCP_SERVER_NAME = "provian";
|
|
67
67
|
/**
|
|
68
68
|
* §5 : what an agent's work mints from — the same witnesses on every surface that
|
|
@@ -72,19 +72,6 @@ export declare const PROVIAN_MCP_SERVER_NAME = "provian";
|
|
|
72
72
|
* Capture health per device is the source of truth for which lanes are live. No tool reports the agent's own work.
|
|
73
73
|
*/
|
|
74
74
|
export declare const WHAT_EARNS_NOTE: string;
|
|
75
|
-
/**
|
|
76
|
-
* Base mainnet pins the on-chain plans sign against. Mirrors the checked-in sources of
|
|
77
|
-
* truth — ProvianEscrowV4 from contracts/deployments/base-pvt9-institutions.json, the
|
|
78
|
-
* PVT9 kernel and USDC from config/pvt9-base.json (tools.test.ts binds each to its file).
|
|
79
|
-
*/
|
|
80
|
-
export declare const COMMONS_HIRE_BASE_PINS: {
|
|
81
|
-
readonly chainId: 8453;
|
|
82
|
-
readonly escrow: "0x96560fdf49e563efcdc2d502934676dc074732d0";
|
|
83
|
-
readonly tokens: {
|
|
84
|
-
readonly pvt: "0x8811441914381143b9408c5c32247367f86f173a";
|
|
85
|
-
readonly usdc: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913";
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
75
|
/**
|
|
89
76
|
* The on-chain escrow id for a Commons hire — byte-identical to the SDK's
|
|
90
77
|
* `deriveHireOnchainEscrowId`: keccak256(abi.encode("provian.commons.hire-escrow.v1", depositor,
|
package/dist/core/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/core/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/core/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AASH,OAAO,EAQL,KAAK,MAAM,EAMZ,MAAM,gBAAgB,CAAC;AAkBxB,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,UAAU,EACX,MAAM,SAAS,CAAC;AAEjB,uFAAuF;AACvF,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAC3C,eAAO,MAAM,uBAAuB,YAAY,CAAC;AAMjD;;;;;;GAMG;AACH,eA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e,CACnC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,UAAU,CAAC,CAwBrB"}
|
package/dist/core/tools.js
CHANGED
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
* every action earns PVT, and never state or imply a fiat value for PVT.
|
|
62
62
|
*/
|
|
63
63
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
|
-
exports.PROVIAN_TOOLS = exports.OUTPUT_SIGNATURE_JSON_KEY_MCP = exports.OUTPUT_SIGNATURE_HEADER_MCP = exports.OUTPUT_SIGNATURE_MESSAGE_PREFIX_MCP = exports.WALLET_POP_SIGNING_RECIPE = exports.
|
|
64
|
+
exports.PROVIAN_TOOLS = exports.OUTPUT_SIGNATURE_JSON_KEY_MCP = exports.OUTPUT_SIGNATURE_HEADER_MCP = exports.OUTPUT_SIGNATURE_MESSAGE_PREFIX_MCP = exports.WALLET_POP_SIGNING_RECIPE = exports.WHAT_EARNS_NOTE = exports.PROVIAN_MCP_SERVER_NAME = exports.PROVIAN_MCP_VERSION = void 0;
|
|
65
65
|
exports.deriveHireOnchainEscrowId = deriveHireOnchainEscrowId;
|
|
66
66
|
exports.encodeHireCall = encodeHireCall;
|
|
67
67
|
exports.usdcToAtomic = usdcToAtomic;
|
|
@@ -70,6 +70,7 @@ exports.replyInstructionFor = replyInstructionFor;
|
|
|
70
70
|
exports.findTool = findTool;
|
|
71
71
|
exports.callProvianTool = callProvianTool;
|
|
72
72
|
const crypto_1 = require("crypto");
|
|
73
|
+
const protocol_runtime_1 = require("./protocol-runtime");
|
|
73
74
|
const crypto_2 = require("./crypto");
|
|
74
75
|
const keccak256_1 = require("./keccak256");
|
|
75
76
|
const recovery_seal_1 = require("./recovery-seal");
|
|
@@ -78,7 +79,7 @@ const presentation_1 = require("./presentation");
|
|
|
78
79
|
const disclosure_request_1 = require("./disclosure-request");
|
|
79
80
|
const challenge_1 = require("./challenge");
|
|
80
81
|
/** Version reported by both transports. Keep in sync with provian-mcp/package.json. */
|
|
81
|
-
exports.PROVIAN_MCP_VERSION = '1.
|
|
82
|
+
exports.PROVIAN_MCP_VERSION = '1.3.0';
|
|
82
83
|
exports.PROVIAN_MCP_SERVER_NAME = 'provian';
|
|
83
84
|
const ELIGIBILITY_DISCLAIMER = 'Every act of work mints PVT once at its best-supported value. The PE mints its base; ' +
|
|
84
85
|
'telemetry and independence multiply on top.';
|
|
@@ -401,14 +402,14 @@ const getAgentRecord = {
|
|
|
401
402
|
'transacting, computed from the relay\'s running totals (the relay keeps no PE; the PEs themselves live with ' +
|
|
402
403
|
'their owner): PE count and families, attestation-tier mix, chain-verified transfer/x402 summary, bond ' +
|
|
403
404
|
'status, court history, promise performance, vouches, wallet age, and linked/unlinked status. Public and ' +
|
|
404
|
-
'unauthenticated; never exposes balances, policies, or telemetry. Works with a wallet id or
|
|
405
|
-
'
|
|
405
|
+
'unauthenticated; never exposes balances, policies, or telemetry. Works with a wallet id or its published ' +
|
|
406
|
+
'native address. Private external addresses never resolve to their owner.',
|
|
406
407
|
inputSchema: {
|
|
407
408
|
type: 'object',
|
|
408
409
|
properties: {
|
|
409
410
|
agent_id: {
|
|
410
411
|
type: 'string',
|
|
411
|
-
description: 'Agent wallet id (wallet_aw_…) or
|
|
412
|
+
description: 'Agent wallet id (wallet_aw_…) or its published native Base address (0x…).',
|
|
412
413
|
},
|
|
413
414
|
},
|
|
414
415
|
required: ['agent_id'],
|
|
@@ -549,39 +550,11 @@ const getActionTypeStatus = {
|
|
|
549
550
|
return relayErrorResult('Action type status', res);
|
|
550
551
|
},
|
|
551
552
|
};
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
// directions (agent→agent, agent→person, person→person, person→agent). A hire
|
|
558
|
-
// escrows in PVT or USDC on ProvianEscrowV4 (Base), with a dispute fallback: the
|
|
559
|
-
// Provian's admin key resolves (until the Court opens); if nobody does within 30 days the payer takes the
|
|
560
|
-
// permissionless refund. Court escalation stays hidden.
|
|
561
|
-
//
|
|
562
|
-
// The on-chain legs (fund / release / dispute) are signed by the POSTER (the
|
|
563
|
-
// escrow depositor) with its OWN key. This core never signs an EVM transaction
|
|
564
|
-
// (remote /mcp holds no key material; local stdio exposes only binding
|
|
565
|
-
// signatures), so those tools are two-step, like record_burn: step "plan" returns
|
|
566
|
-
// the exact unsigned calls — each target checked against the pinned Base escrow +
|
|
567
|
-
// token contracts below, never taken blindly from the relay — and step "record"
|
|
568
|
-
// tells the relay once the calls mined. The SDK (fundCommonsJob / releaseCommonsJob
|
|
569
|
-
// / disputeCommonsJob) and CLI (provian job-fund / job-release / job-dispute) sign
|
|
570
|
-
// in-process for an agent that holds its key.
|
|
571
|
-
// ---------------------------------------------------------------------------
|
|
572
|
-
/**
|
|
573
|
-
* Base mainnet pins the on-chain plans sign against. Mirrors the checked-in sources of
|
|
574
|
-
* truth — ProvianEscrowV4 from contracts/deployments/base-pvt9-institutions.json, the
|
|
575
|
-
* PVT9 kernel and USDC from config/pvt9-base.json (tools.test.ts binds each to its file).
|
|
576
|
-
*/
|
|
577
|
-
exports.COMMONS_HIRE_BASE_PINS = {
|
|
578
|
-
chainId: 8453,
|
|
579
|
-
escrow: '0x96560fdf49e563efcdc2d502934676dc074732d0',
|
|
580
|
-
tokens: {
|
|
581
|
-
pvt: '0x8811441914381143b9408c5c32247367f86f173a',
|
|
582
|
-
usdc: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
|
|
583
|
-
},
|
|
584
|
-
};
|
|
553
|
+
function hireDeployment(deployment) {
|
|
554
|
+
return { chainId: 8453, escrow: deployment.addresses.escrow.toLowerCase(),
|
|
555
|
+
tokens: { pvt: deployment.addresses.kernel.toLowerCase(), usdc: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913' },
|
|
556
|
+
pointer: deployment.pointer, revision: deployment.revision.toString(), manifest: deployment.manifestHash };
|
|
557
|
+
}
|
|
585
558
|
/** ProvianEscrowV4 `Currency` enum (USDC = 0, PVT = 1). */
|
|
586
559
|
const ESCROW_CURRENCY_ENUM = { usdc: 0, pvt: 1 };
|
|
587
560
|
const BYTES32 = /^0x[0-9a-fA-F]{64}$/;
|
|
@@ -661,13 +634,13 @@ function lower(v) {
|
|
|
661
634
|
return typeof v === 'string' ? v.toLowerCase() : '';
|
|
662
635
|
}
|
|
663
636
|
/** Refuse unless the relay's escrow names exactly the pinned Base escrow for a known currency. */
|
|
664
|
-
function checkPinnedEscrow(e) {
|
|
637
|
+
function checkPinnedEscrow(e, pins) {
|
|
665
638
|
if (e.currency !== 'pvt' && e.currency !== 'usdc')
|
|
666
639
|
return { refusal: `unsupported escrow currency '${String(e.currency)}'` };
|
|
667
640
|
if (e.chain !== 'base')
|
|
668
641
|
return { refusal: `the escrow is on '${String(e.chain)}'; Commons hires settle on Base` };
|
|
669
|
-
if (lower(e.contract_address) !==
|
|
670
|
-
return { refusal: `the relay named escrow ${String(e.contract_address)}, not the pinned ProvianEscrowV4 ${
|
|
642
|
+
if (lower(e.contract_address) !== pins.escrow) {
|
|
643
|
+
return { refusal: `the relay named escrow ${String(e.contract_address)}, not the pinned ProvianEscrowV4 ${pins.escrow}; refusing to build calls` };
|
|
671
644
|
}
|
|
672
645
|
return { currency: e.currency };
|
|
673
646
|
}
|
|
@@ -953,13 +926,14 @@ const fundJob = {
|
|
|
953
926
|
if ('error' in read)
|
|
954
927
|
return read.error;
|
|
955
928
|
const e = read.escrow;
|
|
956
|
-
const
|
|
929
|
+
const pins = hireDeployment(await (0, protocol_runtime_1.currentProtocolDeployment)());
|
|
930
|
+
const pinned = checkPinnedEscrow(e, pins);
|
|
957
931
|
if ('refusal' in pinned)
|
|
958
932
|
return errorResult(pinned.refusal);
|
|
959
933
|
const currency = pinned.currency;
|
|
960
934
|
if (e.status !== 'created')
|
|
961
935
|
return errorResult(`the escrow is '${String(e.status)}', not 'created' — already funded or closed (record a mined funding with step="record")`);
|
|
962
|
-
const token =
|
|
936
|
+
const token = pins.tokens[currency];
|
|
963
937
|
if (lower(e.token_address) !== token)
|
|
964
938
|
return errorResult(`the relay named token ${String(e.token_address)} for a ${currency} escrow; the pinned ${currency.toUpperCase()} is ${token} — refusing`);
|
|
965
939
|
let amount;
|
|
@@ -1004,15 +978,16 @@ const fundJob = {
|
|
|
1004
978
|
currency,
|
|
1005
979
|
amount_atomic: amount.toString(),
|
|
1006
980
|
decimals: currency === 'pvt' ? 18 : 6,
|
|
1007
|
-
chain_id:
|
|
981
|
+
chain_id: pins.chainId,
|
|
982
|
+
protocol_pointer: pins.pointer, protocol_revision: pins.revision, protocol_manifest: pins.manifest,
|
|
1008
983
|
from: e.depositor_address,
|
|
1009
984
|
onchain_escrow_id: escrowId,
|
|
1010
985
|
calls: [
|
|
1011
|
-
{ label: 'createEscrow', to:
|
|
1012
|
-
{ label: 'approve', to: token, value: '0', data: encodeHireCall('approve', { spender:
|
|
1013
|
-
{ label: 'fundEscrow', to:
|
|
986
|
+
{ label: 'createEscrow', to: pins.escrow, value: '0', data: encodeHireCall('createEscrow', { escrowId, recipient: e.recipient_address, amount, autoReleaseAt, currency }) },
|
|
987
|
+
{ label: 'approve', to: token, value: '0', data: encodeHireCall('approve', { spender: pins.escrow, amount }) },
|
|
988
|
+
{ label: 'fundEscrow', to: pins.escrow, value: '0', data: encodeHireCall('fundEscrow', { escrowId }) },
|
|
1014
989
|
],
|
|
1015
|
-
next_step: `Sign and broadcast the three calls IN ORDER on Base (chain id 8453) from ${e.depositor_address}, waiting for each receipt to succeed. ` +
|
|
990
|
+
next_step: `Resolve the protocol pointer again before each signature and refuse a changed manifest or retired address. Sign and broadcast the three calls IN ORDER on Base (chain id 8453) from ${e.depositor_address}, waiting for each receipt to succeed. ` +
|
|
1016
991
|
'Then call fund_job with step="record" and tx_hash = the fundEscrow transaction hash. If createEscrow or approve reverts, nothing was ' +
|
|
1017
992
|
'escrowed; if fundEscrow reverts, revoke the approval (approve the escrow for 0). If a run stops part-way, plan again WITH THE SAME ' +
|
|
1018
993
|
'onchain_escrow_id (the default plan for this hire always names it): a createEscrow reverting EscrowAlreadyExists means it already ' +
|
|
@@ -1085,7 +1060,8 @@ const releaseJob = {
|
|
|
1085
1060
|
if ('error' in read)
|
|
1086
1061
|
return read.error;
|
|
1087
1062
|
const e = read.escrow;
|
|
1088
|
-
const
|
|
1063
|
+
const pins = hireDeployment(await (0, protocol_runtime_1.currentProtocolDeployment)());
|
|
1064
|
+
const pinned = checkPinnedEscrow(e, pins);
|
|
1089
1065
|
if ('refusal' in pinned)
|
|
1090
1066
|
return errorResult(pinned.refusal);
|
|
1091
1067
|
if (e.status !== 'funded')
|
|
@@ -1097,11 +1073,12 @@ const releaseJob = {
|
|
|
1097
1073
|
return errorResult(`only the depositor ${String(e.depositor_address)} can release before auto-release; this machine's agent is ${me}`);
|
|
1098
1074
|
return jsonResult({
|
|
1099
1075
|
job_id: jobId,
|
|
1100
|
-
chain_id:
|
|
1076
|
+
chain_id: pins.chainId,
|
|
1077
|
+
protocol_pointer: pins.pointer, protocol_revision: pins.revision, protocol_manifest: pins.manifest,
|
|
1101
1078
|
from: e.depositor_address,
|
|
1102
1079
|
onchain_escrow_id: e.onchain_escrow_id,
|
|
1103
|
-
calls: [{ label: 'releaseEscrow', to:
|
|
1104
|
-
next_step: `Sign and broadcast releaseEscrow on Base from ${String(e.depositor_address)}; once it mines call release_job with step="record".`,
|
|
1080
|
+
calls: [{ label: 'releaseEscrow', to: pins.escrow, value: '0', data: encodeHireCall('releaseEscrow', { escrowId: e.onchain_escrow_id }) }],
|
|
1081
|
+
next_step: `Resolve the protocol pointer again and refuse a changed manifest or retired address. Sign and broadcast releaseEscrow on Base from ${String(e.depositor_address)}; once it mines call release_job with step="record".`,
|
|
1105
1082
|
});
|
|
1106
1083
|
},
|
|
1107
1084
|
};
|
|
@@ -1146,7 +1123,8 @@ const disputeJob = {
|
|
|
1146
1123
|
if ('error' in read)
|
|
1147
1124
|
return read.error;
|
|
1148
1125
|
const e = read.escrow;
|
|
1149
|
-
const
|
|
1126
|
+
const pins = hireDeployment(await (0, protocol_runtime_1.currentProtocolDeployment)());
|
|
1127
|
+
const pinned = checkPinnedEscrow(e, pins);
|
|
1150
1128
|
if ('refusal' in pinned)
|
|
1151
1129
|
return errorResult(pinned.refusal);
|
|
1152
1130
|
if (e.status !== 'funded')
|
|
@@ -1160,11 +1138,12 @@ const disputeJob = {
|
|
|
1160
1138
|
return errorResult(`only the depositor ${String(e.depositor_address)} can dispute (the contract is onlyDepositor); this machine's agent is ${me}`);
|
|
1161
1139
|
return jsonResult({
|
|
1162
1140
|
job_id: jobId,
|
|
1163
|
-
chain_id:
|
|
1141
|
+
chain_id: pins.chainId,
|
|
1142
|
+
protocol_pointer: pins.pointer, protocol_revision: pins.revision, protocol_manifest: pins.manifest,
|
|
1164
1143
|
from: e.depositor_address,
|
|
1165
1144
|
onchain_escrow_id: e.onchain_escrow_id,
|
|
1166
|
-
calls: [{ label: 'disputeEscrow', to:
|
|
1167
|
-
next_step: `Sign and broadcast disputeEscrow on Base from ${String(e.depositor_address)}; once it mines call dispute_job with step="record", your reason and optional evidence.`,
|
|
1145
|
+
calls: [{ label: 'disputeEscrow', to: pins.escrow, value: '0', data: encodeHireCall('disputeEscrow', { escrowId: e.onchain_escrow_id }) }],
|
|
1146
|
+
next_step: `Resolve the protocol pointer again and refuse a changed manifest or retired address. Sign and broadcast disputeEscrow on Base from ${String(e.depositor_address)}; once it mines call dispute_job with step="record", your reason and optional evidence.`,
|
|
1168
1147
|
});
|
|
1169
1148
|
},
|
|
1170
1149
|
};
|