@occa/sdk 0.4.0 → 0.5.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 +29 -0
- package/dist/{chunk-YCSBYRSH.js → chunk-BR62YC5F.js} +17 -3
- package/dist/chunk-BR62YC5F.js.map +1 -0
- package/dist/{chunk-X6FBCGHU.js → chunk-QZSQEGLT.js} +15 -3
- package/dist/chunk-QZSQEGLT.js.map +1 -0
- package/dist/{chunk-N7LNBSDD.js → chunk-YC33EXHO.js} +82 -5
- package/dist/chunk-YC33EXHO.js.map +1 -0
- package/dist/constants.cjs +20 -2
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +13 -2
- package/dist/constants.d.ts +13 -2
- package/dist/constants.js +9 -1
- package/dist/index.cjs +109 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +17 -3
- package/dist/instructions.cjs +92 -2
- package/dist/instructions.cjs.map +1 -1
- package/dist/instructions.d.cts +66 -1
- package/dist/instructions.d.ts +66 -1
- package/dist/instructions.js +7 -3
- package/dist/pda.cjs +15 -1
- package/dist/pda.cjs.map +1 -1
- package/dist/pda.d.cts +15 -1
- package/dist/pda.d.ts +15 -1
- package/dist/pda.js +4 -2
- package/package.json +1 -1
- package/src/constants.ts +17 -1
- package/src/idl/registry.json +389 -5
- package/src/instructions.ts +149 -0
- package/src/pda.ts +25 -0
- package/dist/chunk-N7LNBSDD.js.map +0 -1
- package/dist/chunk-X6FBCGHU.js.map +0 -1
- package/dist/chunk-YCSBYRSH.js.map +0 -1
package/dist/instructions.d.ts
CHANGED
|
@@ -12,7 +12,9 @@ declare const INSTRUCTION_DISCRIMINATOR: {
|
|
|
12
12
|
readonly updateDeploymentStatus: Buffer<ArrayBuffer>;
|
|
13
13
|
readonly retireDeployment: Buffer<ArrayBuffer>;
|
|
14
14
|
readonly setReceivingAddress: Buffer<ArrayBuffer>;
|
|
15
|
+
readonly setAgentReceivingAddress: Buffer<ArrayBuffer>;
|
|
15
16
|
readonly commitDailyAnchor: Buffer<ArrayBuffer>;
|
|
17
|
+
readonly commitTrace: Buffer<ArrayBuffer>;
|
|
16
18
|
};
|
|
17
19
|
interface CreateCompanyParams {
|
|
18
20
|
/** User wallet — signer + bound into the PDA seed. Sole authority for
|
|
@@ -157,6 +159,20 @@ interface SetReceivingAddressParams {
|
|
|
157
159
|
declare function buildSetReceivingAddressInstruction(params: SetReceivingAddressParams): {
|
|
158
160
|
instruction: TransactionInstruction;
|
|
159
161
|
};
|
|
162
|
+
interface SetAgentReceivingAddressParams {
|
|
163
|
+
/** AgentIdentity PDA whose personal receiving wallet is being set. */
|
|
164
|
+
identityPda: PublicKey;
|
|
165
|
+
/** User wallet — must equal `identity.owner`. */
|
|
166
|
+
owner: PublicKey;
|
|
167
|
+
/** New personal receiving address (passive destination for funds
|
|
168
|
+
* disbursed to this agent). Pass `PublicKey.default` to clear. NEVER a
|
|
169
|
+
* signer — it never authorizes any on-chain action. */
|
|
170
|
+
newReceivingAddress: PublicKey;
|
|
171
|
+
programId?: PublicKey;
|
|
172
|
+
}
|
|
173
|
+
declare function buildSetAgentReceivingAddressInstruction(params: SetAgentReceivingAddressParams): {
|
|
174
|
+
instruction: TransactionInstruction;
|
|
175
|
+
};
|
|
160
176
|
declare const TREASURY_INSTRUCTION_DISCRIMINATOR: {
|
|
161
177
|
readonly setPolicy: Buffer<ArrayBuffer>;
|
|
162
178
|
readonly disburseDiscretionary: Buffer<ArrayBuffer>;
|
|
@@ -438,5 +454,54 @@ interface CommitDailyAnchorParams {
|
|
|
438
454
|
declare function buildCommitDailyAnchorInstruction(params: CommitDailyAnchorParams): {
|
|
439
455
|
instruction: TransactionInstruction;
|
|
440
456
|
};
|
|
457
|
+
interface CommitTraceParams {
|
|
458
|
+
deploymentPda: PublicKey;
|
|
459
|
+
companyPda: PublicKey;
|
|
460
|
+
/** Anchor Wallet — must equal `operations.signer` (kind=Anchor). */
|
|
461
|
+
anchorSigner: PublicKey;
|
|
462
|
+
/** Anchor-kind OperationsAccount for this company (in TREASURY program,
|
|
463
|
+
* read-only here). Caller derives via `deriveOperationsPda(company,
|
|
464
|
+
* OPERATIONS_KIND.Anchor)`. */
|
|
465
|
+
operationsPda: PublicKey;
|
|
466
|
+
/** 32-byte hash of the task creation params — globally unique, becomes
|
|
467
|
+
* part of the TraceAnchor PDA seed. */
|
|
468
|
+
taskId: Uint8Array | Buffer;
|
|
469
|
+
/** Link to the deliverable (article URL, PR, etc). Max
|
|
470
|
+
* `MAX_RESULT_URI_LEN` bytes. */
|
|
471
|
+
resultUri: string;
|
|
472
|
+
/** SHA-256 of the deliverable content at completion (32 bytes). */
|
|
473
|
+
contentHash: Uint8Array | Buffer;
|
|
474
|
+
/** Rubric quality score, 0..=`MAX_QUALITY_SCORE`. */
|
|
475
|
+
qualityScore: number;
|
|
476
|
+
/** Version of the scoring rubric that produced `qualityScore`. */
|
|
477
|
+
rubricVersion: number;
|
|
478
|
+
/** SHA-256 of the off-chain verification report (32 bytes). */
|
|
479
|
+
evidenceHash: Uint8Array | Buffer;
|
|
480
|
+
/** Unix seconds the deliverable was completed off-chain. Must be > 0 and
|
|
481
|
+
* not in the future. */
|
|
482
|
+
completedAt: bigint;
|
|
483
|
+
/** Rent payer (typically the operator hot wallet). */
|
|
484
|
+
payer: PublicKey;
|
|
485
|
+
programId?: PublicKey;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Build a `commit_trace` instruction — Anchor-class single-tx commit of one
|
|
489
|
+
* completed, VERIFIED deliverable. Signed by the Anchor Wallet bound to the
|
|
490
|
+
* company's Anchor-kind OperationsAccount (same authority as
|
|
491
|
+
* `commit_daily_anchor`).
|
|
492
|
+
*
|
|
493
|
+
* Only deliverables that passed the off-chain verification gate should be
|
|
494
|
+
* committed — the on-chain `verdict` is always Passed. Caller is
|
|
495
|
+
* responsible for:
|
|
496
|
+
* 1. Computing `contentHash` (SHA-256 of the deliverable)
|
|
497
|
+
* 2. Running the verification gate + scoring rubric off-chain
|
|
498
|
+
* 3. Computing `evidenceHash` (SHA-256 of the verification report)
|
|
499
|
+
*
|
|
500
|
+
* The verdict byte is fixed on-chain; it is not a caller arg.
|
|
501
|
+
*/
|
|
502
|
+
declare function buildCommitTraceInstruction(params: CommitTraceParams): {
|
|
503
|
+
instruction: TransactionInstruction;
|
|
504
|
+
traceAnchorPda: PublicKey;
|
|
505
|
+
};
|
|
441
506
|
|
|
442
|
-
export { type AssetBudget, type CloseOperationsParams, type CommitDailyAnchorParams, type CreateCompanyParams, type CreateDeploymentParams, type DisburseDiscretionaryParams, type DisbursePrivilegedParams, type DisburseRoutineParams, INSTRUCTION_DISCRIMINATOR, type InitProtocolFeeAccountParams, type RegisterAgentIdentityParams, type RegisterCompanyOperationsParams, type RetireDeploymentParams, type RevokeOperationsParams, type SetPolicyParams, type SetReceivingAddressParams, TREASURY_INSTRUCTION_DISCRIMINATOR, type UpdateAgentIdentityMetadataParams, type UpdateCompanyMetadataParams, type UpdateCompanyStatusParams, type UpdateDeploymentMetadataParams, type UpdateDeploymentStatusParams, type UpdateOperationsCapabilityParams, buildCloseOperationsInstruction, buildCommitDailyAnchorInstruction, buildCreateCompanyInstruction, buildCreateDeploymentInstruction, buildDisburseDiscretionaryInstruction, buildDisbursePrivilegedInstruction, buildDisburseRoutineInstruction, buildInitProtocolFeeAccountInstruction, buildRegisterAgentIdentityInstruction, buildRegisterCompanyOperationsInstruction, buildRetireDeploymentInstruction, buildRevokeOperationsInstruction, buildSetPolicyInstruction, buildSetReceivingAddressInstruction, buildUpdateAgentIdentityMetadataInstruction, buildUpdateCompanyMetadataInstruction, buildUpdateCompanyStatusInstruction, buildUpdateDeploymentMetadataInstruction, buildUpdateDeploymentStatusInstruction, buildUpdateOperationsCapabilityInstruction };
|
|
507
|
+
export { type AssetBudget, type CloseOperationsParams, type CommitDailyAnchorParams, type CommitTraceParams, type CreateCompanyParams, type CreateDeploymentParams, type DisburseDiscretionaryParams, type DisbursePrivilegedParams, type DisburseRoutineParams, INSTRUCTION_DISCRIMINATOR, type InitProtocolFeeAccountParams, type RegisterAgentIdentityParams, type RegisterCompanyOperationsParams, type RetireDeploymentParams, type RevokeOperationsParams, type SetAgentReceivingAddressParams, type SetPolicyParams, type SetReceivingAddressParams, TREASURY_INSTRUCTION_DISCRIMINATOR, type UpdateAgentIdentityMetadataParams, type UpdateCompanyMetadataParams, type UpdateCompanyStatusParams, type UpdateDeploymentMetadataParams, type UpdateDeploymentStatusParams, type UpdateOperationsCapabilityParams, buildCloseOperationsInstruction, buildCommitDailyAnchorInstruction, buildCommitTraceInstruction, buildCreateCompanyInstruction, buildCreateDeploymentInstruction, buildDisburseDiscretionaryInstruction, buildDisbursePrivilegedInstruction, buildDisburseRoutineInstruction, buildInitProtocolFeeAccountInstruction, buildRegisterAgentIdentityInstruction, buildRegisterCompanyOperationsInstruction, buildRetireDeploymentInstruction, buildRevokeOperationsInstruction, buildSetAgentReceivingAddressInstruction, buildSetPolicyInstruction, buildSetReceivingAddressInstruction, buildUpdateAgentIdentityMetadataInstruction, buildUpdateCompanyMetadataInstruction, buildUpdateCompanyStatusInstruction, buildUpdateDeploymentMetadataInstruction, buildUpdateDeploymentStatusInstruction, buildUpdateOperationsCapabilityInstruction };
|
package/dist/instructions.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
TREASURY_INSTRUCTION_DISCRIMINATOR,
|
|
4
4
|
buildCloseOperationsInstruction,
|
|
5
5
|
buildCommitDailyAnchorInstruction,
|
|
6
|
+
buildCommitTraceInstruction,
|
|
6
7
|
buildCreateCompanyInstruction,
|
|
7
8
|
buildCreateDeploymentInstruction,
|
|
8
9
|
buildDisburseDiscretionaryInstruction,
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
buildRegisterCompanyOperationsInstruction,
|
|
14
15
|
buildRetireDeploymentInstruction,
|
|
15
16
|
buildRevokeOperationsInstruction,
|
|
17
|
+
buildSetAgentReceivingAddressInstruction,
|
|
16
18
|
buildSetPolicyInstruction,
|
|
17
19
|
buildSetReceivingAddressInstruction,
|
|
18
20
|
buildUpdateAgentIdentityMetadataInstruction,
|
|
@@ -21,14 +23,15 @@ import {
|
|
|
21
23
|
buildUpdateDeploymentMetadataInstruction,
|
|
22
24
|
buildUpdateDeploymentStatusInstruction,
|
|
23
25
|
buildUpdateOperationsCapabilityInstruction
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-
|
|
26
|
+
} from "./chunk-YC33EXHO.js";
|
|
27
|
+
import "./chunk-QZSQEGLT.js";
|
|
28
|
+
import "./chunk-BR62YC5F.js";
|
|
27
29
|
export {
|
|
28
30
|
INSTRUCTION_DISCRIMINATOR,
|
|
29
31
|
TREASURY_INSTRUCTION_DISCRIMINATOR,
|
|
30
32
|
buildCloseOperationsInstruction,
|
|
31
33
|
buildCommitDailyAnchorInstruction,
|
|
34
|
+
buildCommitTraceInstruction,
|
|
32
35
|
buildCreateCompanyInstruction,
|
|
33
36
|
buildCreateDeploymentInstruction,
|
|
34
37
|
buildDisburseDiscretionaryInstruction,
|
|
@@ -39,6 +42,7 @@ export {
|
|
|
39
42
|
buildRegisterCompanyOperationsInstruction,
|
|
40
43
|
buildRetireDeploymentInstruction,
|
|
41
44
|
buildRevokeOperationsInstruction,
|
|
45
|
+
buildSetAgentReceivingAddressInstruction,
|
|
42
46
|
buildSetPolicyInstruction,
|
|
43
47
|
buildSetReceivingAddressInstruction,
|
|
44
48
|
buildUpdateAgentIdentityMetadataInstruction,
|
package/dist/pda.cjs
CHANGED
|
@@ -27,6 +27,7 @@ __export(pda_exports, {
|
|
|
27
27
|
deriveOperationsPda: () => deriveOperationsPda,
|
|
28
28
|
derivePolicyPda: () => derivePolicyPda,
|
|
29
29
|
deriveProtocolFeePda: () => deriveProtocolFeePda,
|
|
30
|
+
deriveTraceAnchorPda: () => deriveTraceAnchorPda,
|
|
30
31
|
deriveTreasuryPda: () => deriveTreasuryPda,
|
|
31
32
|
u32LeBytes: () => u32LeBytes
|
|
32
33
|
});
|
|
@@ -47,12 +48,14 @@ var POLICY_SEED = Buffer.from("policy");
|
|
|
47
48
|
var PROTOCOL_FEES_SEED = Buffer.from("protocol_fees");
|
|
48
49
|
var OPERATIONS_SEED = Buffer.from("operations");
|
|
49
50
|
var DAILY_ANCHOR_SEED = Buffer.from("daily_anchor");
|
|
51
|
+
var TRACE_SEED = Buffer.from("trace");
|
|
50
52
|
var SOL_PSEUDO_MINT = new import_web3.PublicKey(new Uint8Array(32));
|
|
51
53
|
var ACCOUNT_DISCRIMINATOR = {
|
|
52
54
|
AgentIdentity: Buffer.from([11, 149, 31, 27, 186, 76, 241, 72]),
|
|
53
55
|
CompanyAccount: Buffer.from([37, 215, 171, 200, 8, 141, 69, 96]),
|
|
54
56
|
Deployment: Buffer.from([66, 90, 104, 89, 183, 130, 64, 178]),
|
|
55
|
-
DailyAnchorAccount: Buffer.from([218, 106, 107, 94, 194, 48, 111, 254])
|
|
57
|
+
DailyAnchorAccount: Buffer.from([218, 106, 107, 94, 194, 48, 111, 254]),
|
|
58
|
+
TraceAnchorAccount: Buffer.from([159, 101, 186, 98, 211, 217, 119, 232])
|
|
56
59
|
};
|
|
57
60
|
var TREASURY_ACCOUNT_DISCRIMINATOR = {
|
|
58
61
|
TreasuryAccount: Buffer.from([204, 140, 18, 173, 90, 152, 134, 123]),
|
|
@@ -131,6 +134,16 @@ function deriveDailyAnchorPda(deploymentPda, dayUnix, programId = REGISTRY_PROGR
|
|
|
131
134
|
);
|
|
132
135
|
return { pda, bump };
|
|
133
136
|
}
|
|
137
|
+
function deriveTraceAnchorPda(taskId, programId = REGISTRY_PROGRAM_ID) {
|
|
138
|
+
if (taskId.length !== 32) {
|
|
139
|
+
throw new RangeError(`taskId must be 32 bytes, got ${taskId.length}`);
|
|
140
|
+
}
|
|
141
|
+
const [pda, bump] = import_web32.PublicKey.findProgramAddressSync(
|
|
142
|
+
[TRACE_SEED, Buffer.from(taskId)],
|
|
143
|
+
programId
|
|
144
|
+
);
|
|
145
|
+
return { pda, bump };
|
|
146
|
+
}
|
|
134
147
|
// Annotate the CommonJS export names for ESM import in node:
|
|
135
148
|
0 && (module.exports = {
|
|
136
149
|
deriveAgentIdentityPda,
|
|
@@ -140,6 +153,7 @@ function deriveDailyAnchorPda(deploymentPda, dayUnix, programId = REGISTRY_PROGR
|
|
|
140
153
|
deriveOperationsPda,
|
|
141
154
|
derivePolicyPda,
|
|
142
155
|
deriveProtocolFeePda,
|
|
156
|
+
deriveTraceAnchorPda,
|
|
143
157
|
deriveTreasuryPda,
|
|
144
158
|
u32LeBytes
|
|
145
159
|
});
|
package/dist/pda.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/pda.ts","../src/constants.ts"],"sourcesContent":["import { PublicKey } from \"@solana/web3.js\";\nimport {\n AGENT_IDENTITY_SEED,\n COMPANY_SEED,\n DAILY_ANCHOR_SEED,\n DEPLOYMENT_SEED,\n OPERATIONS_SEED,\n POLICY_SEED,\n PROTOCOL_FEES_SEED,\n REGISTRY_PROGRAM_ID,\n TREASURY_PROGRAM_ID,\n TREASURY_SEED,\n type OperationsKind,\n} from \"./constants\";\n\n/**\n * Encode a u32 as little-endian 4 bytes (matches Anchor / Borsh on-chain\n * representation when using a u32 in a PDA seed).\n */\nexport function u32LeBytes(value: number): Buffer {\n if (!Number.isInteger(value) || value < 0 || value > 0xff_ff_ff_ff) {\n throw new RangeError(`u32 out of range: ${value}`);\n }\n const buf = Buffer.alloc(4);\n buf.writeUInt32LE(value, 0);\n return buf;\n}\n\n/**\n * CompanyAccount PDA.\n *\n * seeds = [\"company\", owner, nonce_le_u32]\n *\n * Wallet-bound seed: a wallet's companies can be enumerated directly\n * from chain by probing `(owner, nonce=0..N)`. The owner is also the\n * sole authority for state-changing ix on this account.\n */\nexport function deriveCompanyPda(\n owner: PublicKey,\n nonce: number,\n programId: PublicKey = REGISTRY_PROGRAM_ID,\n): { pda: PublicKey; bump: number } {\n const [pda, bump] = PublicKey.findProgramAddressSync(\n [COMPANY_SEED, owner.toBuffer(), u32LeBytes(nonce)],\n programId,\n );\n return { pda, bump };\n}\n\n/**\n * AgentIdentity PDA.\n *\n * seeds = [\"agent_identity\", agent_pubkey]\n *\n * `agent_pubkey` is a stable identity key chosen by the caller (typically\n * a fresh keypair generated client-side). Identity is independent of any\n * company — the same identity may be deployed multiple times across the\n * same owner's companies.\n */\nexport function deriveAgentIdentityPda(\n agentPubkey: PublicKey,\n programId: PublicKey = REGISTRY_PROGRAM_ID,\n): { pda: PublicKey; bump: number } {\n const [pda, bump] = PublicKey.findProgramAddressSync(\n [AGENT_IDENTITY_SEED, agentPubkey.toBuffer()],\n programId,\n );\n return { pda, bump };\n}\n\n/**\n * Deployment PDA.\n *\n * seeds = [\"deployment\", company_pda, deployment_index_le_u32]\n *\n * `deployment_index` is a per-company u32 counter. Maintained by the\n * caller — pick the next free index. Same `agent_identity` may have\n * multiple deployments under the same company (e.g. retired then\n * re-deployed); each deployment gets its own index.\n */\nexport function deriveDeploymentPda(\n companyPda: PublicKey,\n deploymentIndex: number,\n programId: PublicKey = REGISTRY_PROGRAM_ID,\n): { pda: PublicKey; bump: number } {\n const [pda, bump] = PublicKey.findProgramAddressSync(\n [DEPLOYMENT_SEED, companyPda.toBuffer(), u32LeBytes(deploymentIndex)],\n programId,\n );\n return { pda, bump };\n}\n\n/**\n * TreasuryAccount PDA — owned by Treasury program.\n *\n * seeds = [\"treasury\", company_pda]\n *\n * Initialized atomically with PolicyAccount via Registry's `create_company`\n * CPI to `treasury::init_treasury` (design doc §6).\n */\nexport function deriveTreasuryPda(\n companyPda: PublicKey,\n programId: PublicKey = TREASURY_PROGRAM_ID,\n): { pda: PublicKey; bump: number } {\n const [pda, bump] = PublicKey.findProgramAddressSync(\n [TREASURY_SEED, companyPda.toBuffer()],\n programId,\n );\n return { pda, bump };\n}\n\n/**\n * PolicyAccount PDA — owned by Treasury program.\n *\n * seeds = [\"policy\", company_pda]\n *\n * Initialized atomically with TreasuryAccount via the same `create_company`\n * CPI flow.\n */\nexport function derivePolicyPda(\n companyPda: PublicKey,\n programId: PublicKey = TREASURY_PROGRAM_ID,\n): { pda: PublicKey; bump: number } {\n const [pda, bump] = PublicKey.findProgramAddressSync(\n [POLICY_SEED, companyPda.toBuffer()],\n programId,\n );\n return { pda, bump };\n}\n\n/**\n * ProtocolFeeAccount PDA — owned by Treasury program. Singleton: one\n * per program deployment, collects the Agent Operating Fee from every\n * intra-company agent disbursement.\n *\n * seeds = [\"protocol_fees\"]\n */\nexport function deriveProtocolFeePda(\n programId: PublicKey = TREASURY_PROGRAM_ID,\n): { pda: PublicKey; bump: number } {\n const [pda, bump] = PublicKey.findProgramAddressSync(\n [PROTOCOL_FEES_SEED],\n programId,\n );\n return { pda, bump };\n}\n\n/**\n * OperationsAccount PDA — owned by Treasury program. One per\n * (company, kind) pair, so Disbursement and Anchor capabilities never\n * share a key.\n *\n * seeds = [\"operations\", company_pda, kind_byte]\n *\n * `kind_byte` is the single-byte discriminator from `OPERATIONS_KIND`\n * (Disbursement=0, Anchor=1). Order MUST NOT change once any account\n * exists.\n */\nexport function deriveOperationsPda(\n companyPda: PublicKey,\n kind: OperationsKind,\n programId: PublicKey = TREASURY_PROGRAM_ID,\n): { pda: PublicKey; bump: number } {\n const [pda, bump] = PublicKey.findProgramAddressSync(\n [OPERATIONS_SEED, companyPda.toBuffer(), Buffer.from([kind])],\n programId,\n );\n return { pda, bump };\n}\n\n/** Encode an i64 as little-endian 8 bytes (matches Anchor / Borsh). */\nfunction i64LeBytes(value: bigint): Buffer {\n const buf = Buffer.alloc(8);\n buf.writeBigInt64LE(value, 0);\n return buf;\n}\n\n/**\n * DailyAnchorAccount PDA — owned by Registry program. One per\n * (deployment, UTC day) — captures the Merkle root over that day's\n * task hashes.\n *\n * seeds = [\"daily_anchor\", deployment_pda, day_unix_le_i64]\n *\n * `dayUnix` must be aligned to 00:00:00 UTC (multiple of 86400). The\n * on-chain handler enforces alignment; passing an unaligned value will\n * fail with a constraint error.\n */\nexport function deriveDailyAnchorPda(\n deploymentPda: PublicKey,\n dayUnix: bigint,\n programId: PublicKey = REGISTRY_PROGRAM_ID,\n): { pda: PublicKey; bump: number } {\n const [pda, bump] = PublicKey.findProgramAddressSync(\n [DAILY_ANCHOR_SEED, deploymentPda.toBuffer(), i64LeBytes(dayUnix)],\n programId,\n );\n return { pda, bump };\n}\n","import { PublicKey } from \"@solana/web3.js\";\n\n// Registry program ID. The vanity-grinded program keypair lives at\n// `occa-programs/programs/registry/registry-keypair.json` (gitignored,\n// sibling repo). Public key is committed here so clients (server +\n// web) can derive PDAs without loading the keypair.\n//\n// NOTE: this is the devnet program ID. Mainnet will likely have a\n// different program ID — when that day comes, swap via env or config.\nexport const REGISTRY_PROGRAM_ID_BASE58 =\n \"occaTHMv5eYG5aZ85jimxTvHkBfsDCvndXC6J2k8kxr\";\n\nexport const REGISTRY_PROGRAM_ID = new PublicKey(REGISTRY_PROGRAM_ID_BASE58);\n\n// Treasury program ID — devnet. Registry's `create_company` CPIs into\n// `treasury::init_treasury` to atomically initialize the company's\n// TreasuryAccount + PolicyAccount PDAs (per design doc §6).\nexport const TREASURY_PROGRAM_ID_BASE58 =\n \"occaxyVLnurdjedWCBPrvDCCto8wGYadtTZ3nAmcVzh\";\n\nexport const TREASURY_PROGRAM_ID = new PublicKey(TREASURY_PROGRAM_ID_BASE58);\n\n// PDA seed prefixes. Must match `occa-programs/programs/registry/src/lib.rs` exactly.\nexport const COMPANY_SEED = Buffer.from(\"company\");\nexport const AGENT_IDENTITY_SEED = Buffer.from(\"agent_identity\");\nexport const DEPLOYMENT_SEED = Buffer.from(\"deployment\");\n// Treasury PDA seeds (owned by treasury program). Must match\n// `occa-programs/programs/treasury/src/lib.rs`.\nexport const TREASURY_SEED = Buffer.from(\"treasury\");\nexport const POLICY_SEED = Buffer.from(\"policy\");\nexport const PROTOCOL_FEES_SEED = Buffer.from(\"protocol_fees\");\nexport const OPERATIONS_SEED = Buffer.from(\"operations\");\n// DailyAnchor PDA seed (owned by registry program). Seeds:\n// [\"daily_anchor\", deployment_pda, day_unix_le_i64_8bytes].\nexport const DAILY_ANCHOR_SEED = Buffer.from(\"daily_anchor\");\n\n// OperationsKind discriminator byte — must match the Rust enum order in\n// `treasury/src/lib.rs`. Used as the 3rd seed byte of an OperationsAccount\n// PDA and as a u8 wire arg to `register_company_operations`.\nexport const OPERATIONS_KIND = {\n /** Disbursement Wallet — operator-held only, signs `disburse_routine`. */\n Disbursement: 0,\n /** Anchor Wallet — operator+OCCA shared, signs `commit_daily_anchor`. */\n Anchor: 1,\n} as const;\nexport type OperationsKind =\n (typeof OPERATIONS_KIND)[keyof typeof OPERATIONS_KIND];\n\n// SOL has no real SPL mint — lamports live directly on accounts. The\n// treasury program uses the default (all-zero) pubkey as the SOL marker\n// in accepted-asset lists and disbursement mint args.\nexport const SOL_PSEUDO_MINT = new PublicKey(new Uint8Array(32));\n\n// On-chain bounds — must match `occa-programs/programs/registry/src/lib.rs`.\nexport const MAX_NAME_LEN = 64;\nexport const MAX_LOCALE_LEN = 8;\nexport const MAX_ROLE_LEN = 32;\nexport const MAX_METADATA_URI_LEN = 200;\nexport const MAX_REPUTATION_URI_LEN = 200;\n\n// Status encodings — must match the on-chain constants.\nexport const COMPANY_STATUS = {\n Active: 0,\n Paused: 1,\n} as const;\nexport type CompanyStatus =\n (typeof COMPANY_STATUS)[keyof typeof COMPANY_STATUS];\n\nexport const DEPLOYMENT_STATUS = {\n Active: 0,\n Paused: 1,\n /** Terminal — retired deployments cannot be reactivated. */\n Retired: 2,\n} as const;\nexport type DeploymentStatus =\n (typeof DEPLOYMENT_STATUS)[keyof typeof DEPLOYMENT_STATUS];\n\n// Account discriminators (Anchor sha256(\"account:<Name>\")[..8]).\nexport const ACCOUNT_DISCRIMINATOR = {\n AgentIdentity: Buffer.from([11, 149, 31, 27, 186, 76, 241, 72]),\n CompanyAccount: Buffer.from([37, 215, 171, 200, 8, 141, 69, 96]),\n Deployment: Buffer.from([66, 90, 104, 89, 183, 130, 64, 178]),\n DailyAnchorAccount: Buffer.from([218, 106, 107, 94, 194, 48, 111, 254]),\n} as const;\n\n// Treasury program account discriminators — from\n// `occa-programs/target/idl/treasury.json`.\nexport const TREASURY_ACCOUNT_DISCRIMINATOR = {\n TreasuryAccount: Buffer.from([204, 140, 18, 173, 90, 152, 134, 123]),\n PolicyAccount: Buffer.from([218, 201, 183, 164, 156, 127, 81, 175]),\n ProtocolFeeAccount: Buffer.from([5, 171, 24, 9, 150, 135, 135, 201]),\n OperationsAccount: Buffer.from([185, 55, 148, 90, 151, 227, 104, 158]),\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,eAA0B;;;ACA1B,kBAA0B;AASnB,IAAM,6BACX;AAEK,IAAM,sBAAsB,IAAI,sBAAU,0BAA0B;AAKpE,IAAM,6BACX;AAEK,IAAM,sBAAsB,IAAI,sBAAU,0BAA0B;AAGpE,IAAM,eAAe,OAAO,KAAK,SAAS;AAC1C,IAAM,sBAAsB,OAAO,KAAK,gBAAgB;AACxD,IAAM,kBAAkB,OAAO,KAAK,YAAY;AAGhD,IAAM,gBAAgB,OAAO,KAAK,UAAU;AAC5C,IAAM,cAAc,OAAO,KAAK,QAAQ;AACxC,IAAM,qBAAqB,OAAO,KAAK,eAAe;AACtD,IAAM,kBAAkB,OAAO,KAAK,YAAY;AAGhD,IAAM,oBAAoB,OAAO,KAAK,cAAc;AAiBpD,IAAM,kBAAkB,IAAI,sBAAU,IAAI,WAAW,EAAE,CAAC;AA2BxD,IAAM,wBAAwB;AAAA,EACnC,eAAe,OAAO,KAAK,CAAC,IAAI,KAAK,IAAI,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;AAAA,EAC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,mBAAmB,cAAc,SAAS,GAAG,WAAW,OAAO,CAAC;AAAA,IACjE;AAAA,EACF;AACA,SAAO,EAAE,KAAK,KAAK;AACrB;","names":["import_web3"]}
|
|
1
|
+
{"version":3,"sources":["../src/pda.ts","../src/constants.ts"],"sourcesContent":["import { PublicKey } from \"@solana/web3.js\";\nimport {\n AGENT_IDENTITY_SEED,\n COMPANY_SEED,\n DAILY_ANCHOR_SEED,\n DEPLOYMENT_SEED,\n OPERATIONS_SEED,\n POLICY_SEED,\n PROTOCOL_FEES_SEED,\n REGISTRY_PROGRAM_ID,\n TRACE_SEED,\n TREASURY_PROGRAM_ID,\n TREASURY_SEED,\n type OperationsKind,\n} from \"./constants\";\n\n/**\n * Encode a u32 as little-endian 4 bytes (matches Anchor / Borsh on-chain\n * representation when using a u32 in a PDA seed).\n */\nexport function u32LeBytes(value: number): Buffer {\n if (!Number.isInteger(value) || value < 0 || value > 0xff_ff_ff_ff) {\n throw new RangeError(`u32 out of range: ${value}`);\n }\n const buf = Buffer.alloc(4);\n buf.writeUInt32LE(value, 0);\n return buf;\n}\n\n/**\n * CompanyAccount PDA.\n *\n * seeds = [\"company\", owner, nonce_le_u32]\n *\n * Wallet-bound seed: a wallet's companies can be enumerated directly\n * from chain by probing `(owner, nonce=0..N)`. The owner is also the\n * sole authority for state-changing ix on this account.\n */\nexport function deriveCompanyPda(\n owner: PublicKey,\n nonce: number,\n programId: PublicKey = REGISTRY_PROGRAM_ID,\n): { pda: PublicKey; bump: number } {\n const [pda, bump] = PublicKey.findProgramAddressSync(\n [COMPANY_SEED, owner.toBuffer(), u32LeBytes(nonce)],\n programId,\n );\n return { pda, bump };\n}\n\n/**\n * AgentIdentity PDA.\n *\n * seeds = [\"agent_identity\", agent_pubkey]\n *\n * `agent_pubkey` is a stable identity key chosen by the caller (typically\n * a fresh keypair generated client-side). Identity is independent of any\n * company — the same identity may be deployed multiple times across the\n * same owner's companies.\n */\nexport function deriveAgentIdentityPda(\n agentPubkey: PublicKey,\n programId: PublicKey = REGISTRY_PROGRAM_ID,\n): { pda: PublicKey; bump: number } {\n const [pda, bump] = PublicKey.findProgramAddressSync(\n [AGENT_IDENTITY_SEED, agentPubkey.toBuffer()],\n programId,\n );\n return { pda, bump };\n}\n\n/**\n * Deployment PDA.\n *\n * seeds = [\"deployment\", company_pda, deployment_index_le_u32]\n *\n * `deployment_index` is a per-company u32 counter. Maintained by the\n * caller — pick the next free index. Same `agent_identity` may have\n * multiple deployments under the same company (e.g. retired then\n * re-deployed); each deployment gets its own index.\n */\nexport function deriveDeploymentPda(\n companyPda: PublicKey,\n deploymentIndex: number,\n programId: PublicKey = REGISTRY_PROGRAM_ID,\n): { pda: PublicKey; bump: number } {\n const [pda, bump] = PublicKey.findProgramAddressSync(\n [DEPLOYMENT_SEED, companyPda.toBuffer(), u32LeBytes(deploymentIndex)],\n programId,\n );\n return { pda, bump };\n}\n\n/**\n * TreasuryAccount PDA — owned by Treasury program.\n *\n * seeds = [\"treasury\", company_pda]\n *\n * Initialized atomically with PolicyAccount via Registry's `create_company`\n * CPI to `treasury::init_treasury` (design doc §6).\n */\nexport function deriveTreasuryPda(\n companyPda: PublicKey,\n programId: PublicKey = TREASURY_PROGRAM_ID,\n): { pda: PublicKey; bump: number } {\n const [pda, bump] = PublicKey.findProgramAddressSync(\n [TREASURY_SEED, companyPda.toBuffer()],\n programId,\n );\n return { pda, bump };\n}\n\n/**\n * PolicyAccount PDA — owned by Treasury program.\n *\n * seeds = [\"policy\", company_pda]\n *\n * Initialized atomically with TreasuryAccount via the same `create_company`\n * CPI flow.\n */\nexport function derivePolicyPda(\n companyPda: PublicKey,\n programId: PublicKey = TREASURY_PROGRAM_ID,\n): { pda: PublicKey; bump: number } {\n const [pda, bump] = PublicKey.findProgramAddressSync(\n [POLICY_SEED, companyPda.toBuffer()],\n programId,\n );\n return { pda, bump };\n}\n\n/**\n * ProtocolFeeAccount PDA — owned by Treasury program. Singleton: one\n * per program deployment, collects the Agent Operating Fee from every\n * intra-company agent disbursement.\n *\n * seeds = [\"protocol_fees\"]\n */\nexport function deriveProtocolFeePda(\n programId: PublicKey = TREASURY_PROGRAM_ID,\n): { pda: PublicKey; bump: number } {\n const [pda, bump] = PublicKey.findProgramAddressSync(\n [PROTOCOL_FEES_SEED],\n programId,\n );\n return { pda, bump };\n}\n\n/**\n * OperationsAccount PDA — owned by Treasury program. One per\n * (company, kind) pair, so Disbursement and Anchor capabilities never\n * share a key.\n *\n * seeds = [\"operations\", company_pda, kind_byte]\n *\n * `kind_byte` is the single-byte discriminator from `OPERATIONS_KIND`\n * (Disbursement=0, Anchor=1). Order MUST NOT change once any account\n * exists.\n */\nexport function deriveOperationsPda(\n companyPda: PublicKey,\n kind: OperationsKind,\n programId: PublicKey = TREASURY_PROGRAM_ID,\n): { pda: PublicKey; bump: number } {\n const [pda, bump] = PublicKey.findProgramAddressSync(\n [OPERATIONS_SEED, companyPda.toBuffer(), Buffer.from([kind])],\n programId,\n );\n return { pda, bump };\n}\n\n/** Encode an i64 as little-endian 8 bytes (matches Anchor / Borsh). */\nfunction i64LeBytes(value: bigint): Buffer {\n const buf = Buffer.alloc(8);\n buf.writeBigInt64LE(value, 0);\n return buf;\n}\n\n/**\n * DailyAnchorAccount PDA — owned by Registry program. One per\n * (deployment, UTC day) — captures the Merkle root over that day's\n * task hashes.\n *\n * seeds = [\"daily_anchor\", deployment_pda, day_unix_le_i64]\n *\n * `dayUnix` must be aligned to 00:00:00 UTC (multiple of 86400). The\n * on-chain handler enforces alignment; passing an unaligned value will\n * fail with a constraint error.\n */\nexport function deriveDailyAnchorPda(\n deploymentPda: PublicKey,\n dayUnix: bigint,\n programId: PublicKey = REGISTRY_PROGRAM_ID,\n): { pda: PublicKey; bump: number } {\n const [pda, bump] = PublicKey.findProgramAddressSync(\n [DAILY_ANCHOR_SEED, deploymentPda.toBuffer(), i64LeBytes(dayUnix)],\n programId,\n );\n return { pda, bump };\n}\n\n/**\n * TraceAnchorAccount PDA — owned by Registry program. One per completed,\n * verified deliverable (article, PR, etc).\n *\n * seeds = [\"trace\", task_id_32bytes]\n *\n * `taskId` is a 32-byte hash of the task creation params. Collision on the\n * same `taskId` means the task is already anchored — a re-commit fails\n * naturally (Anchor `init` rejects).\n */\nexport function deriveTraceAnchorPda(\n taskId: Uint8Array,\n programId: PublicKey = REGISTRY_PROGRAM_ID,\n): { pda: PublicKey; bump: number } {\n if (taskId.length !== 32) {\n throw new RangeError(`taskId must be 32 bytes, got ${taskId.length}`);\n }\n const [pda, bump] = PublicKey.findProgramAddressSync(\n [TRACE_SEED, Buffer.from(taskId)],\n programId,\n );\n return { pda, bump };\n}\n","import { PublicKey } from \"@solana/web3.js\";\n\n// Registry program ID. The vanity-grinded program keypair lives at\n// `occa-programs/programs/registry/registry-keypair.json` (gitignored,\n// sibling repo). Public key is committed here so clients (server +\n// web) can derive PDAs without loading the keypair.\n//\n// NOTE: this is the devnet program ID. Mainnet will likely have a\n// different program ID — when that day comes, swap via env or config.\nexport const REGISTRY_PROGRAM_ID_BASE58 =\n \"occaTHMv5eYG5aZ85jimxTvHkBfsDCvndXC6J2k8kxr\";\n\nexport const REGISTRY_PROGRAM_ID = new PublicKey(REGISTRY_PROGRAM_ID_BASE58);\n\n// Treasury program ID — devnet. Registry's `create_company` CPIs into\n// `treasury::init_treasury` to atomically initialize the company's\n// TreasuryAccount + PolicyAccount PDAs (per design doc §6).\nexport const TREASURY_PROGRAM_ID_BASE58 =\n \"occaxyVLnurdjedWCBPrvDCCto8wGYadtTZ3nAmcVzh\";\n\nexport const TREASURY_PROGRAM_ID = new PublicKey(TREASURY_PROGRAM_ID_BASE58);\n\n// PDA seed prefixes. Must match `occa-programs/programs/registry/src/lib.rs` exactly.\nexport const COMPANY_SEED = Buffer.from(\"company\");\nexport const AGENT_IDENTITY_SEED = Buffer.from(\"agent_identity\");\nexport const DEPLOYMENT_SEED = Buffer.from(\"deployment\");\n// Treasury PDA seeds (owned by treasury program). Must match\n// `occa-programs/programs/treasury/src/lib.rs`.\nexport const TREASURY_SEED = Buffer.from(\"treasury\");\nexport const POLICY_SEED = Buffer.from(\"policy\");\nexport const PROTOCOL_FEES_SEED = Buffer.from(\"protocol_fees\");\nexport const OPERATIONS_SEED = Buffer.from(\"operations\");\n// DailyAnchor PDA seed (owned by registry program). Seeds:\n// [\"daily_anchor\", deployment_pda, day_unix_le_i64_8bytes].\nexport const DAILY_ANCHOR_SEED = Buffer.from(\"daily_anchor\");\n// TraceAnchor PDA seed (owned by registry program). Seeds:\n// [\"trace\", task_id_32bytes]. One per completed, verified deliverable.\nexport const TRACE_SEED = Buffer.from(\"trace\");\n\n// OperationsKind discriminator byte — must match the Rust enum order in\n// `treasury/src/lib.rs`. Used as the 3rd seed byte of an OperationsAccount\n// PDA and as a u8 wire arg to `register_company_operations`.\nexport const OPERATIONS_KIND = {\n /** Disbursement Wallet — operator-held only, signs `disburse_routine`. */\n Disbursement: 0,\n /**\n * Anchor Wallet — operator+OCCA shared, signs `commit_daily_anchor`\n * and `commit_trace`.\n */\n Anchor: 1,\n} as const;\nexport type OperationsKind =\n (typeof OPERATIONS_KIND)[keyof typeof OPERATIONS_KIND];\n\n// SOL has no real SPL mint — lamports live directly on accounts. The\n// treasury program uses the default (all-zero) pubkey as the SOL marker\n// in accepted-asset lists and disbursement mint args.\nexport const SOL_PSEUDO_MINT = new PublicKey(new Uint8Array(32));\n\n// On-chain bounds — must match `occa-programs/programs/registry/src/lib.rs`.\nexport const MAX_NAME_LEN = 64;\nexport const MAX_LOCALE_LEN = 8;\nexport const MAX_ROLE_LEN = 32;\nexport const MAX_METADATA_URI_LEN = 200;\nexport const MAX_REPUTATION_URI_LEN = 200;\nexport const MAX_RESULT_URI_LEN = 200;\nexport const MAX_QUALITY_SCORE = 100;\n\n// TraceAnchorAccount.verdict encoding — only Passed deliverables are\n// anchored (failed/unverified work never reaches the chain).\nexport const TRACE_VERDICT = {\n Passed: 1,\n} as const;\nexport type TraceVerdict = (typeof TRACE_VERDICT)[keyof typeof TRACE_VERDICT];\n\n// Status encodings — must match the on-chain constants.\nexport const COMPANY_STATUS = {\n Active: 0,\n Paused: 1,\n} as const;\nexport type CompanyStatus =\n (typeof COMPANY_STATUS)[keyof typeof COMPANY_STATUS];\n\nexport const DEPLOYMENT_STATUS = {\n Active: 0,\n Paused: 1,\n /** Terminal — retired deployments cannot be reactivated. */\n Retired: 2,\n} as const;\nexport type DeploymentStatus =\n (typeof DEPLOYMENT_STATUS)[keyof typeof DEPLOYMENT_STATUS];\n\n// Account discriminators (Anchor sha256(\"account:<Name>\")[..8]).\nexport const ACCOUNT_DISCRIMINATOR = {\n AgentIdentity: Buffer.from([11, 149, 31, 27, 186, 76, 241, 72]),\n CompanyAccount: Buffer.from([37, 215, 171, 200, 8, 141, 69, 96]),\n Deployment: Buffer.from([66, 90, 104, 89, 183, 130, 64, 178]),\n DailyAnchorAccount: Buffer.from([218, 106, 107, 94, 194, 48, 111, 254]),\n TraceAnchorAccount: Buffer.from([159, 101, 186, 98, 211, 217, 119, 232]),\n} as const;\n\n// Treasury program account discriminators — from\n// `occa-programs/target/idl/treasury.json`.\nexport const TREASURY_ACCOUNT_DISCRIMINATOR = {\n TreasuryAccount: Buffer.from([204, 140, 18, 173, 90, 152, 134, 123]),\n PolicyAccount: Buffer.from([218, 201, 183, 164, 156, 127, 81, 175]),\n ProtocolFeeAccount: Buffer.from([5, 171, 24, 9, 150, 135, 135, 201]),\n OperationsAccount: Buffer.from([185, 55, 148, 90, 151, 227, 104, 158]),\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,eAA0B;;;ACA1B,kBAA0B;AASnB,IAAM,6BACX;AAEK,IAAM,sBAAsB,IAAI,sBAAU,0BAA0B;AAKpE,IAAM,6BACX;AAEK,IAAM,sBAAsB,IAAI,sBAAU,0BAA0B;AAGpE,IAAM,eAAe,OAAO,KAA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O,SAAS,qBACd,YAAuB,qBACW;AAClC,QAAM,CAAC,KAAK,IAAI,IAAI,uBAAU;AAAA,IAC5B,CAAC,kBAAkB;AAAA,IACnB;AAAA,EACF;AACA,SAAO,EAAE,KAAK,KAAK;AACrB;AAaO,SAAS,oBACd,YACA,MACA,YAAuB,qBACW;AAClC,QAAM,CAAC,KAAK,IAAI,IAAI,uBAAU;AAAA,IAC5B,CAAC,iBAAiB,WAAW,SAAS,GAAG,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;AAAA,IAC5D;AAAA,EACF;AACA,SAAO,EAAE,KAAK,KAAK;AACrB;AAGA,SAAS,WAAW,OAAuB;AACzC,QAAM,MAAM,OAAO,MAAM,CAAC;AAC1B,MAAI,gBAAgB,OAAO,CAAC;AAC5B,SAAO;AACT;AAaO,SAAS,qBACd,eACA,SACA,YAAuB,qBACW;AAClC,QAAM,CAAC,KAAK,IAAI,IAAI,uBAAU;AAAA,IAC5B,CAAC,mBAAmB,cAAc,SAAS,GAAG,WAAW,OAAO,CAAC;AAAA,IACjE;AAAA,EACF;AACA,SAAO,EAAE,KAAK,KAAK;AACrB;AAYO,SAAS,qBACd,QACA,YAAuB,qBACW;AAClC,MAAI,OAAO,WAAW,IAAI;AACxB,UAAM,IAAI,WAAW,gCAAgC,OAAO,MAAM,EAAE;AAAA,EACtE;AACA,QAAM,CAAC,KAAK,IAAI,IAAI,uBAAU;AAAA,IAC5B,CAAC,YAAY,OAAO,KAAK,MAAM,CAAC;AAAA,IAChC;AAAA,EACF;AACA,SAAO,EAAE,KAAK,KAAK;AACrB;","names":["import_web3"]}
|
package/dist/pda.d.cts
CHANGED
|
@@ -112,5 +112,19 @@ declare function deriveDailyAnchorPda(deploymentPda: PublicKey, dayUnix: bigint,
|
|
|
112
112
|
pda: PublicKey;
|
|
113
113
|
bump: number;
|
|
114
114
|
};
|
|
115
|
+
/**
|
|
116
|
+
* TraceAnchorAccount PDA — owned by Registry program. One per completed,
|
|
117
|
+
* verified deliverable (article, PR, etc).
|
|
118
|
+
*
|
|
119
|
+
* seeds = ["trace", task_id_32bytes]
|
|
120
|
+
*
|
|
121
|
+
* `taskId` is a 32-byte hash of the task creation params. Collision on the
|
|
122
|
+
* same `taskId` means the task is already anchored — a re-commit fails
|
|
123
|
+
* naturally (Anchor `init` rejects).
|
|
124
|
+
*/
|
|
125
|
+
declare function deriveTraceAnchorPda(taskId: Uint8Array, programId?: PublicKey): {
|
|
126
|
+
pda: PublicKey;
|
|
127
|
+
bump: number;
|
|
128
|
+
};
|
|
115
129
|
|
|
116
|
-
export { deriveAgentIdentityPda, deriveCompanyPda, deriveDailyAnchorPda, deriveDeploymentPda, deriveOperationsPda, derivePolicyPda, deriveProtocolFeePda, deriveTreasuryPda, u32LeBytes };
|
|
130
|
+
export { deriveAgentIdentityPda, deriveCompanyPda, deriveDailyAnchorPda, deriveDeploymentPda, deriveOperationsPda, derivePolicyPda, deriveProtocolFeePda, deriveTraceAnchorPda, deriveTreasuryPda, u32LeBytes };
|
package/dist/pda.d.ts
CHANGED
|
@@ -112,5 +112,19 @@ declare function deriveDailyAnchorPda(deploymentPda: PublicKey, dayUnix: bigint,
|
|
|
112
112
|
pda: PublicKey;
|
|
113
113
|
bump: number;
|
|
114
114
|
};
|
|
115
|
+
/**
|
|
116
|
+
* TraceAnchorAccount PDA — owned by Registry program. One per completed,
|
|
117
|
+
* verified deliverable (article, PR, etc).
|
|
118
|
+
*
|
|
119
|
+
* seeds = ["trace", task_id_32bytes]
|
|
120
|
+
*
|
|
121
|
+
* `taskId` is a 32-byte hash of the task creation params. Collision on the
|
|
122
|
+
* same `taskId` means the task is already anchored — a re-commit fails
|
|
123
|
+
* naturally (Anchor `init` rejects).
|
|
124
|
+
*/
|
|
125
|
+
declare function deriveTraceAnchorPda(taskId: Uint8Array, programId?: PublicKey): {
|
|
126
|
+
pda: PublicKey;
|
|
127
|
+
bump: number;
|
|
128
|
+
};
|
|
115
129
|
|
|
116
|
-
export { deriveAgentIdentityPda, deriveCompanyPda, deriveDailyAnchorPda, deriveDeploymentPda, deriveOperationsPda, derivePolicyPda, deriveProtocolFeePda, deriveTreasuryPda, u32LeBytes };
|
|
130
|
+
export { deriveAgentIdentityPda, deriveCompanyPda, deriveDailyAnchorPda, deriveDeploymentPda, deriveOperationsPda, derivePolicyPda, deriveProtocolFeePda, deriveTraceAnchorPda, deriveTreasuryPda, u32LeBytes };
|
package/dist/pda.js
CHANGED
|
@@ -6,10 +6,11 @@ import {
|
|
|
6
6
|
deriveOperationsPda,
|
|
7
7
|
derivePolicyPda,
|
|
8
8
|
deriveProtocolFeePda,
|
|
9
|
+
deriveTraceAnchorPda,
|
|
9
10
|
deriveTreasuryPda,
|
|
10
11
|
u32LeBytes
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-QZSQEGLT.js";
|
|
13
|
+
import "./chunk-BR62YC5F.js";
|
|
13
14
|
export {
|
|
14
15
|
deriveAgentIdentityPda,
|
|
15
16
|
deriveCompanyPda,
|
|
@@ -18,6 +19,7 @@ export {
|
|
|
18
19
|
deriveOperationsPda,
|
|
19
20
|
derivePolicyPda,
|
|
20
21
|
deriveProtocolFeePda,
|
|
22
|
+
deriveTraceAnchorPda,
|
|
21
23
|
deriveTreasuryPda,
|
|
22
24
|
u32LeBytes
|
|
23
25
|
};
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -33,6 +33,9 @@ export const OPERATIONS_SEED = Buffer.from("operations");
|
|
|
33
33
|
// DailyAnchor PDA seed (owned by registry program). Seeds:
|
|
34
34
|
// ["daily_anchor", deployment_pda, day_unix_le_i64_8bytes].
|
|
35
35
|
export const DAILY_ANCHOR_SEED = Buffer.from("daily_anchor");
|
|
36
|
+
// TraceAnchor PDA seed (owned by registry program). Seeds:
|
|
37
|
+
// ["trace", task_id_32bytes]. One per completed, verified deliverable.
|
|
38
|
+
export const TRACE_SEED = Buffer.from("trace");
|
|
36
39
|
|
|
37
40
|
// OperationsKind discriminator byte — must match the Rust enum order in
|
|
38
41
|
// `treasury/src/lib.rs`. Used as the 3rd seed byte of an OperationsAccount
|
|
@@ -40,7 +43,10 @@ export const DAILY_ANCHOR_SEED = Buffer.from("daily_anchor");
|
|
|
40
43
|
export const OPERATIONS_KIND = {
|
|
41
44
|
/** Disbursement Wallet — operator-held only, signs `disburse_routine`. */
|
|
42
45
|
Disbursement: 0,
|
|
43
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Anchor Wallet — operator+OCCA shared, signs `commit_daily_anchor`
|
|
48
|
+
* and `commit_trace`.
|
|
49
|
+
*/
|
|
44
50
|
Anchor: 1,
|
|
45
51
|
} as const;
|
|
46
52
|
export type OperationsKind =
|
|
@@ -57,6 +63,15 @@ export const MAX_LOCALE_LEN = 8;
|
|
|
57
63
|
export const MAX_ROLE_LEN = 32;
|
|
58
64
|
export const MAX_METADATA_URI_LEN = 200;
|
|
59
65
|
export const MAX_REPUTATION_URI_LEN = 200;
|
|
66
|
+
export const MAX_RESULT_URI_LEN = 200;
|
|
67
|
+
export const MAX_QUALITY_SCORE = 100;
|
|
68
|
+
|
|
69
|
+
// TraceAnchorAccount.verdict encoding — only Passed deliverables are
|
|
70
|
+
// anchored (failed/unverified work never reaches the chain).
|
|
71
|
+
export const TRACE_VERDICT = {
|
|
72
|
+
Passed: 1,
|
|
73
|
+
} as const;
|
|
74
|
+
export type TraceVerdict = (typeof TRACE_VERDICT)[keyof typeof TRACE_VERDICT];
|
|
60
75
|
|
|
61
76
|
// Status encodings — must match the on-chain constants.
|
|
62
77
|
export const COMPANY_STATUS = {
|
|
@@ -81,6 +96,7 @@ export const ACCOUNT_DISCRIMINATOR = {
|
|
|
81
96
|
CompanyAccount: Buffer.from([37, 215, 171, 200, 8, 141, 69, 96]),
|
|
82
97
|
Deployment: Buffer.from([66, 90, 104, 89, 183, 130, 64, 178]),
|
|
83
98
|
DailyAnchorAccount: Buffer.from([218, 106, 107, 94, 194, 48, 111, 254]),
|
|
99
|
+
TraceAnchorAccount: Buffer.from([159, 101, 186, 98, 211, 217, 119, 232]),
|
|
84
100
|
} as const;
|
|
85
101
|
|
|
86
102
|
// Treasury program account discriminators — from
|