@ottochain/sdk 1.4.1 → 1.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.
Files changed (38) hide show
  1. package/dist/cjs/ottochain/normalize.js +23 -12
  2. package/dist/esm/apps/contracts/index.js +10 -28
  3. package/dist/esm/apps/corporate/index.js +24 -79
  4. package/dist/esm/apps/governance/index.js +36 -85
  5. package/dist/esm/apps/identity/constants.js +22 -27
  6. package/dist/esm/apps/identity/index.js +7 -35
  7. package/dist/esm/apps/index.js +6 -32
  8. package/dist/esm/apps/markets/index.js +6 -27
  9. package/dist/esm/apps/oracles/index.js +7 -27
  10. package/dist/esm/errors.js +9 -19
  11. package/dist/esm/generated/google/protobuf/struct.js +33 -39
  12. package/dist/esm/generated/google/protobuf/timestamp.js +6 -9
  13. package/dist/esm/generated/index.js +10 -134
  14. package/dist/esm/generated/ottochain/apps/contracts/v1/contract.js +48 -54
  15. package/dist/esm/generated/ottochain/apps/corporate/v1/corporate.js +335 -357
  16. package/dist/esm/generated/ottochain/apps/governance/v1/governance.js +284 -299
  17. package/dist/esm/generated/ottochain/apps/identity/v1/agent.js +38 -47
  18. package/dist/esm/generated/ottochain/apps/identity/v1/attestation.js +44 -50
  19. package/dist/esm/generated/ottochain/apps/markets/v1/market.js +77 -86
  20. package/dist/esm/generated/ottochain/apps/oracles/v1/oracle.js +66 -72
  21. package/dist/esm/generated/ottochain/v1/common.js +1 -4
  22. package/dist/esm/generated/ottochain/v1/fiber.js +90 -96
  23. package/dist/esm/generated/ottochain/v1/messages.js +79 -82
  24. package/dist/esm/generated/ottochain/v1/records.js +137 -140
  25. package/dist/esm/index.js +13 -70
  26. package/dist/esm/ottochain/drop-nulls.js +1 -5
  27. package/dist/esm/ottochain/index.js +6 -54
  28. package/dist/esm/ottochain/metagraph-client.js +12 -16
  29. package/dist/esm/ottochain/normalize.js +27 -23
  30. package/dist/esm/ottochain/snapshot.js +10 -20
  31. package/dist/esm/ottochain/transaction.js +13 -25
  32. package/dist/esm/ottochain/types.js +1 -2
  33. package/dist/esm/types.js +2 -7
  34. package/dist/esm/validation.js +65 -76
  35. package/dist/esm/verify.js +3 -7
  36. package/dist/types/ottochain/normalize.d.ts +7 -8
  37. package/dist/types/ottochain/types.d.ts +3 -1
  38. package/package.json +7 -7
@@ -1,13 +1,10 @@
1
- "use strict";
2
1
  /**
3
2
  * Transaction Helpers for Self-Signed Mode
4
3
  *
5
4
  * These helpers create properly formatted payloads for the bridge's
6
5
  * self-signed mode, where clients sign their own transactions.
7
6
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getPublicKeyForRegistration = exports.addTransactionSignature = exports.createDataTransactionRequest = exports.signTransaction = exports.createInvokeScriptPayload = exports.createScriptPayload = exports.createArchivePayload = exports.createTransitionPayload = exports.createStateMachinePayload = void 0;
10
- const metagraph_sdk_1 = require("@constellation-network/metagraph-sdk");
7
+ import { signDataUpdate, getPublicKeyId } from '@constellation-network/metagraph-sdk';
11
8
  /**
12
9
  * Create a new state machine fiber payload.
13
10
  *
@@ -27,7 +24,7 @@ const metagraph_sdk_1 = require("@constellation-network/metagraph-sdk");
27
24
  * const signed = await signTransaction(create, privateKey);
28
25
  * ```
29
26
  */
