@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.
@@ -12,10 +12,14 @@ declare const POLICY_SEED: Buffer<ArrayBuffer>;
12
12
  declare const PROTOCOL_FEES_SEED: Buffer<ArrayBuffer>;
13
13
  declare const OPERATIONS_SEED: Buffer<ArrayBuffer>;
14
14
  declare const DAILY_ANCHOR_SEED: Buffer<ArrayBuffer>;
15
+ declare const TRACE_SEED: Buffer<ArrayBuffer>;
15
16
  declare const OPERATIONS_KIND: {
16
17
  /** Disbursement Wallet — operator-held only, signs `disburse_routine`. */
17
18
  readonly Disbursement: 0;
18
- /** Anchor Wallet — operator+OCCA shared, signs `commit_daily_anchor`. */
19
+ /**
20
+ * Anchor Wallet — operator+OCCA shared, signs `commit_daily_anchor`
21
+ * and `commit_trace`.
22
+ */
19
23
  readonly Anchor: 1;
20
24
  };
21
25
  type OperationsKind = (typeof OPERATIONS_KIND)[keyof typeof OPERATIONS_KIND];
@@ -25,6 +29,12 @@ declare const MAX_LOCALE_LEN = 8;
25
29
  declare const MAX_ROLE_LEN = 32;
26
30
  declare const MAX_METADATA_URI_LEN = 200;
27
31
  declare const MAX_REPUTATION_URI_LEN = 200;
