@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
59 lines • 1.99 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.toSignOperationEventRaw = exports.fromSignOperationEventRaw = exports.toSignedOperationRaw = exports.fromSignedOperationRaw = void 0;
const account_1 = require("../account");
const fromSignedOperationRaw = (signedOp, accountId) => {
const { operation, signature, expirationDate, rawData } = signedOp;
const out = {
operation: (0, account_1.fromOperationRaw)(operation, accountId),
signature,
};
if (rawData) {
out.rawData = rawData;
}
if (expirationDate) {
out.expirationDate = new Date(expirationDate);
}
return out;
};
exports.fromSignedOperationRaw = fromSignedOperationRaw;
const toSignedOperationRaw = (signedOp, preserveSubOperation) => {
const { operation, signature, expirationDate, rawData } = signedOp;
const out = {
operation: (0, account_1.toOperationRaw)(operation, preserveSubOperation),
signature,
};
if (rawData) {
out.rawData = rawData;
}
if (expirationDate) {
out.expirationDate = expirationDate.toISOString();
}
return out;
};
exports.toSignedOperationRaw = toSignedOperationRaw;
const fromSignOperationEventRaw = (e, accountId) => {
switch (e.type) {
case "signed":
return {
type: "signed",
signedOperation: (0, exports.fromSignedOperationRaw)(e.signedOperation, accountId),
};
default:
return e;
}
};
exports.fromSignOperationEventRaw = fromSignOperationEventRaw;
const toSignOperationEventRaw = (e) => {
switch (e.type) {
case "signed":
return {
type: "signed",
signedOperation: (0, exports.toSignedOperationRaw)(e.signedOperation, true),
};
default:
return e;
}
};
exports.toSignOperationEventRaw = toSignOperationEventRaw;
//# sourceMappingURL=signOperation.js.map