@fairmint/canton-node-sdk
Version:
Canton Node SDK
166 lines • 6.46 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JsCommandsSchema = exports.DeduplicationPeriodSchema = exports.CompositeCommandSchema = exports.UnassignCommandSchema = exports.AssignCommandSchema = exports.ExerciseByKeyCommandSchema = exports.CreateAndExerciseCommandSchema = exports.CommandRequestSchema = exports.DisclosedContractSchema = exports.CommandSchema = exports.ExerciseCommandSchema = exports.CreateCommandSchema = void 0;
const zod_1 = require("zod");
const base_1 = require("../base");
const common_1 = require("../common");
exports.CreateCommandSchema = zod_1.z
.object({
/** Command to create a new contract instance. */
CreateCommand: zod_1.z
.object({
/** Template ID of the contract to create. */
templateId: zod_1.z.string(),
/** Arguments for the contract creation. */
createArguments: base_1.RecordSchema,
})
.strict(),
})
.strict();
exports.ExerciseCommandSchema = zod_1.z
.object({
/** Command to exercise a choice on an existing contract. */
ExerciseCommand: zod_1.z
.object({
/** Template ID of the contract. */
templateId: zod_1.z.string(),
/** Contract ID to exercise the choice on. */
contractId: zod_1.z.string(),
/** Name of the choice to exercise. */
choice: zod_1.z.string(),
/** Arguments for the choice. */
choiceArgument: base_1.RecordSchema,
})
.strict(),
})
.strict();
exports.CommandSchema = zod_1.z.union([exports.CreateCommandSchema, exports.ExerciseCommandSchema]);
exports.DisclosedContractSchema = zod_1.z
.object({
/** Template ID of the disclosed contract. */
templateId: zod_1.z.string(),
/** Contract ID of the disclosed contract. */
contractId: zod_1.z.string(),
/** Serialized event blob for the disclosed contract. */
createdEventBlob: zod_1.z.string(),
/** Synchronizer ID for the disclosed contract. */
synchronizerId: zod_1.z.string(),
})
.strict();
exports.CommandRequestSchema = zod_1.z
.object({
/** List of commands to submit. */
commands: zod_1.z.array(exports.CommandSchema),
/** Unique identifier for the command request. */
commandId: zod_1.z.string(),
/** Parties submitting the command. */
actAs: zod_1.z.array(zod_1.z.string()),
/** Parties to read as (optional). */
readAs: zod_1.z.array(zod_1.z.string()).optional(),
/** Disclosed contracts referenced by the command (optional). */
disclosedContracts: zod_1.z.array(exports.DisclosedContractSchema).optional(),
})
.strict();
/** Command to create a contract and immediately exercise a choice on it. */
exports.CreateAndExerciseCommandSchema = zod_1.z
.object({
CreateAndExerciseCommand: zod_1.z
.object({
/** Template ID of the contract to create. */
templateId: zod_1.z.string(),
/** Arguments for the contract creation. */
createArguments: base_1.RecordSchema,
/** Name of the choice to exercise. */
choice: zod_1.z.string(),
/** Arguments for the choice. */
choiceArgument: base_1.RecordSchema,
})
.strict(),
})
.strict();
/** Command to exercise a choice on a contract by key. */
exports.ExerciseByKeyCommandSchema = zod_1.z
.object({
ExerciseByKeyCommand: zod_1.z
.object({
/** Template ID of the contract. */
templateId: zod_1.z.string(),
/** Contract key to exercise the choice on. */
contractKey: base_1.RecordSchema,
/** Name of the choice to exercise. */
choice: zod_1.z.string(),
/** Arguments for the choice. */
choiceArgument: base_1.RecordSchema,
})
.strict(),
})
.strict();
/** Command to assign a contract (reassignment). */
exports.AssignCommandSchema = zod_1.z
.object({
AssignCommand: zod_1.z
.object({
/** Reassignment ID from the unassigned event. */
reassignmentId: zod_1.z.string(),
/** Source synchronizer ID. */
source: zod_1.z.string(),
/** Target synchronizer ID. */
target: zod_1.z.string(),
})
.strict(),
})
.strict();
/** Command to unassign a contract (reassignment). */
exports.UnassignCommandSchema = zod_1.z
.object({
UnassignCommand: zod_1.z
.object({
/** Contract ID to unassign. */
contractId: zod_1.z.string(),
/** Source synchronizer ID. */
source: zod_1.z.string(),
/** Target synchronizer ID. */
target: zod_1.z.string(),
})
.strict(),
})
.strict();
/** Composite command type (oneOf all supported commands). */
exports.CompositeCommandSchema = zod_1.z.union([
exports.CreateAndExerciseCommandSchema,
exports.CreateCommandSchema,
exports.ExerciseByKeyCommandSchema,
exports.ExerciseCommandSchema,
exports.AssignCommandSchema,
exports.UnassignCommandSchema,
]);
/** Deduplication period (oneOf duration, offset, or empty). */
exports.DeduplicationPeriodSchema = zod_1.z.union([
zod_1.z.object({ DeduplicationDuration: common_1.DeduplicationDurationSchema }),
zod_1.z.object({ DeduplicationOffset: common_1.DeduplicationOffsetSchema }),
zod_1.z.object({ Empty: common_1.EmptyDeduplicationSchema }),
]);
/** Commands container with all command types. */
exports.JsCommandsSchema = zod_1.z.object({
/** Workflow ID (optional). */
workflowId: zod_1.z.string().optional(),
/** User ID submitting the command. */
userId: zod_1.z.string(),
/** Unique identifier for the command. */
commandId: zod_1.z.string(),
/** Party submitting the command. */
submitter: zod_1.z.string(),
/** Submission ID (optional). */
submissionId: zod_1.z.string().optional(),
/** List of commands to execute. */
commands: zod_1.z.array(exports.CommandSchema),
/** Deduplication period (optional). */
deduplicationPeriod: exports.DeduplicationPeriodSchema.optional(),
/** Minimum ledger time relative to submission (optional). */
minLedgerTimeRel: common_1.MinLedgerTimeRelSchema.optional(),
/** Disclosed contracts (optional). */
disclosedContracts: zod_1.z.array(exports.DisclosedContractSchema).optional(),
/** Prefetch contract keys (optional). */
prefetchContractKeys: zod_1.z.array(common_1.PrefetchContractKeySchema).optional(),
});
//# sourceMappingURL=commands.js.map