@telaro/sacp 1.0.1 → 1.0.3
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/dist/agreement.d.ts +70 -0
- package/dist/agreement.d.ts.map +1 -0
- package/dist/agreement.js +122 -0
- package/dist/agreement.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/jury.d.ts +83 -0
- package/dist/jury.d.ts.map +1 -0
- package/dist/jury.js +142 -0
- package/dist/jury.js.map +1 -0
- package/package.json +41 -29
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client for `sacp_agreement` — the on-chain Proof-of-Agreement memo
|
|
3
|
+
* program. Phase 8b Step 1 surface.
|
|
4
|
+
*
|
|
5
|
+
* - `deriveAgreementPda(jobId)` — deterministic PDA lookup.
|
|
6
|
+
* - `buildPostAgreementIx(...)` — single-IX builder for buyer +
|
|
7
|
+
* provider to co-sign before any payment moves.
|
|
8
|
+
* - `fetchAgreement(conn, jobId)` — read + decode a posted PDA.
|
|
9
|
+
*
|
|
10
|
+
* Mirrors the conventions in `./validation.ts` so a sACP integrator
|
|
11
|
+
* can wire this in the same way they wire the validator IXs.
|
|
12
|
+
*/
|
|
13
|
+
import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
14
|
+
export declare const SACP_AGREEMENT_PROGRAM_ID: PublicKey;
|
|
15
|
+
export declare const SEED_AGREEMENT: Buffer<ArrayBuffer>;
|
|
16
|
+
export declare const MAX_SPEC_URI_LEN = 256;
|
|
17
|
+
/**
|
|
18
|
+
* Derive the PDA that holds a job's agreement memo. The seed pair is
|
|
19
|
+
* fixed by the program (`["agreement", job_id]`) so any consumer
|
|
20
|
+
* (gateway, web UI, dispute panel) can look the memo up without an
|
|
21
|
+
* indexer.
|
|
22
|
+
*/
|
|
23
|
+
export declare function deriveAgreementPda(jobId: Uint8Array): [PublicKey, number];
|
|
24
|
+
export interface PostAgreementParams {
|
|
25
|
+
buyer: PublicKey;
|
|
26
|
+
provider: PublicKey;
|
|
27
|
+
jobId: Uint8Array;
|
|
28
|
+
/** SHA-256 of the sample request, or 32 zeros if no sample committed. */
|
|
29
|
+
sampleRequestHash: Uint8Array;
|
|
30
|
+
/** SHA-256 of the sample deliverable, or 32 zeros if no sample committed. */
|
|
31
|
+
sampleDeliverableHash: Uint8Array;
|
|
32
|
+
/** Off-chain URL of the human-readable spec. ≤ 256 bytes. */
|
|
33
|
+
specUri: string;
|
|
34
|
+
/** Bond size the provider commits to post, in atoms. */
|
|
35
|
+
bondAtoms: bigint;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build the `post_agreement` instruction. Both buyer and provider
|
|
39
|
+
* must sign the resulting transaction — the program rejects anything
|
|
40
|
+
* else, since a one-sided memo would let either party lock in terms
|
|
41
|
+
* the other never saw.
|
|
42
|
+
*/
|
|
43
|
+
export declare function buildPostAgreementIx(params: PostAgreementParams): TransactionInstruction;
|
|
44
|
+
export interface FetchedAgreement {
|
|
45
|
+
buyer: PublicKey;
|
|
46
|
+
provider: PublicKey;
|
|
47
|
+
jobId: Uint8Array;
|
|
48
|
+
sampleRequestHash: Uint8Array;
|
|
49
|
+
sampleDeliverableHash: Uint8Array;
|
|
50
|
+
specUri: string;
|
|
51
|
+
bondAtoms: bigint;
|
|
52
|
+
signedAt: bigint;
|
|
53
|
+
bump: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Read + decode a previously posted agreement. Returns null when the
|
|
57
|
+
* PDA doesn't exist yet (i.e. the parties haven't signed). Throws if
|
|
58
|
+
* the account exists but isn't a well-formed `Agreement`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function fetchAgreement(conn: Connection, jobId: Uint8Array): Promise<FetchedAgreement | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Layout (matches programs/sacp_agreement/src/lib.rs):
|
|
63
|
+
* discriminator (8) +
|
|
64
|
+
* buyer (32) + provider (32) + job_id (32) +
|
|
65
|
+
* sample_request_hash (32) + sample_deliverable_hash (32) +
|
|
66
|
+
* spec_uri (4-byte len + utf8) +
|
|
67
|
+
* bond_atoms (8, u64 LE) + signed_at (8, i64 LE) + bump (1)
|
|
68
|
+
*/
|
|
69
|
+
export declare function parseAgreementFromBuffer(data: Buffer): FetchedAgreement;
|
|
70
|
+
//# sourceMappingURL=agreement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agreement.d.ts","sourceRoot":"","sources":["../src/agreement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,UAAU,EACV,SAAS,EAET,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AAQzB,eAAO,MAAM,yBAAyB,WAErC,CAAC;AAEF,eAAO,MAAM,cAAc,qBAA2B,CAAC;AACvD,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAQzE;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,EAAE,UAAU,CAAC;IAClB,yEAAyE;IACzE,iBAAiB,EAAE,UAAU,CAAC;IAC9B,6EAA6E;IAC7E,qBAAqB,EAAE,UAAU,CAAC;IAClC,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,mBAAmB,GAC1B,sBAAsB,CA6BxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,EAAE,UAAU,CAAC;IAClB,iBAAiB,EAAE,UAAU,CAAC;IAC9B,qBAAqB,EAAE,UAAU,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAKlC;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CA8CvE"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client for `sacp_agreement` — the on-chain Proof-of-Agreement memo
|
|
3
|
+
* program. Phase 8b Step 1 surface.
|
|
4
|
+
*
|
|
5
|
+
* - `deriveAgreementPda(jobId)` — deterministic PDA lookup.
|
|
6
|
+
* - `buildPostAgreementIx(...)` — single-IX builder for buyer +
|
|
7
|
+
* provider to co-sign before any payment moves.
|
|
8
|
+
* - `fetchAgreement(conn, jobId)` — read + decode a posted PDA.
|
|
9
|
+
*
|
|
10
|
+
* Mirrors the conventions in `./validation.ts` so a sACP integrator
|
|
11
|
+
* can wire this in the same way they wire the validator IXs.
|
|
12
|
+
*/
|
|
13
|
+
import { PublicKey, SystemProgram, TransactionInstruction, } from "@solana/web3.js";
|
|
14
|
+
import { encodeBytes32, encodeInstruction, encodeString, encodeU64, } from "./codec.js";
|
|
15
|
+
export const SACP_AGREEMENT_PROGRAM_ID = new PublicKey("2tp9TSMeuDyK117VvW3t2hJwfLLBMgZX8h4NCUsBLtvU");
|
|
16
|
+
export const SEED_AGREEMENT = Buffer.from("agreement");
|
|
17
|
+
export const MAX_SPEC_URI_LEN = 256;
|
|
18
|
+
/**
|
|
19
|
+
* Derive the PDA that holds a job's agreement memo. The seed pair is
|
|
20
|
+
* fixed by the program (`["agreement", job_id]`) so any consumer
|
|
21
|
+
* (gateway, web UI, dispute panel) can look the memo up without an
|
|
22
|
+
* indexer.
|
|
23
|
+
*/
|
|
24
|
+
export function deriveAgreementPda(jobId) {
|
|
25
|
+
if (jobId.length !== 32) {
|
|
26
|
+
throw new Error(`jobId must be 32 bytes, got ${jobId.length}`);
|
|
27
|
+
}
|
|
28
|
+
return PublicKey.findProgramAddressSync([SEED_AGREEMENT, Buffer.from(jobId)], SACP_AGREEMENT_PROGRAM_ID);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Build the `post_agreement` instruction. Both buyer and provider
|
|
32
|
+
* must sign the resulting transaction — the program rejects anything
|
|
33
|
+
* else, since a one-sided memo would let either party lock in terms
|
|
34
|
+
* the other never saw.
|
|
35
|
+
*/
|
|
36
|
+
export function buildPostAgreementIx(params) {
|
|
37
|
+
if (params.specUri.length === 0 || params.specUri.length > MAX_SPEC_URI_LEN) {
|
|
38
|
+
throw new Error(`specUri must be 1..${MAX_SPEC_URI_LEN} bytes, got ${params.specUri.length}`);
|
|
39
|
+
}
|
|
40
|
+
if (params.bondAtoms <= 0n) {
|
|
41
|
+
throw new Error("bondAtoms must be greater than zero");
|
|
42
|
+
}
|
|
43
|
+
const [agreementPda] = deriveAgreementPda(params.jobId);
|
|
44
|
+
const data = encodeInstruction("post_agreement", encodeBytes32(params.jobId), encodeBytes32(params.sampleRequestHash), encodeBytes32(params.sampleDeliverableHash), encodeString(params.specUri), encodeU64(params.bondAtoms));
|
|
45
|
+
return new TransactionInstruction({
|
|
46
|
+
programId: SACP_AGREEMENT_PROGRAM_ID,
|
|
47
|
+
keys: [
|
|
48
|
+
{ pubkey: params.buyer, isSigner: true, isWritable: true },
|
|
49
|
+
{ pubkey: params.provider, isSigner: true, isWritable: false },
|
|
50
|
+
{ pubkey: agreementPda, isSigner: false, isWritable: true },
|
|
51
|
+
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
52
|
+
],
|
|
53
|
+
data,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Read + decode a previously posted agreement. Returns null when the
|
|
58
|
+
* PDA doesn't exist yet (i.e. the parties haven't signed). Throws if
|
|
59
|
+
* the account exists but isn't a well-formed `Agreement`.
|
|
60
|
+
*/
|
|
61
|
+
export async function fetchAgreement(conn, jobId) {
|
|
62
|
+
const [pda] = deriveAgreementPda(jobId);
|
|
63
|
+
const info = await conn.getAccountInfo(pda, "confirmed");
|
|
64
|
+
if (!info)
|
|
65
|
+
return null;
|
|
66
|
+
return parseAgreementFromBuffer(info.data);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Layout (matches programs/sacp_agreement/src/lib.rs):
|
|
70
|
+
* discriminator (8) +
|
|
71
|
+
* buyer (32) + provider (32) + job_id (32) +
|
|
72
|
+
* sample_request_hash (32) + sample_deliverable_hash (32) +
|
|
73
|
+
* spec_uri (4-byte len + utf8) +
|
|
74
|
+
* bond_atoms (8, u64 LE) + signed_at (8, i64 LE) + bump (1)
|
|
75
|
+
*/
|
|
76
|
+
export function parseAgreementFromBuffer(data) {
|
|
77
|
+
let offset = 8; // skip Anchor discriminator
|
|
78
|
+
const readPubkey = () => {
|
|
79
|
+
const v = new PublicKey(data.subarray(offset, offset + 32));
|
|
80
|
+
offset += 32;
|
|
81
|
+
return v;
|
|
82
|
+
};
|
|
83
|
+
const readBytes32 = () => {
|
|
84
|
+
const v = new Uint8Array(data.subarray(offset, offset + 32));
|
|
85
|
+
offset += 32;
|
|
86
|
+
return v;
|
|
87
|
+
};
|
|
88
|
+
const readString = () => {
|
|
89
|
+
const len = data.readUInt32LE(offset);
|
|
90
|
+
offset += 4;
|
|
91
|
+
const v = data.subarray(offset, offset + len).toString("utf8");
|
|
92
|
+
offset += len;
|
|
93
|
+
return v;
|
|
94
|
+
};
|
|
95
|
+
const readU64 = () => {
|
|
96
|
+
const v = data.readBigUInt64LE(offset);
|
|
97
|
+
offset += 8;
|
|
98
|
+
return v;
|
|
99
|
+
};
|
|
100
|
+
const readI64 = () => {
|
|
101
|
+
const v = data.readBigInt64LE(offset);
|
|
102
|
+
offset += 8;
|
|
103
|
+
return v;
|
|
104
|
+
};
|
|
105
|
+
const readU8 = () => {
|
|
106
|
+
const v = data.readUInt8(offset);
|
|
107
|
+
offset += 1;
|
|
108
|
+
return v;
|
|
109
|
+
};
|
|
110
|
+
return {
|
|
111
|
+
buyer: readPubkey(),
|
|
112
|
+
provider: readPubkey(),
|
|
113
|
+
jobId: readBytes32(),
|
|
114
|
+
sampleRequestHash: readBytes32(),
|
|
115
|
+
sampleDeliverableHash: readBytes32(),
|
|
116
|
+
specUri: readString(),
|
|
117
|
+
bondAtoms: readU64(),
|
|
118
|
+
signedAt: readI64(),
|
|
119
|
+
bump: readU8(),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=agreement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agreement.js","sourceRoot":"","sources":["../src/agreement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAEL,SAAS,EACT,aAAa,EACb,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,SAAS,CACpD,8CAA8C,CAC/C,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAiB;IAClD,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,+BAA+B,KAAK,CAAC,MAAM,EAAE,CAAC,CA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CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC/D,MAAM,IAAI,GAAG,CAAC;QACd,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;IACF,MAAM,OAAO,GAAG,GAAW,EAAE;QAC3B,MAAM,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACvC,MAAM,IAAI,CAAC,CAAC;QACZ,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;IACF,MAAM,OAAO,GAAG,GAAW,EAAE;QAC3B,MAAM,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QACtC,MAAM,IAAI,CAAC,CAAC;QACZ,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;IACF,MAAM,MAAM,GAAG,GAAW,EAAE;QAC1B,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACjC,MAAM,IAAI,CAAC,CAAC;QACZ,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;IAEF,OAAO;QACL,KAAK,EAAE,UAAU,EAAE;QACnB,QAAQ,EAAE,UAAU,EAAE;QACtB,KAAK,EAAE,WAAW,EAAE;QACpB,iBAAiB,EAAE,WAAW,EAAE;QAChC,qBAAqB,EAAE,WAAW,EAAE;QACpC,OAAO,EAAE,UAAU,EAAE;QACrB,SAAS,EAAE,OAAO,EAAE;QACpB,QAAQ,EAAE,OAAO,EAAE;QACnB,IAAI,EAAE,MAAM,EAAE;KACf,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ export * as lst from "./lst.js";
|
|
|
25
25
|
export * as takeRate from "./take_rate.js";
|
|
26
26
|
export * as offering from "./offering.js";
|
|
27
27
|
export * as negotiation from "./negotiation.js";
|
|
28
|
+
export * as agreement from "./agreement.js";
|
|
29
|
+
export * as jury from "./jury.js";
|
|
28
30
|
export { SacpClient, JobSession, type JobActors, type JobSnapshot, type JobAction, type SacpClientConfig, } from "./runtime.js";
|
|
29
31
|
export { LocalSigner, RemoteSigner, WalletAdapterSigner, type SacpSigner, type RemoteSignTransport, type BrowserWalletAdapter, } from "./signer.js";
|
|
30
32
|
export { ProviderRuntime, EvaluatorRuntime, type ProviderRuntimeOptions, type EvaluatorRuntimeOptions, type WatcherCallbackContext, } from "./watcher.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,WAAW,MAAM,k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CHANGED
|
@@ -25,6 +25,8 @@ export * as lst from "./lst.js";
|
|
|
25
25
|
export * as takeRate from "./take_rate.js";
|
|
26
26
|
export * as offering from "./offering.js";
|
|
27
27
|
export * as negotiation from "./negotiation.js";
|
|
28
|
+
export * as agreement from "./agreement.js";
|
|
29
|
+
export * as jury from "./jury.js";
|
|
28
30
|
// v0.8 runtime layer — high-level client + session.
|
|
29
31
|
export { SacpClient, JobSession, } from "./runtime.js";
|
|
30
32
|
export { LocalSigner, RemoteSigner, WalletAdapterSigner, } from "./signer.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,oDAAoD;AACpD,OAAO,EACL,UAAU,EACV,UAAU,GAKX,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,WAAW,EACX,YAAY,EACZ,mBAAmB,GAIpB,MAAM,aAAa,CAAC;AAErB,8CAA8C;AAC9C,OAAO,EACL,eAAe,EACf,gBAAgB,GAIjB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,sBAAsB,GAIvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,cAAc,GAEf,MAAM,cAAc,CAAC;AAEtB,8CAA8C;AAC9C,OAAO,EACL,oBAAoB,EACpB,kBAAkB,GAEnB,MAAM,cAAc,CAAC;AAMtB,OAAO,EACL,eAAe,EACf,0BAA0B,EAC1B,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,kBAAkB,GACnB,MAAM,WAAW,CAAC"}
|
package/dist/jury.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client for `sacp_jury` — VRF-seeded jury draw program (Phase 8b
|
|
3
|
+
* Step 4).
|
|
4
|
+
*
|
|
5
|
+
* - `deriveJuryPda(jobIdHash)` — PDA lookup, deterministic from the
|
|
6
|
+
* sha256(jobId) bytes that buyer + provider both produce.
|
|
7
|
+
* - `buildOpenJuryIx(...)` — opens the Jury account before any
|
|
8
|
+
* panel draw runs.
|
|
9
|
+
* - `buildSealPanelIx(...)` — dev / test path. Caller supplies the
|
|
10
|
+
* candidate list and a mock 32-byte seed.
|
|
11
|
+
* - `buildSealPanelFromRandomnessIx(...)` — production path. Pass a
|
|
12
|
+
* Switchboard On-Demand `Randomness` account; the program reads
|
|
13
|
+
* its `result_buffer` directly.
|
|
14
|
+
* - `fetchJury` / `parseJuryFromBuffer` — read + decode the sealed
|
|
15
|
+
* panel for downstream consumers (e.g. evaluator UI).
|
|
16
|
+
*/
|
|
17
|
+
import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
18
|
+
export declare const SACP_JURY_PROGRAM_ID: PublicKey;
|
|
19
|
+
/**
|
|
20
|
+
* Switchboard On-Demand program id used by `seal_panel_from_randomness`.
|
|
21
|
+
* Same value baked into `programs/sacp_jury/src/lib.rs`. Exported so
|
|
22
|
+
* the client can derive Randomness PDAs without re-importing the
|
|
23
|
+
* Switchboard SDK.
|
|
24
|
+
*/
|
|
25
|
+
export declare const SWITCHBOARD_ON_DEMAND_PROGRAM_ID: PublicKey;
|
|
26
|
+
export declare const SEED_JURY: Buffer<ArrayBuffer>;
|
|
27
|
+
export declare const MAX_PANEL_SIZE = 9;
|
|
28
|
+
export declare const MAX_CANDIDATES = 64;
|
|
29
|
+
/** Derive the Jury PDA for a 32-byte jobId hash. */
|
|
30
|
+
export declare function deriveJuryPda(jobIdHash: Uint8Array): [PublicKey, number];
|
|
31
|
+
export interface OpenJuryParams {
|
|
32
|
+
caller: PublicKey;
|
|
33
|
+
jobIdHash: Uint8Array;
|
|
34
|
+
panelSize: number;
|
|
35
|
+
}
|
|
36
|
+
export declare function buildOpenJuryIx(params: OpenJuryParams): TransactionInstruction;
|
|
37
|
+
export interface CandidateInput {
|
|
38
|
+
authority: PublicKey;
|
|
39
|
+
stakeAtoms: bigint;
|
|
40
|
+
}
|
|
41
|
+
export interface SealPanelParams {
|
|
42
|
+
cranker: PublicKey;
|
|
43
|
+
jury: PublicKey;
|
|
44
|
+
candidates: ReadonlyArray<CandidateInput>;
|
|
45
|
+
mockSeed: Uint8Array;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Dev / test path. Use this when you want a deterministic draw for a
|
|
49
|
+
* smoke test or local fixture. Production path is
|
|
50
|
+
* `buildSealPanelFromRandomnessIx`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function buildSealPanelIx(params: SealPanelParams): TransactionInstruction;
|
|
53
|
+
export interface SealPanelFromRandomnessParams {
|
|
54
|
+
cranker: PublicKey;
|
|
55
|
+
jury: PublicKey;
|
|
56
|
+
candidates: ReadonlyArray<CandidateInput>;
|
|
57
|
+
/** Switchboard On-Demand `Randomness` account that's been revealed. */
|
|
58
|
+
randomness: PublicKey;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Production path. The program reads the `result_buffer` from the
|
|
62
|
+
* Switchboard account directly — caller is responsible for having
|
|
63
|
+
* already triggered the Switchboard request + reveal flow before
|
|
64
|
+
* cranking this IX. Pre-reveal calls fail with
|
|
65
|
+
* `RandomnessNotResolved`.
|
|
66
|
+
*/
|
|
67
|
+
export declare function buildSealPanelFromRandomnessIx(params: SealPanelFromRandomnessParams): TransactionInstruction;
|
|
68
|
+
export interface FetchedJury {
|
|
69
|
+
jobIdHash: Uint8Array;
|
|
70
|
+
panelSize: number;
|
|
71
|
+
sealed: boolean;
|
|
72
|
+
seedUsed: Uint8Array;
|
|
73
|
+
panel: PublicKey[];
|
|
74
|
+
bump: number;
|
|
75
|
+
}
|
|
76
|
+
export declare function fetchJury(conn: Connection, jobIdHash: Uint8Array): Promise<FetchedJury | null>;
|
|
77
|
+
/**
|
|
78
|
+
* Layout (must match programs/sacp_jury/src/lib.rs Jury):
|
|
79
|
+
* 8 disc + 32 jobId + 1 panel_size + 1 sealed +
|
|
80
|
+
* 32 seed_used + 4 panel_len + 32 * panel_len + 1 bump.
|
|
81
|
+
*/
|
|
82
|
+
export declare function parseJuryFromBuffer(data: Buffer): FetchedJury;
|
|
83
|
+
//# sourceMappingURL=jury.d.ts.map
|
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ED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,6BAA6B,GACpC,sBAAsB,CAcxB;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,UAAU,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,UAAU,CAAC;IACrB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,SAAS,CAC7B,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,UAAU,GACpB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAK7B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAiC7D"}
|
package/dist/jury.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client for `sacp_jury` — VRF-seeded jury draw program (Phase 8b
|
|
3
|
+
* Step 4).
|
|
4
|
+
*
|
|
5
|
+
* - `deriveJuryPda(jobIdHash)` — PDA lookup, deterministic from the
|
|
6
|
+
* sha256(jobId) bytes that buyer + provider both produce.
|
|
7
|
+
* - `buildOpenJuryIx(...)` — opens the Jury account before any
|
|
8
|
+
* panel draw runs.
|
|
9
|
+
* - `buildSealPanelIx(...)` — dev / test path. Caller supplies the
|
|
10
|
+
* candidate list and a mock 32-byte seed.
|
|
11
|
+
* - `buildSealPanelFromRandomnessIx(...)` — production path. Pass a
|
|
12
|
+
* Switchboard On-Demand `Randomness` account; the program reads
|
|
13
|
+
* its `result_buffer` directly.
|
|
14
|
+
* - `fetchJury` / `parseJuryFromBuffer` — read + decode the sealed
|
|
15
|
+
* panel for downstream consumers (e.g. evaluator UI).
|
|
16
|
+
*/
|
|
17
|
+
import { PublicKey, SystemProgram, TransactionInstruction, } from "@solana/web3.js";
|
|
18
|
+
import { encodeBytes32, encodeInstruction, encodeU8, encodeU64, } from "./codec.js";
|
|
19
|
+
export const SACP_JURY_PROGRAM_ID = new PublicKey("9tLdTxzEFKqqi9tK7DcRhoJ5HzWaxUzgqXnyjUZfM5i7");
|
|
20
|
+
/**
|
|
21
|
+
* Switchboard On-Demand program id used by `seal_panel_from_randomness`.
|
|
22
|
+
* Same value baked into `programs/sacp_jury/src/lib.rs`. Exported so
|
|
23
|
+
* the client can derive Randomness PDAs without re-importing the
|
|
24
|
+
* Switchboard SDK.
|
|
25
|
+
*/
|
|
26
|
+
export const SWITCHBOARD_ON_DEMAND_PROGRAM_ID = new PublicKey("SBondMDrcV3K4kxZR1HNVT7osZxAHVHgYXL5Ze1oMUv");
|
|
27
|
+
export const SEED_JURY = Buffer.from("jury");
|
|
28
|
+
export const MAX_PANEL_SIZE = 9;
|
|
29
|
+
export const MAX_CANDIDATES = 64;
|
|
30
|
+
/** Derive the Jury PDA for a 32-byte jobId hash. */
|
|
31
|
+
export function deriveJuryPda(jobIdHash) {
|
|
32
|
+
if (jobIdHash.length !== 32) {
|
|
33
|
+
throw new Error(`jobIdHash must be 32 bytes, got ${jobIdHash.length}`);
|
|
34
|
+
}
|
|
35
|
+
return PublicKey.findProgramAddressSync([SEED_JURY, Buffer.from(jobIdHash)], SACP_JURY_PROGRAM_ID);
|
|
36
|
+
}
|
|
37
|
+
export function buildOpenJuryIx(params) {
|
|
38
|
+
if (params.panelSize < 1 || params.panelSize > MAX_PANEL_SIZE) {
|
|
39
|
+
throw new Error(`panelSize must be 1..${MAX_PANEL_SIZE}, got ${params.panelSize}`);
|
|
40
|
+
}
|
|
41
|
+
const [jury] = deriveJuryPda(params.jobIdHash);
|
|
42
|
+
const data = encodeInstruction("open_jury", encodeBytes32(params.jobIdHash), encodeU8(params.panelSize));
|
|
43
|
+
return new TransactionInstruction({
|
|
44
|
+
programId: SACP_JURY_PROGRAM_ID,
|
|
45
|
+
keys: [
|
|
46
|
+
{ pubkey: params.caller, isSigner: true, isWritable: true },
|
|
47
|
+
{ pubkey: jury, isSigner: false, isWritable: true },
|
|
48
|
+
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
49
|
+
],
|
|
50
|
+
data,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function encodeCandidates(list) {
|
|
54
|
+
if (list.length > MAX_CANDIDATES) {
|
|
55
|
+
throw new Error(`candidate list exceeds MAX_CANDIDATES=${MAX_CANDIDATES}, got ${list.length}`);
|
|
56
|
+
}
|
|
57
|
+
const len = Buffer.alloc(4);
|
|
58
|
+
len.writeUInt32LE(list.length);
|
|
59
|
+
const parts = list.map((c) => Buffer.concat([c.authority.toBuffer(), encodeU64(c.stakeAtoms)]));
|
|
60
|
+
return Buffer.concat([len, ...parts]);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Dev / test path. Use this when you want a deterministic draw for a
|
|
64
|
+
* smoke test or local fixture. Production path is
|
|
65
|
+
* `buildSealPanelFromRandomnessIx`.
|
|
66
|
+
*/
|
|
67
|
+
export function buildSealPanelIx(params) {
|
|
68
|
+
const data = encodeInstruction("seal_panel", encodeCandidates(params.candidates), encodeBytes32(params.mockSeed));
|
|
69
|
+
return new TransactionInstruction({
|
|
70
|
+
programId: SACP_JURY_PROGRAM_ID,
|
|
71
|
+
keys: [
|
|
72
|
+
{ pubkey: params.jury, isSigner: false, isWritable: true },
|
|
73
|
+
{ pubkey: params.cranker, isSigner: true, isWritable: false },
|
|
74
|
+
],
|
|
75
|
+
data,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Production path. The program reads the `result_buffer` from the
|
|
80
|
+
* Switchboard account directly — caller is responsible for having
|
|
81
|
+
* already triggered the Switchboard request + reveal flow before
|
|
82
|
+
* cranking this IX. Pre-reveal calls fail with
|
|
83
|
+
* `RandomnessNotResolved`.
|
|
84
|
+
*/
|
|
85
|
+
export function buildSealPanelFromRandomnessIx(params) {
|
|
86
|
+
const data = encodeInstruction("seal_panel_from_randomness", encodeCandidates(params.candidates));
|
|
87
|
+
return new TransactionInstruction({
|
|
88
|
+
programId: SACP_JURY_PROGRAM_ID,
|
|
89
|
+
keys: [
|
|
90
|
+
{ pubkey: params.jury, isSigner: false, isWritable: true },
|
|
91
|
+
{ pubkey: params.cranker, isSigner: true, isWritable: false },
|
|
92
|
+
{ pubkey: params.randomness, isSigner: false, isWritable: false },
|
|
93
|
+
],
|
|
94
|
+
data,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
export async function fetchJury(conn, jobIdHash) {
|
|
98
|
+
const [pda] = deriveJuryPda(jobIdHash);
|
|
99
|
+
const info = await conn.getAccountInfo(pda, "confirmed");
|
|
100
|
+
if (!info)
|
|
101
|
+
return null;
|
|
102
|
+
return parseJuryFromBuffer(info.data);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Layout (must match programs/sacp_jury/src/lib.rs Jury):
|
|
106
|
+
* 8 disc + 32 jobId + 1 panel_size + 1 sealed +
|
|
107
|
+
* 32 seed_used + 4 panel_len + 32 * panel_len + 1 bump.
|
|
108
|
+
*/
|
|
109
|
+
export function parseJuryFromBuffer(data) {
|
|
110
|
+
let offset = 8;
|
|
111
|
+
const readBytes32 = () => {
|
|
112
|
+
const v = new Uint8Array(data.subarray(offset, offset + 32));
|
|
113
|
+
offset += 32;
|
|
114
|
+
return v;
|
|
115
|
+
};
|
|
116
|
+
const readU8 = () => {
|
|
117
|
+
const v = data.readUInt8(offset);
|
|
118
|
+
offset += 1;
|
|
119
|
+
return v;
|
|
120
|
+
};
|
|
121
|
+
const readU32 = () => {
|
|
122
|
+
const v = data.readUInt32LE(offset);
|
|
123
|
+
offset += 4;
|
|
124
|
+
return v;
|
|
125
|
+
};
|
|
126
|
+
const readPubkey = () => {
|
|
127
|
+
const v = new PublicKey(data.subarray(offset, offset + 32));
|
|
128
|
+
offset += 32;
|
|
129
|
+
return v;
|
|
130
|
+
};
|
|
131
|
+
const jobIdHash = readBytes32();
|
|
132
|
+
const panelSize = readU8();
|
|
133
|
+
const sealed = readU8() === 1;
|
|
134
|
+
const seedUsed = readBytes32();
|
|
135
|
+
const panelLen = readU32();
|
|
136
|
+
const panel = [];
|
|
137
|
+
for (let i = 0; i < panelLen; i++)
|
|
138
|
+
panel.push(readPubkey());
|
|
139
|
+
const bump = readU8();
|
|
140
|
+
return { jobIdHash, panelSize, sealed, seedUsed, panel, bump };
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=jury.js.map
|
package/dist/jury.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jury.js","sourceRoot":"","sources":["../src/jury.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAEL,SAAS,EACT,aAAa,EACb,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,SAAS,CAC/C,8CAA8C,CAC/C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,IAAI,SAAS,CAC3D,6CAA6C,CAC9C,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAChC,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAEjC,oDAAoD;AACpD,MAAM,UAAU,aAAa,CAAC,SAAqB;IACjD,IAAI,SAAS,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,mCAAmC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,SAAS,CAAC,sBAAsB,CACrC,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAC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CAAC,MAAM,EAAE,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;QAC5D,MAAM,IAAI,EAAE,CAAC;QACb,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;IAEF,MAAM,SAAS,GAAG,WAAW,EAAE,CAAC;IAChC,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC;IAC3B,MAAM,MAAM,GAAG,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9B,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,MAAM,QAAQ,GAAG,OAAO,EAAE,CAAC;IAC3B,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE;QAAE,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAC5D,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC;IAEtB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACjE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telaro/sacp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Solana Agent Commerce Protocol (sACP) — TypeScript SDK. Job lifecycle escrow + bonded validator registry on Solana, ERC-8183 compatible. Reference implementation by Telaro Protocol.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -62,6 +62,14 @@
|
|
|
62
62
|
"./negotiation": {
|
|
63
63
|
"types": "./dist/negotiation.d.ts",
|
|
64
64
|
"import": "./dist/negotiation.js"
|
|
65
|
+
},
|
|
66
|
+
"./agreement": {
|
|
67
|
+
"types": "./dist/agreement.d.ts",
|
|
68
|
+
"import": "./dist/agreement.js"
|
|
69
|
+
},
|
|
70
|
+
"./jury": {
|
|
71
|
+
"types": "./dist/jury.d.ts",
|
|
72
|
+
"import": "./dist/jury.js"
|
|
65
73
|
}
|
|
66
74
|
},
|
|
67
75
|
"files": [
|
|
@@ -69,33 +77,9 @@
|
|
|
69
77
|
"README.md",
|
|
70
78
|
"INTEGRATION.md"
|
|
71
79
|
],
|
|
72
|
-
"scripts": {
|
|
73
|
-
"build": "tsc -p tsconfig.json",
|
|
74
|
-
"typecheck": "tsc --noEmit",
|
|
75
|
-
"clean": "rm -rf dist",
|
|
76
|
-
"prepublishOnly": "pnpm clean && pnpm build",
|
|
77
|
-
"smoke": "tsx tests/devnet-smoke.ts",
|
|
78
|
-
"smoke:validation": "tsx tests/devnet-validation.ts",
|
|
79
|
-
"smoke:dispute": "tsx tests/devnet-dispute.ts",
|
|
80
|
-
"smoke:reclaim": "tsx tests/devnet-reclaim.ts",
|
|
81
|
-
"smoke:all": "tsx tests/devnet-smoke.ts && tsx tests/devnet-dispute.ts && tsx tests/devnet-reclaim.ts && tsx tests/devnet-validation.ts",
|
|
82
|
-
"smoke:bonded": "tsx tests/devnet-bonded-evaluator.ts",
|
|
83
|
-
"smoke:negative": "tsx tests/devnet-negative.ts",
|
|
84
|
-
"smoke:wormhole": "tsx tests/devnet-wormhole.ts",
|
|
85
|
-
"smoke:jitosol": "tsx tests/devnet-jitosol.ts",
|
|
86
|
-
"smoke:wormhole-reclaim": "tsx tests/devnet-wormhole-reclaim.ts",
|
|
87
|
-
"smoke:take-rate": "tsx tests/devnet-take-rate.ts",
|
|
88
|
-
"smoke:runtime": "tsx tests/devnet-runtime.ts",
|
|
89
|
-
"smoke:v09": "tsx tests/devnet-v09.ts",
|
|
90
|
-
"smoke:v09-phase56": "tsx tests/devnet-v09-phase56.ts",
|
|
91
|
-
"smoke:phase7": "tsx tests/devnet-phase7.ts",
|
|
92
|
-
"smoke:phase8": "tsx tests/devnet-phase8.ts",
|
|
93
|
-
"smoke:phantom": "tsx tests/devnet-phantom.ts",
|
|
94
|
-
"smoke:x402": "tsx tests/devnet-x402.ts",
|
|
95
|
-
"smoke:mcp-server": "tsx tests/devnet-mcp-server.ts"
|
|
96
|
-
},
|
|
97
80
|
"dependencies": {
|
|
98
81
|
"@solana/web3.js": "^1.95.0",
|
|
82
|
+
"@solana/spl-token": "^0.4.0",
|
|
99
83
|
"@coral-xyz/anchor": "^0.31.0",
|
|
100
84
|
"@noble/hashes": "^1.5.0"
|
|
101
85
|
},
|
|
@@ -105,7 +89,6 @@
|
|
|
105
89
|
"typescript": "^5.5.0",
|
|
106
90
|
"tsx": "^4.16.0",
|
|
107
91
|
"express": "^4.21.0",
|
|
108
|
-
"@solana/spl-token": "^0.4.0",
|
|
109
92
|
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
110
93
|
},
|
|
111
94
|
"publishConfig": {
|
|
@@ -135,5 +118,34 @@
|
|
|
135
118
|
"telaro",
|
|
136
119
|
"validation-registry"
|
|
137
120
|
],
|
|
138
|
-
"type": "module"
|
|
139
|
-
|
|
121
|
+
"type": "module",
|
|
122
|
+
"scripts": {
|
|
123
|
+
"build": "tsc -p tsconfig.json",
|
|
124
|
+
"typecheck": "tsc --noEmit",
|
|
125
|
+
"clean": "rm -rf dist",
|
|
126
|
+
"smoke": "tsx tests/devnet-smoke.ts",
|
|
127
|
+
"smoke:validation": "tsx tests/devnet-validation.ts",
|
|
128
|
+
"smoke:dispute": "tsx tests/devnet-dispute.ts",
|
|
129
|
+
"smoke:reclaim": "tsx tests/devnet-reclaim.ts",
|
|
130
|
+
"smoke:all": "tsx tests/devnet-smoke.ts && tsx tests/devnet-dispute.ts && tsx tests/devnet-reclaim.ts && tsx tests/devnet-validation.ts",
|
|
131
|
+
"smoke:bonded": "tsx tests/devnet-bonded-evaluator.ts",
|
|
132
|
+
"smoke:negative": "tsx tests/devnet-negative.ts",
|
|
133
|
+
"smoke:wormhole": "tsx tests/devnet-wormhole.ts",
|
|
134
|
+
"smoke:jitosol": "tsx tests/devnet-jitosol.ts",
|
|
135
|
+
"smoke:wormhole-reclaim": "tsx tests/devnet-wormhole-reclaim.ts",
|
|
136
|
+
"smoke:take-rate": "tsx tests/devnet-take-rate.ts",
|
|
137
|
+
"smoke:runtime": "tsx tests/devnet-runtime.ts",
|
|
138
|
+
"smoke:v09": "tsx tests/devnet-v09.ts",
|
|
139
|
+
"smoke:v09-phase56": "tsx tests/devnet-v09-phase56.ts",
|
|
140
|
+
"smoke:phase7": "tsx tests/devnet-phase7.ts",
|
|
141
|
+
"smoke:phase8": "tsx tests/devnet-phase8.ts",
|
|
142
|
+
"smoke:agreement": "tsx tests/devnet-agreement.ts",
|
|
143
|
+
"smoke:phase8b": "tsx tests/devnet-phase8b.ts",
|
|
144
|
+
"smoke:jury-verdict": "tsx tests/devnet-jury-verdict.ts",
|
|
145
|
+
"smoke:resolver-routing": "tsx tests/devnet-resolver-routing.ts",
|
|
146
|
+
"smoke:jury-sdk": "tsx tests/devnet-jury-sdk.ts",
|
|
147
|
+
"smoke:phantom": "tsx tests/devnet-phantom.ts",
|
|
148
|
+
"smoke:x402": "tsx tests/devnet-x402.ts",
|
|
149
|
+
"smoke:mcp-server": "tsx tests/devnet-mcp-server.ts"
|
|
150
|
+
}
|
|
151
|
+
}
|