Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 1x 2x 2x 2x 2x | import { autoInjectable } from "tsyringe";
import { Metadata } from "../../tr8-script/domain/ast.js";
import { Amount } from "../../tr8-script/domain/value.js";
import { AmountValueMapper } from "../../approval-engine/mappers/value.mapper.js";
import { AmountDto } from "../../commons/dtos/values.dto.js";
@autoInjectable()
class MetadataMapper {
static metadataFromMessage(rawMetadata: string): Metadata {
return JSON.parse(rawMetadata);
}
static variableFromMessage(
vars: Record<string, AmountDto>,
): Record<string, Amount> {
return Object.keys(vars).reduce(
(acc, k) => {
acc[k] = AmountValueMapper.fromMessage(vars[k]!);
return acc;
},
{} as Record<string, Amount>,
);
}
}
export { MetadataMapper };
|