32
+ declare const MAX_RESULT_URI_LEN = 200;
33
+ declare const MAX_QUALITY_SCORE = 100;
34
+ declare const TRACE_VERDICT: {
35
+ readonly Passed: 1;
36
+ };
37
+ type TraceVerdict = (typeof TRACE_VERDICT)[keyof typeof TRACE_VERDICT];
28
38
  declare const COMPANY_STATUS: {
29
39
  readonly Active: 0;
30
40
  readonly Paused: 1;
@@ -42,6 +52,7 @@ declare const ACCOUNT_DISCRIMINATOR: {
42
52
  readonly CompanyAccount: Buffer<ArrayBuffer>;
43
53
  readonly Deployment: Buffer<ArrayBuffer>;
44
54
  readonly DailyAnchorAccount: Buffer<ArrayBuffer>;
55
+ readonly TraceAnchorAccount: Buffer<ArrayBuffer>;
45
56
  };
46
57
  declare const TREASURY_ACCOUNT_DISCRIMINATOR: {
47
58
  readonly TreasuryAccount: Buffer<ArrayBuffer>;
@@ -50,4 +61,4 @@ declare const TREASURY_ACCOUNT_DISCRIMINATOR: {
50
61
  readonly OperationsAccount: Buffer<ArrayBuffer>;
51
62
  };
52
63
 
53
- export { ACCOUNT_DISCRIMINATOR, AGENT_IDENTITY_SEED, COMPANY_SEED, COMPANY_STATUS, type CompanyStatus, DAILY_ANCHOR_SEED, DEPLOYMENT_SEED, DEPLOYMENT_STATUS, type DeploymentStatus, MAX_LOCALE_LEN, MAX_METADATA_URI_LEN, MAX_NAME_LEN, MAX_REPUTATION_URI_LEN, MAX_ROLE_LEN, OPERATIONS_KIND, OPERATIONS_SEED, type OperationsKind, POLICY_SEED, PROTOCOL_FEES_SEED, REGISTRY_PROGRAM_ID, REGISTRY_PROGRAM_ID_BASE58, SOL_PSEUDO_MINT, TREASURY_ACCOUNT_DISCRIMINATOR, TREASURY_PROGRAM_ID, TREASURY_PROGRAM_ID_BASE58, TREASURY_SEED };
64
+ export { ACCOUNT_DISCRIMINATOR, AGENT_IDENTITY_SEED, COMPANY_SEED, COMPANY_STATUS, type CompanyStatus, DAILY_ANCHOR_SEED, DEPLOYMENT_SEED, DEPLOYMENT_STATUS, type DeploymentStatus, MAX_LOCALE_LEN, MAX_METADATA_URI_LEN, MAX_NAME_LEN, MAX_QUALITY_SCORE, MAX_REPUTATION_URI_LEN, MAX_RESULT_URI_LEN, MAX_ROLE_LEN, OPERATIONS_KIND, OPERATIONS_SEED, type OperationsKind, POLICY_SEED, PROTOCOL_FEES_SEED, REGISTRY_PROGRAM_ID, REGISTRY_PROGRAM_ID_BASE58, SOL_PSEUDO_MINT, TRACE_SEED, TRACE_VERDICT, TREASURY_ACCOUNT_DISCRIMINATOR, TREASURY_PROGRAM_ID, TREASURY_PROGRAM_ID_BASE58, TREASURY_SEED, type TraceVerdict };
package/dist/constants.js CHANGED
@@ -9,7 +9,9 @@ import {
9
9
  MAX_LOCALE_LEN,
10
10
  MAX_METADATA_URI_LEN,
11
11
  MAX_NAME_LEN,
12
+ MAX_QUALITY_SCORE,
12
13
  MAX_REPUTATION_URI_LEN,
14
+ MAX_RESULT_URI_LEN,
13
15
  MAX_ROLE_LEN,
14
16
  OPERATIONS_KIND,
15
17
  OPERATIONS_SEED,
@@ -18,11 +20,13 @@ import {
18
20
  REGISTRY_PROGRAM_ID,
19
21
  REGISTRY_PROGRAM_ID_BASE58,
20
22
  SOL_PSEUDO_MINT,
23
+ TRACE_SEED,
24
+ TRACE_VERDICT,
21
25
  TREASURY_ACCOUNT_DISCRIMINATOR,
22
26
  TREASURY_PROGRAM_ID,
23
27
  TREASURY_PROGRAM_ID_BASE58,
24
28
  TREASURY_SEED
25
- } from "./chunk-YCSBYRSH.js";
29
+ } from "./chunk-BR62YC5F.js";
26
30
  export {
27
31
  ACCOUNT_DISCRIMINATOR,
28
32
  AGENT_IDENTITY_SEED,
@@ -34,7 +38,9 @@ export {
34
38
  MAX_LOCALE_LEN,
35
39
  MAX_METADATA_URI_LEN,
36
40
  MAX_NAME_LEN,
41
+ MAX_QUALITY_SCORE,
37
42
  MAX_REPUTATION_URI_LEN,
43
+ MAX_RESULT_URI_LEN,
38
44
  MAX_ROLE_LEN,
39
45
  OPERATIONS_KIND,
40
46
  OPERATIONS_SEED,
@@ -43,6 +49,8 @@ export {
43
49
  REGISTRY_PROGRAM_ID,
44
50
  REGISTRY_PROGRAM_ID_BASE58,
45
51
  SOL_PSEUDO_MINT,
52
+ TRACE_SEED,
53
+ TRACE_VERDICT,
46
54
  TREASURY_ACCOUNT_DISCRIMINATOR,
47
55
  TREASURY_PROGRAM_ID,
48
56
  TREASURY_PROGRAM_ID_BASE58,
package/dist/index.cjs CHANGED
@@ -31,7 +31,9 @@ __export(src_exports, {
31
31
  MAX_LOCALE_LEN: () => MAX_LOCALE_LEN,
32
32
  MAX_METADATA_URI_LEN: () => MAX_METADATA_URI_LEN,
33
33
  MAX_NAME_LEN: () => MAX_NAME_LEN,
34
+ MAX_QUALITY_SCORE: () => MAX_QUALITY_SCORE,
34
35
  MAX_REPUTATION_URI_LEN: () => MAX_REPUTATION_URI_LEN,
36
+ MAX_RESULT_URI_LEN: () => MAX_RESULT_URI_LEN,
35
37
  MAX_ROLE_LEN: () => MAX_ROLE_LEN,
36
38
  OPERATIONS_KIND: () => OPERATIONS_KIND,
37
39
  OPERATIONS_SEED: () => OPERATIONS_SEED,
@@ -40,6 +42,8 @@ __export(src_exports, {
40
42
  REGISTRY_PROGRAM_ID: () => REGISTRY_PROGRAM_ID,
41
43
  REGISTRY_PROGRAM_ID_BASE58: () => REGISTRY_PROGRAM_ID_BASE58,
42
44
  SOL_PSEUDO_MINT: () => SOL_PSEUDO_MINT,
45
+ TRACE_SEED: () => TRACE_SEED,
46
+ TRACE_VERDICT: () => TRACE_VERDICT,
43
47
  TREASURY_ACCOUNT_DISCRIMINATOR: () => TREASURY_ACCOUNT_DISCRIMINATOR,
44
48
  TREASURY_INSTRUCTION_DISCRIMINATOR: () => TREASURY_INSTRUCTION_DISCRIMINATOR,
45
49
  TREASURY_PROGRAM_ID: () => TREASURY_PROGRAM_ID,
@@ -47,6 +51,7 @@ __export(src_exports, {
47
51
  TREASURY_SEED: () => TREASURY_SEED,
48
52
  buildCloseOperationsInstruction: () => buildCloseOperationsInstruction,
49
53
  buildCommitDailyAnchorInstruction: () => buildCommitDailyAnchorInstruction,
54
+ buildCommitTraceInstruction: () => buildCommitTraceInstruction,
50
55
  buildCreateCompanyInstruction: () => buildCreateCompanyInstruction,
51
56
  buildCreateDeploymentInstruction: () => buildCreateDeploymentInstruction,
52
57
  buildDisburseDiscretionaryInstruction: () => buildDisburseDiscretionaryInstruction,
@@ -57,6 +62,7 @@ __export(src_exports, {
57
62
  buildRegisterCompanyOperationsInstruction: () => buildRegisterCompanyOperationsInstruction,
58
63
  buildRetireDeploymentInstruction: () => buildRetireDeploymentInstruction,
59
64
  buildRevokeOperationsInstruction: () => buildRevokeOperationsInstruction,
65
+ buildSetAgentReceivingAddressInstruction: () => buildSetAgentReceivingAddressInstruction,
60
66
  buildSetPolicyInstruction: () => buildSetPolicyInstruction,
61
67
  buildSetReceivingAddressInstruction: () => buildSetReceivingAddressInstruction,
62
68
  buildUpdateAgentIdentityMetadataInstruction: () => buildUpdateAgentIdentityMetadataInstruction,
@@ -72,6 +78,7 @@ __export(src_exports, {
72
78
  deriveOperationsPda: () => deriveOperationsPda,
73
79
  derivePolicyPda: () => derivePolicyPda,
74
80
  deriveProtocolFeePda: () => deriveProtocolFeePda,
81
+ deriveTraceAnchorPda: () => deriveTraceAnchorPda,
75
82
  deriveTreasuryPda: () => deriveTreasuryPda,
76
83
  u32LeBytes: () => u32LeBytes
77
84
  });
@@ -91,10 +98,14 @@ var POLICY_SEED = Buffer.from("policy");
91
98
  var PROTOCOL_FEES_SEED = Buffer.from("protocol_fees");
92
99
  var OPERATIONS_SEED = Buffer.from("operations");
93
100
  var DAILY_ANCHOR_SEED = Buffer.from("daily_anchor");
101
+ var TRACE_SEED = Buffer.from("trace");
94
102
  var OPERATIONS_KIND = {
95
103
  /** Disbursement Wallet — operator-held only, signs `disburse_routine`. */
96
104
  Disbursement: 0,
97
- /** Anchor Wallet — operator+OCCA shared, signs `commit_daily_anchor`. */
105
+ /**
106
+ * Anchor Wallet — operator+OCCA shared, signs `commit_daily_anchor`
107
+ * and `commit_trace`.
108
+ */
98
109
  Anchor: 1
99
110
  };
100
111
  var SOL_PSEUDO_MINT = new import_web3.PublicKey(new Uint8Array(32));
@@ -103,6 +114,11 @@ var MAX_LOCALE_LEN = 8;
103
114
  var MAX_ROLE_LEN = 32;
104
115
  var MAX_METADATA_URI_LEN = 200;
105
116
  var MAX_REPUTATION_URI_LEN = 200;
117
+ var MAX_RESULT_URI_LEN = 200;
118
+ var MAX_QUALITY_SCORE = 100;
119
+ var TRACE_VERDICT = {
120
+ Passed: 1
121
+ };
106
122
  var COMPANY_STATUS = {
107
123
  Active: 0,
108
124
  Paused: 1
@@ -117,7 +133,8 @@ var ACCOUNT_DISCRIMINATOR = {
117
133
  AgentIdentity: Buffer.from([11, 149, 31, 27, 186, 76, 241, 72]),
118
134
  CompanyAccount: Buffer.from([37, 215, 171, 200, 8, 141, 69, 96]),
119
135
  Deployment: Buffer.from([66, 90, 104, 89, 183, 130, 64, 178]),
120
- DailyAnchorAccount: Buffer.from([218, 106, 107, 94, 194, 48, 111, 254])
136
+ DailyAnchorAccount: Buffer.from([218, 106, 107, 94, 194, 48, 111, 254]),
137
+ TraceAnchorAccount: Buffer.from([159, 101, 186, 98, 211, 217, 119, 232])
121
138
  };
122
139
  var TREASURY_ACCOUNT_DISCRIMINATOR = {
123
140
  TreasuryAccount: Buffer.from([204, 140, 18, 173, 90, 152, 134, 123]),
@@ -197,6 +214,16 @@ function deriveDailyAnchorPda(deploymentPda, dayUnix, programId = REGISTRY_PROGR
197
214
  );
198
215
  return { pda, bump };
199
216
  }
217
+ function deriveTraceAnchorPda(taskId, programId = REGISTRY_PROGRAM_ID) {
218
+ if (taskId.length !== 32) {
219
+ throw new RangeError(`taskId must be 32 bytes, got ${taskId.length}`);
220
+ }
221
+ const [pda, bump] = import_web32.PublicKey.findProgramAddressSync(
222
+ [TRACE_SEED, Buffer.from(taskId)],
223
+ programId
224
+ );
225
+ return { pda, bump };
226
+ }
200
227
 
201
228
  // src/instructions.ts
202
229
  var import_web33 = require("@solana/web3.js");
@@ -220,7 +247,9 @@ var INSTRUCTION_DISCRIMINATOR = {
220
247
  updateDeploymentStatus: Buffer.from([225, 195, 150, 254, 178, 203, 53, 147]),
221
248
  retireDeployment: Buffer.from([45, 188, 162, 197, 136, 180, 202, 153]),
222
249
  setReceivingAddress: Buffer.from([70, 63, 44, 87, 16, 6, 156, 200]),
223
- commitDailyAnchor: Buffer.from([18, 7, 3, 65, 58, 148, 164, 0])
250
+ setAgentReceivingAddress: Buffer.from([197, 126, 122, 18, 38, 62, 179, 218]),
251
+ commitDailyAnchor: Buffer.from([18, 7, 3, 65, 58, 148, 164, 0]),
252
+ commitTrace: Buffer.from([58, 140, 230, 51, 170, 109, 228, 125])
224
253
  };
225
254
  function encodeString(s) {
226
255
  const utf8 = Buffer.from(s, "utf8");
@@ -454,6 +483,22 @@ function buildSetReceivingAddressInstruction(params) {
454
483
  });
455
484
  return { instruction };
456
485
  }
486
+ function buildSetAgentReceivingAddressInstruction(params) {
487
+ const programId = params.programId ?? REGISTRY_PROGRAM_ID;
488
+ const data = Buffer.concat([
489
+ INSTRUCTION_DISCRIMINATOR.setAgentReceivingAddress,
490
+ encodePubkey(params.newReceivingAddress)
491
+ ]);
492
+ const instruction = new import_web33.TransactionInstruction({
493
+ programId,
494
+ keys: [
495
+ { pubkey: params.identityPda, isSigner: false, isWritable: true },
496
+ { pubkey: params.owner, isSigner: true, isWritable: false }
497
+ ],
498
+ data
499
+ });
500
+ return { instruction };
501
+ }
457
502
  var TREASURY_INSTRUCTION_DISCRIMINATOR = {
458
503
  setPolicy: Buffer.from([40, 133, 12, 157, 235, 202, 2, 132]),
459
504
  disburseDiscretionary: Buffer.from([102, 176, 14, 127, 210, 4, 96, 175]),
@@ -810,6 +855,60 @@ function buildCommitDailyAnchorInstruction(params) {
810
855
  });
811
856
  return { instruction };
812
857
  }
858
+ function buildCommitTraceInstruction(params) {
859
+ const programId = params.programId ?? REGISTRY_PROGRAM_ID;
860
+ if (params.taskId.length !== 32) {
861
+ throw new RangeError(`taskId must be 32 bytes, got ${params.taskId.length}`);
862
+ }
863
+ if (params.contentHash.length !== 32) {
864
+ throw new RangeError(
865
+ `contentHash must be 32 bytes, got ${params.contentHash.length}`
866
+ );
867
+ }
868
+ if (params.evidenceHash.length !== 32) {
869
+ throw new RangeError(
870
+ `evidenceHash must be 32 bytes, got ${params.evidenceHash.length}`
871
+ );
872
+ }
873
+ if (Buffer.from(params.resultUri, "utf8").length > MAX_RESULT_URI_LEN) {
874
+ throw new RangeError(
875
+ `resultUri exceeds MAX_RESULT_URI_LEN (${MAX_RESULT_URI_LEN} bytes)`
876
+ );
877
+ }
878
+ if (params.qualityScore < 0 || params.qualityScore > MAX_QUALITY_SCORE) {
879
+ throw new RangeError(
880
+ `qualityScore out of range 0..=${MAX_QUALITY_SCORE}: ${params.qualityScore}`
881
+ );
882
+ }
883
+ const taskId = Buffer.from(params.taskId);
884
+ const { pda: traceAnchorPda } = deriveTraceAnchorPda(taskId, programId);
885
+ const data = Buffer.concat([
886
+ INSTRUCTION_DISCRIMINATOR.commitTrace,
887
+ taskId,
888
+ encodeString(params.resultUri),
889
+ Buffer.from(params.contentHash),
890
+ encodeU8(params.qualityScore),
891
+ encodeU8(params.rubricVersion),
892
+ Buffer.from(params.evidenceHash),
893
+ encodeI64(params.completedAt)
894
+ ]);
895
+ const instruction = new import_web33.TransactionInstruction({
896
+ programId,
897
+ // Order: deployment, company, anchor_signer, operations, trace_anchor,
898
+ // payer, system_program.
899
+ keys: [
900
+ { pubkey: params.deploymentPda, isSigner: false, isWritable: false },
901
+ { pubkey: params.companyPda, isSigner: false, isWritable: false },
902
+ { pubkey: params.anchorSigner, isSigner: true, isWritable: false },
903
+ { pubkey: params.operationsPda, isSigner: false, isWritable: false },
904
+ { pubkey: traceAnchorPda, isSigner: false, isWritable: true },
905
+ { pubkey: params.payer, isSigner: true, isWritable: true },
906
+ { pubkey: import_web33.SystemProgram.programId, isSigner: false, isWritable: false }
907
+ ],
908
+ data
909
+ });
910
+ return { instruction, traceAnchorPda };
911
+ }
813
912
  // Annotate the CommonJS export names for ESM import in node:
814
913
  0 && (module.exports = {
815
914
  ACCOUNT_DISCRIMINATOR,
@@ -823,7 +922,9 @@ function buildCommitDailyAnchorInstruction(params) {
823
922
  MAX_LOCALE_LEN,
824
923
  MAX_METADATA_URI_LEN,
825
924
  MAX_NAME_LEN,
925
+ MAX_QUALITY_SCORE,
826
926
  MAX_REPUTATION_URI_LEN,
927
+ MAX_RESULT_URI_LEN,
827
928
  MAX_ROLE_LEN,
828
929
  OPERATIONS_KIND,
829
930
  OPERATIONS_SEED,
@@ -832,6 +933,8 @@ function buildCommitDailyAnchorInstruction(params) {
832
933
  REGISTRY_PROGRAM_ID,
833
934
  REGISTRY_PROGRAM_ID_BASE58,
834
935
  SOL_PSEUDO_MINT,
936
+ TRACE_SEED,
937
+ TRACE_VERDICT,
835
938
  TREASURY_ACCOUNT_DISCRIMINATOR,
836
939
  TREASURY_INSTRUCTION_DISCRIMINATOR,
837
940
  TREASURY_PROGRAM_ID,
@@ -839,6 +942,7 @@ function buildCommitDailyAnchorInstruction(params) {
839
942
  TREASURY_SEED,
840
943
  buildCloseOperationsInstruction,
841
944
  buildCommitDailyAnchorInstruction,
945
+ buildCommitTraceInstruction,
842
946
  buildCreateCompanyInstruction,
843
947
  buildCreateDeploymentInstruction,
844
948
  buildDisburseDiscretionaryInstruction,
@@ -849,6 +953,7 @@ function buildCommitDailyAnchorInstruction(params) {
849
953
  buildRegisterCompanyOperationsInstruction,
850
954
  buildRetireDeploymentInstruction,
851
955
  buildRevokeOperationsInstruction,
956
+ buildSetAgentReceivingAddressInstruction,
852
957
  buildSetPolicyInstruction,
853
958
  buildSetReceivingAddressInstruction,
854
959
  buildUpdateAgentIdentityMetadataInstruction,
@@ -864,6 +969,7 @@ function buildCommitDailyAnchorInstruction(params) {
864
969
  deriveOperationsPda,
865
970
  derivePolicyPda,
866
971
  deriveProtocolFeePda,
972
+ deriveTraceAnchorPda,
867
973
  deriveTreasuryPda,
868
974
  u32LeBytes
869
975
  });