30
- function createStateMachinePayload(params) {
27
+ export function createStateMachinePayload(params) {
31
28
  return {
32
29
  CreateStateMachine: {
33
30
  fiberId: params.fiberId,
@@ -37,7 +34,6 @@ function createStateMachinePayload(params) {
37
34
  },
38
35
  };
39
36
  }
40
- exports.createStateMachinePayload = createStateMachinePayload;
41
37
  /**
42
38
  * Create a transition payload ready for signing.
43
39
  *
@@ -56,7 +52,7 @@ exports.createStateMachinePayload = createStateMachinePayload;
56
52
  * });
57
53
  * ```
58
54
  */
59
- function createTransitionPayload(params) {
55
+ export function createTransitionPayload(params) {
60
56
  return {
61
57
  TransitionStateMachine: {
62
58
  fiberId: params.fiberId,
@@ -66,14 +62,13 @@ function createTransitionPayload(params) {
66
62
  },
67
63
  };
68
64
  }
69
- exports.createTransitionPayload = createTransitionPayload;
70
65
  /**
71
66
  * Create an archive payload ready for signing.
72
67
  *
73
68
  * @param params - Archive parameters
74
69
  * @returns An ArchiveStateMachine message ready for signing
75
70
  */
76
- function createArchivePayload(params) {
71
+ export function createArchivePayload(params) {
77
72
  return {
78
73
  ArchiveStateMachine: {
79
74
  fiberId: params.fiberId,
@@ -81,7 +76,6 @@ function createArchivePayload(params) {
81
76
  },
82
77
  };
83
78
  }
84
- exports.createArchivePayload = createArchivePayload;
85
79
  /**
86
80
  * Create a new script fiber payload.
87
81
  *
@@ -105,7 +99,7 @@ exports.createArchivePayload = createArchivePayload;
105
99
  * const signed = await signTransaction(script, privateKey);
106
100
  * ```
107
101
  */
108
- function createScriptPayload(params) {
102
+ export function createScriptPayload(params) {
109
103
  return {
110
104
  CreateScript: {
111
105
  fiberId: params.fiberId,
@@ -115,14 +109,13 @@ function createScriptPayload(params) {
115
109
  },
116
110
  };
117
111
  }
118
- exports.createScriptPayload = createScriptPayload;
119
112
  /**
120
113
  * Create an invoke script payload ready for signing.
121
114
  *
122
115
  * @param params - Invoke script parameters
123
116
  * @returns An InvokeScript message ready for signing
124
117
  */
125
- function createInvokeScriptPayload(params) {
118
+ export function createInvokeScriptPayload(params) {
126
119
  return {
127
120
  InvokeScript: {
128
121
  fiberId: params.fiberId,
@@ -132,7 +125,6 @@ function createInvokeScriptPayload(params) {
132
125
  },
133
126
  };
134
127
  }
135
- exports.createInvokeScriptPayload = createInvokeScriptPayload;
136
128
  /**
137
129
  * Sign a transaction payload for self-signed mode.
138
130
  *
@@ -170,14 +162,13 @@ exports.createInvokeScriptPayload = createInvokeScriptPayload;
170
162
  * });
171
163
  * ```
172
164
  */
173
- async function signTransaction(message, privateKey) {
174
- const proof = await (0, metagraph_sdk_1.signDataUpdate)(message, privateKey);
165
+ export async function signTransaction(message, privateKey) {
166
+ const proof = await signDataUpdate(message, privateKey);
175
167
  return {
176
168
  value: message,
177
169
  proofs: [proof],
178
170
  };
179
171
  }
180
- exports.signTransaction = signTransaction;
181
172
  /**
182
173
  * Wrap a signed transaction in the DataTransactionRequest format
183
174
  * expected by tessellation's DL1 `/data` endpoint.
@@ -199,10 +190,9 @@ exports.signTransaction = signTransaction;
199
190
  * });
200
191
  * ```
201
192
  */
202
- function createDataTransactionRequest(signed) {
193
+ export function createDataTransactionRequest(signed) {
203
194
  return { data: signed, fee: null };
204
195
  }
205
- exports.createDataTransactionRequest = createDataTransactionRequest;
206
196
  /**
207
197
  * Add an additional signature to a signed transaction.
208
198
  *
@@ -213,14 +203,13 @@ exports.createDataTransactionRequest = createDataTransactionRequest;
213
203
  * @param privateKey - Additional signer's private key
214
204
  * @returns Transaction with additional signature
215
205
  */
216
- async function addTransactionSignature(signed, privateKey) {
217
- const newProof = await (0, metagraph_sdk_1.signDataUpdate)(signed.value, privateKey);
206
+ export async function addTransactionSignature(signed, privateKey) {
207
+ const newProof = await signDataUpdate(signed.value, privateKey);
218
208
  return {
219
209
  value: signed.value,
220
210
  proofs: [...signed.proofs, newProof],
221
211
  };
222
212
  }
223
- exports.addTransactionSignature = addTransactionSignature;
224
213
  /**
225
214
  * Get the public key ID from a private key in the format expected by registration.
226
215
  *
@@ -245,7 +234,6 @@ exports.addTransactionSignature = addTransactionSignature;
245
234
  * });
246
235
  * ```
247
236
  */
248
- function getPublicKeyForRegistration(privateKey) {
249
- return (0, metagraph_sdk_1.getPublicKeyId)(privateKey);
237
+ export function getPublicKeyForRegistration(privateKey) {
238
+ return getPublicKeyId(privateKey);
250
239
  }
251
- exports.getPublicKeyForRegistration = getPublicKeyForRegistration;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * Ottochain-specific type definitions
4
3
  *
@@ -8,4 +7,4 @@
8
7
  * @see modules/models/src/main/scala/xyz/kd5ujc/schema/
9
8
  * @packageDocumentation
10
9
  */
11
- Object.defineProperty(exports, "__esModule", { value: true });
10
+ export {};
package/dist/esm/types.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * OttoChain Type Aliases
4
3
  *
@@ -7,19 +6,15 @@
7
6
  *
8
7
  * @packageDocumentation
9
8
  */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.isValidFiberId = exports.isValidAddress = void 0;
12
9
  /**
13
10
  * Validate a DAG address format.
14
11
  */
15
- function isValidAddress(value) {
12
+ export function isValidAddress(value) {
16
13
  return /^DAG[0-9a-zA-Z]+$/.test(value);
17
14
  }
18
- exports.isValidAddress = isValidAddress;
19
15
  /**
20
16
  * Validate a UUID format.
21
17
  */
22
- function isValidFiberId(value) {
18
+ export function isValidFiberId(value) {
23
19
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
24
20
  }
25
- exports.isValidFiberId = isValidFiberId;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * Input Validation with Zod Schemas
4
3
  *
@@ -6,10 +5,8 @@
6
5
  *
7
6
  * @packageDocumentation
8
7
  */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.assert = exports.safeParse = exports.validateKeyPair = exports.validateAddress = exports.validatePublicKey = exports.validatePrivateKey = exports.validate = exports.CompleteContractRequestSchema = exports.AcceptContractRequestSchema = exports.ProposeContractRequestSchema = exports.ContractTermsSchema = exports.PlatformLinkSchema = exports.AgentIdentityRegistrationSchema = exports.TransferParamsSchema = exports.CurrencyTransactionSchema = exports.CurrencyTransactionValueSchema = exports.TransactionReferenceSchema = exports.SignedSchema = exports.SignatureProofSchema = exports.KeyPairSchema = exports.PublicKeySchema = exports.PrivateKeySchema = exports.DagAddressSchema = void 0;
11
- const zod_1 = require("zod");
12
- const errors_js_1 = require("./errors.js");
8
+ import { z } from 'zod';
9
+ import { ValidationError } from './errors.js';
13
10
  // ============================================================================
14
11
  // Primitive Schemas
15
12
  // ============================================================================
@@ -17,7 +14,7 @@ const errors_js_1 = require("./errors.js");
17
14
  * Schema for a hex string of specific length
18
15
  */
19
16
  const hexString = (length) => {
20
- let schema = zod_1.z.string().regex(/^[0-9a-fA-F]+$/, 'Must be a valid hex string');
17
+ let schema = z.string().regex(/^[0-9a-fA-F]+$/, 'Must be a valid hex string');
21
18
  if (length !== undefined) {
22
19
  schema = schema.length(length, `Must be exactly ${length} characters`);
23
20
  }
@@ -26,7 +23,7 @@ const hexString = (length) => {
26
23
  /**
27
24
  * Schema for a DAG address
28
25
  */
29
- exports.DagAddressSchema = zod_1.z
26
+ export const DagAddressSchema = z
30
27
  .string()
31
28
  .regex(/^DAG[0-9][a-zA-Z0-9]{36}$/, 'Must be a valid DAG address');
32
29
  // ============================================================================
@@ -35,29 +32,29 @@ exports.DagAddressSchema = zod_1.z
35
32
  /**
36
33
  * Schema for a private key (64-character hex string)
37
34
  */
38
- exports.PrivateKeySchema = hexString(64).describe('Private key in hex format (64 characters)');
35
+ export const PrivateKeySchema = hexString(64).describe('Private key in hex format (64 characters)');
39
36
  /**
40
37
  * Schema for a public key (128 or 130 character hex string)
41
38
  */
42
- exports.PublicKeySchema = zod_1.z
39
+ export const PublicKeySchema = z
43
40
  .string()
44
41
  .regex(/^(04)?[0-9a-fA-F]{128}$/, 'Must be a valid public key (128 or 130 hex chars)')
45
42
  .describe('Public key in hex format (with optional 04 prefix)');
46
43
  /**
47
44
  * Schema for a KeyPair
48
45
  */
49
- exports.KeyPairSchema = zod_1.z.object({
46
+ export const KeyPairSchema = z.object({
50
47
  /** Private key in hex format */
51
- privateKey: exports.PrivateKeySchema,
48
+ privateKey: PrivateKeySchema,
52
49
  /** Public key in hex format (uncompressed, with 04 prefix) */
53
- publicKey: exports.PublicKeySchema,
50
+ publicKey: PublicKeySchema,
54
51
  /** DAG address derived from the public key */
55
- address: exports.DagAddressSchema,
52
+ address: DagAddressSchema,
56
53
  });
57
54
  /**
58
55
  * Schema for a SignatureProof
59
56
  */
60
- exports.SignatureProofSchema = zod_1.z.object({
57
+ export const SignatureProofSchema = z.object({
61
58
  /** Public key hex (uncompressed, without 04 prefix) - 128 characters */
62
59
  id: hexString(128),
63
60
  /** DER-encoded ECDSA signature in hex format */
@@ -66,45 +63,44 @@ exports.SignatureProofSchema = zod_1.z.object({
66
63
  /**
67
64
  * Schema for a Signed object (generic)
68
65
  */
69
- const SignedSchema = (valueSchema) => zod_1.z.object({
66
+ export const SignedSchema = (valueSchema) => z.object({
70
67
  value: valueSchema,
71
- proofs: zod_1.z.array(exports.SignatureProofSchema).min(1, 'At least one proof is required'),
68
+ proofs: z.array(SignatureProofSchema).min(1, 'At least one proof is required'),
72
69
  });
73
- exports.SignedSchema = SignedSchema;
74
70
  // ============================================================================
75
71
  // Transaction Schemas
76
72
  // ============================================================================
77
73
  /**
78
74
  * Schema for TransactionReference
79
75
  */
80
- exports.TransactionReferenceSchema = zod_1.z.object({
81
- ordinal: zod_1.z.number().int().min(0),
82
- hash: zod_1.z.string().min(1),
76
+ export const TransactionReferenceSchema = z.object({
77
+ ordinal: z.number().int().min(0),
78
+ hash: z.string().min(1),
83
79
  });
84
80
  /**
85
81
  * Schema for CurrencyTransactionValue
86
82
  */
87
- exports.CurrencyTransactionValueSchema = zod_1.z.object({
88
- source: exports.DagAddressSchema,
89
- destination: exports.DagAddressSchema,
90
- amount: zod_1.z.number().int().positive('Amount must be positive'),
91
- fee: zod_1.z.number().int().min(0).default(0),
83
+ export const CurrencyTransactionValueSchema = z.object({
84
+ source: DagAddressSchema,
85
+ destination: DagAddressSchema,
86
+ amount: z.number().int().positive('Amount must be positive'),
87
+ fee: z.number().int().min(0).default(0),
92
88
  });
93
89
  /**
94
90
  * Schema for CurrencyTransaction
95
91
  */
96
- exports.CurrencyTransactionSchema = zod_1.z.object({
97
- value: exports.CurrencyTransactionValueSchema,
98
- parent: exports.TransactionReferenceSchema,
92
+ export const CurrencyTransactionSchema = z.object({
93
+ value: CurrencyTransactionValueSchema,
94
+ parent: TransactionReferenceSchema,
99
95
  });
100
96
  /**
101
97
  * Schema for TransferParams
102
98
  */
103
- exports.TransferParamsSchema = zod_1.z.object({
104
- from: exports.DagAddressSchema,
105
- to: exports.DagAddressSchema,
106
- amount: zod_1.z.number().positive('Amount must be positive'),
107
- fee: zod_1.z.number().min(0).optional().default(0),
99
+ export const TransferParamsSchema = z.object({
100
+ from: DagAddressSchema,
101
+ to: DagAddressSchema,
102
+ amount: z.number().positive('Amount must be positive'),
103
+ fee: z.number().min(0).optional().default(0),
108
104
  });
109
105
  // ============================================================================
110
106
  // Identity Schemas
@@ -112,22 +108,22 @@ exports.TransferParamsSchema = zod_1.z.object({
112
108
  /**
113
109
  * Schema for AgentIdentity registration
114
110
  */
115
- exports.AgentIdentityRegistrationSchema = zod_1.z.object({
111
+ export const AgentIdentityRegistrationSchema = z.object({
116
112
  /** Public key in hex format */
117
- publicKey: exports.PublicKeySchema,
113
+ publicKey: PublicKeySchema,
118
114
  /** Display name for the agent */
119
- displayName: zod_1.z.string().min(1).max(64),
115
+ displayName: z.string().min(1).max(64),
120
116
  /** Initial reputation (default: 10) */
121
- reputation: zod_1.z.number().int().min(0).optional().default(10),
117
+ reputation: z.number().int().min(0).optional().default(10),
122
118
  });
123
119
  /**
124
120
  * Schema for PlatformLink
125
121
  */
126
- exports.PlatformLinkSchema = zod_1.z.object({
127
- platform: zod_1.z.enum(['DISCORD', 'TELEGRAM', 'TWITTER', 'GITHUB', 'CUSTOM']),
128
- platformUserId: zod_1.z.string().min(1),
129
- platformUsername: zod_1.z.string().min(1),
130
- verified: zod_1.z.boolean().optional().default(false),
122
+ export const PlatformLinkSchema = z.object({
123
+ platform: z.enum(['DISCORD', 'TELEGRAM', 'TWITTER', 'GITHUB', 'CUSTOM']),
124
+ platformUserId: z.string().min(1),
125
+ platformUsername: z.string().min(1),
126
+ verified: z.boolean().optional().default(false),
131
127
  });
132
128
  // ============================================================================
133
129
  // Contract Schemas
@@ -135,39 +131,39 @@ exports.PlatformLinkSchema = zod_1.z.object({
135
131
  /**
136
132
  * Schema for contract terms (flexible structure)
137
133
  */
138
- exports.ContractTermsSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
134
+ export const ContractTermsSchema = z.record(z.string(), z.unknown());
139
135
  /**
140
136
  * Schema for ProposeContractRequest
141
137
  */
142
- exports.ProposeContractRequestSchema = zod_1.z.object({
138
+ export const ProposeContractRequestSchema = z.object({
143
139
  /** Proposer's DAG address */
144
- proposer: exports.DagAddressSchema,
140
+ proposer: DagAddressSchema,
145
141
  /** Counterparty's DAG address */
146
- counterparty: exports.DagAddressSchema,
142
+ counterparty: DagAddressSchema,
147
143
  /** Contract terms */
148
- terms: exports.ContractTermsSchema,
144
+ terms: ContractTermsSchema,
149
145
  /** Human-readable description */
150
- description: zod_1.z.string().min(1).max(1000),
146
+ description: z.string().min(1).max(1000),
151
147
  });
152
148
  /**
153
149
  * Schema for AcceptContractRequest
154
150
  */
155
- exports.AcceptContractRequestSchema = zod_1.z.object({
151
+ export const AcceptContractRequestSchema = z.object({
156
152
  /** Contract ID to accept */
157
- contractId: zod_1.z.string().min(1),
153
+ contractId: z.string().min(1),
158
154
  /** Acceptor's DAG address */
159
- acceptor: exports.DagAddressSchema,
155
+ acceptor: DagAddressSchema,
160
156
  });
161
157
  /**
162
158
  * Schema for CompleteContractRequest
163
159
  */
164
- exports.CompleteContractRequestSchema = zod_1.z.object({
160
+ export const CompleteContractRequestSchema = z.object({
165
161
  /** Contract ID to complete */
166
- contractId: zod_1.z.string().min(1),
162
+ contractId: z.string().min(1),
167
163
  /** Completer's DAG address */
168
- completer: exports.DagAddressSchema,
164
+ completer: DagAddressSchema,
169
165
  /** Proof of completion */
170
- proof: zod_1.z.string().min(1),
166
+ proof: z.string().min(1),
171
167
  });
172
168
  // ============================================================================
173
169
  // Validation Helpers
@@ -187,7 +183,7 @@ exports.CompleteContractRequestSchema = zod_1.z.object({
187
183
  * // keyPair is now typed as ValidatedKeyPair
188
184
  * ```
189
185
  */
190
- function validate(schema, data, fieldName) {
186
+ export function validate(schema, data, fieldName) {
191
187
  const result = schema.safeParse(data);
192
188
  if (!result.success) {
193
189
  const issues = result.error.issues;
@@ -195,7 +191,7 @@ function validate(schema, data, fieldName) {
195
191
  // Build a helpful error message
196
192
  const path = firstIssue.path.length > 0 ? firstIssue.path.join('.') : fieldName || 'input';
197
193
  const message = `Validation failed for '${path}': ${firstIssue.message}`;
198
- throw new errors_js_1.ValidationError(message, {
194
+ throw new ValidationError(message, {
199
195
  field: path,
200
196
  value: data,
201
197
  details: {
@@ -209,7 +205,6 @@ function validate(schema, data, fieldName) {
209
205
  }
210
206
  return result.data;
211
207
  }
212
- exports.validate = validate;
213
208
  /**
214
209
  * Validate a private key
215
210
  *
@@ -217,10 +212,9 @@ exports.validate = validate;
217
212
  * @returns Validated private key
218
213
  * @throws {ValidationError} If validation fails
219
214
  */
220
- function validatePrivateKey(privateKey) {
221
- return validate(exports.PrivateKeySchema, privateKey, 'privateKey');
215
+ export function validatePrivateKey(privateKey) {
216
+ return validate(PrivateKeySchema, privateKey, 'privateKey');
222
217
  }
223
- exports.validatePrivateKey = validatePrivateKey;
224
218
  /**
225
219
  * Validate a public key
226
220
  *
@@ -228,10 +222,9 @@ exports.validatePrivateKey = validatePrivateKey;
228
222
  * @returns Validated public key
229
223
  * @throws {ValidationError} If validation fails
230
224
  */
231
- function validatePublicKey(publicKey) {
232
- return validate(exports.PublicKeySchema, publicKey, 'publicKey');
225
+ export function validatePublicKey(publicKey) {
226
+ return validate(PublicKeySchema, publicKey, 'publicKey');
233
227
  }
234
- exports.validatePublicKey = validatePublicKey;
235
228
  /**
236
229
  * Validate a DAG address
237
230
  *
@@ -239,10 +232,9 @@ exports.validatePublicKey = validatePublicKey;
239
232
  * @returns Validated address
240
233
  * @throws {ValidationError} If validation fails
241
234
  */
242
- function validateAddress(address) {
243
- return validate(exports.DagAddressSchema, address, 'address');
235
+ export function validateAddress(address) {
236
+ return validate(DagAddressSchema, address, 'address');
244
237
  }
245
- exports.validateAddress = validateAddress;
246
238
  /**
247
239
  * Validate a KeyPair
248
240
  *
@@ -250,10 +242,9 @@ exports.validateAddress = validateAddress;
250
242
  * @returns Validated KeyPair
251
243
  * @throws {ValidationError} If validation fails
252
244
  */
253
- function validateKeyPair(keyPair) {
254
- return validate(exports.KeyPairSchema, keyPair, 'keyPair');
245
+ export function validateKeyPair(keyPair) {
246
+ return validate(KeyPairSchema, keyPair, 'keyPair');
255
247
  }
256
- exports.validateKeyPair = validateKeyPair;
257
248
  /**
258
249
  * Safe validation that returns a result object instead of throwing
259
250
  *
@@ -271,7 +262,7 @@ exports.validateKeyPair = validateKeyPair;
271
262
  * }
272
263
  * ```
273
264
  */
274
- function safeParse(schema, data) {
265
+ export function safeParse(schema, data) {
275
266
  const result = schema.safeParse(data);
276
267
  if (result.success) {
277
268
  return { success: true, data: result.data };
@@ -282,7 +273,7 @@ function safeParse(schema, data) {
282
273
  const message = `Validation failed for '${path}': ${firstIssue.message}`;
283
274
  return {
284
275
  success: false,
285
- error: new errors_js_1.ValidationError(message, {
276
+ error: new ValidationError(message, {
286
277
  field: path,
287
278
  value: data,
288
279
  details: {
@@ -295,7 +286,6 @@ function safeParse(schema, data) {
295
286
  }),
296
287
  };
297
288
  }
298
- exports.safeParse = safeParse;
299
289
  /**
300
290
  * Assert that a condition is true, throwing ValidationError if not
301
291
  *
@@ -304,9 +294,8 @@ exports.safeParse = safeParse;
304
294
  * @param field - Optional field name for context
305
295
  * @throws {ValidationError} If condition is false
306
296
  */
307
- function assert(condition, message, field) {
297
+ export function assert(condition, message, field) {
308
298
  if (!condition) {
309
- throw new errors_js_1.ValidationError(message, { field });
299
+ throw new ValidationError(message, { field });
310
300
  }
311
301
  }
312
- exports.assert = assert;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * Backward-compatible verify wrapper.
4
3
  *
@@ -6,12 +5,9 @@
6
5
  * its verify() ignores the `isDataUpdate` parameter when `mode` is present.
7
6
  * This wrapper strips `mode` so callers' explicit `isDataUpdate` always wins.
8
7
  */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.verify = void 0;
11
- const metagraph_sdk_1 = require("@constellation-network/metagraph-sdk");
12
- function verify(signed, isDataUpdate) {
8
+ import { verify as _verify } from '@constellation-network/metagraph-sdk';
9
+ export function verify(signed, isDataUpdate) {
13
10
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
14
11
  const { mode, ...rest } = signed;
15
- return (0, metagraph_sdk_1.verify)(rest, isDataUpdate);
12
+ return _verify(rest, isDataUpdate);
16
13
  }
17
- exports.verify = verify;
@@ -20,13 +20,12 @@
20
20
  /**
21
21
  * Normalize a CreateStateMachine message for wire format
22
22
  *
23
- * Ensures all Option fields are explicit null:
24
- * - definition.metadata
25
- * - definition.states[*].metadata
26
- * - definition.transitions[*].guard
27
- * - definition.transitions[*].actions
28
- * - definition.transitions[*].metadata
29
- * - parentFiberId
23
+ * Ensures all Option/default fields are explicit in wire format:
24
+ * - definition.metadata → null when absent
25
+ * - definition.states[*].metadata → null when absent
26
+ * - definition.transitions[*].dependencies → [] when absent
27
+ * - parentFiberId → null when absent
28
+ * - participants → null when absent (Optional Set[Address] for multi-party signing)
30
29
  *
31
30
  * @example
32
31
  * ```typescript
@@ -35,7 +34,7 @@
35
34
  * definition: { states: { INIT: { id: { value: 'INIT' }, isFinal: false } }, ... },
36
35
  * initialData: {}
37
36
  * });
38
- * // message now has parentFiberId: null, definition.metadata: null, etc.
37
+ * // message now has parentFiberId: null, participants: null, definition.metadata: null, etc.
39
38
  * ```
40
39
  */
41
40
  export declare function normalizeCreateStateMachine(msg: Record<string, unknown>): Record<string, unknown>;
@@ -157,7 +157,9 @@ export interface CreateStateMachine {
157
157
  fiberId: string;
158
158
  definition: StateMachineDefinition;
159
159
  initialData: JsonLogicValue;
160
- parentFiberId?: string;
160
+ parentFiberId?: string | null;
161
+ /** Optional set of DAG addresses authorized to sign transitions (multi-party signing). */
162
+ participants?: string[] | null;
161
163
  }
162
164
  /**
163
165
  * Trigger a state machine transition.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ottochain/sdk",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "TypeScript SDK for ottochain metagraph operations - signing, encoding, and network interactions",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -100,18 +100,18 @@
100
100
  "devDependencies": {
101
101
  "@babel/preset-env": "^7.29.0",
102
102
  "@commitlint/cli": "^20.4.4",
103
- "@commitlint/config-conventional": "^19.0.0",
104
- "@eslint/js": "^9.39.3",
103
+ "@commitlint/config-conventional": "^20.5.0",
104
+ "@eslint/js": "^9.39.4",
105
105
  "@jest/globals": "^30.3.0",
106
106
  "@types/jest": "^30.0.0",
107
- "@types/node": "^25.3.3",
107
+ "@types/node": "^25.5.0",
108
108
  "@typescript-eslint/eslint-plugin": "^8.56.1",
109
- "@typescript-eslint/parser": "^8.56.1",
109
+ "@typescript-eslint/parser": "^8.57.1",
110
110
  "eslint": "^9.39.3",
111
- "jest": "^30.2.0",
111
+ "jest": "^30.3.0",
112
112
  "prettier": "^3.0.0",
113
113
  "ts-jest": "^29.0.0",
114
- "ts-proto": "^2.11.2",
114
+ "ts-proto": "^2.11.5",
115
115
  "typedoc": "^0.28.17",
116
116
  "typescript": "^5.0.0"
117
117
  },