UNPKG

@digitalasset/daml-ledger

Version:
42 lines 1.85 kB
"use strict"; // Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. // SPDX-License-Identifier: Apache-2.0 Object.defineProperty(exports, "__esModule", { value: true }); exports.TransactionCodec = void 0; const TimestampCodec_1 = require("./TimestampCodec"); const EventCodec_1 = require("./EventCodec"); const transaction_pb_1 = require("../generated/com/daml/ledger/api/v1/transaction_pb"); exports.TransactionCodec = { deserialize(message) { const transaction = { effectiveAt: TimestampCodec_1.TimestampCodec.deserialize(message.getEffectiveAt()), events: message.getEventsList().map((event) => EventCodec_1.EventCodec.deserialize(event)), offset: message.getOffset(), transactionId: message.getTransactionId(), }; const commandId = message.getCommandId(); if (commandId !== undefined && commandId !== '') { transaction.commandId = commandId; } const workflowId = message.getWorkflowId(); if (workflowId !== undefined && workflowId !== '') { transaction.workflowId = workflowId; } return transaction; }, serialize(object) { const message = new transaction_pb_1.Transaction(); message.setEffectiveAt(TimestampCodec_1.TimestampCodec.serialize(object.effectiveAt)); message.setEventsList(object.events.map((event) => EventCodec_1.EventCodec.serialize(event))); message.setOffset(object.offset); message.setTransactionId(object.transactionId); if (object.commandId) { message.setCommandId(object.commandId); } if (object.workflowId) { message.setWorkflowId(object.workflowId); } return message; } }; //# sourceMappingURL=TransactionCodec.js.map