@fintekkers/ledger-models 0.4.38 → 0.4.39

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 (61) hide show
  1. package/node/fintekkers/models/util/decimal_value_pb.d.ts +2 -0
  2. package/node/wrappers/models/position/position.d.ts +1 -1
  3. package/node/wrappers/models/position/position.js.map +1 -1
  4. package/node/wrappers/models/position/position.test.js +2 -2
  5. package/node/wrappers/models/position/position.test.js.map +1 -1
  6. package/node/wrappers/models/position/position.test.ts +2 -2
  7. package/node/wrappers/models/position/position.ts +2 -2
  8. package/node/wrappers/models/price/Price.js +16 -8
  9. package/node/wrappers/models/price/Price.js.map +1 -1
  10. package/node/wrappers/models/price/Price.ts +15 -6
  11. package/node/wrappers/models/price/price_rules.d.ts +2 -2
  12. package/node/wrappers/models/price/price_rules.js +6 -4
  13. package/node/wrappers/models/price/price_rules.js.map +1 -1
  14. package/node/wrappers/models/price/price_rules.ts +5 -3
  15. package/node/wrappers/models/security/BondSecurity.d.ts +1 -1
  16. package/node/wrappers/models/security/BondSecurity.js +5 -5
  17. package/node/wrappers/models/security/BondSecurity.js.map +1 -1
  18. package/node/wrappers/models/security/BondSecurity.ts +5 -4
  19. package/node/wrappers/models/security/FloatingRateNote.js +2 -2
  20. package/node/wrappers/models/security/FloatingRateNote.js.map +1 -1
  21. package/node/wrappers/models/security/FloatingRateNote.ts +2 -1
  22. package/node/wrappers/models/security/Issuance.js +3 -6
  23. package/node/wrappers/models/security/Issuance.js.map +1 -1
  24. package/node/wrappers/models/security/Issuance.ts +3 -2
  25. package/node/wrappers/models/security/MortgageBackedSecurity.js +7 -7
  26. package/node/wrappers/models/security/MortgageBackedSecurity.js.map +1 -1
  27. package/node/wrappers/models/security/MortgageBackedSecurity.ts +7 -6
  28. package/node/wrappers/models/security/TIPSBond.js +2 -2
  29. package/node/wrappers/models/security/TIPSBond.js.map +1 -1
  30. package/node/wrappers/models/security/TIPSBond.ts +2 -1
  31. package/node/wrappers/models/security/security_rules.js +10 -12
  32. package/node/wrappers/models/security/security_rules.js.map +1 -1
  33. package/node/wrappers/models/security/security_rules.ts +9 -9
  34. package/node/wrappers/models/transaction/transaction.js +16 -10
  35. package/node/wrappers/models/transaction/transaction.js.map +1 -1
  36. package/node/wrappers/models/transaction/transaction.ts +16 -7
  37. package/node/wrappers/models/utils/decimal.d.ts +96 -0
  38. package/node/wrappers/models/utils/decimal.js +328 -0
  39. package/node/wrappers/models/utils/decimal.js.map +1 -0
  40. package/node/wrappers/models/utils/decimal.legacy.test.d.ts +1 -0
  41. package/node/wrappers/models/utils/decimal.legacy.test.js +174 -0
  42. package/node/wrappers/models/utils/decimal.legacy.test.js.map +1 -0
  43. package/node/wrappers/models/utils/decimal.legacy.test.ts +158 -0
  44. package/node/wrappers/models/utils/decimal.test.d.ts +1 -0
  45. package/node/wrappers/models/utils/decimal.test.js +258 -0
  46. package/node/wrappers/models/utils/decimal.test.js.map +1 -0
  47. package/node/wrappers/models/utils/decimal.test.ts +272 -0
  48. package/node/wrappers/models/utils/decimal.ts +335 -0
  49. package/node/wrappers/models/utils/decimal.typings.test.d.ts +1 -0
  50. package/node/wrappers/models/utils/decimal.typings.test.js +39 -0
  51. package/node/wrappers/models/utils/decimal.typings.test.js.map +1 -0
  52. package/node/wrappers/models/utils/decimal.typings.test.ts +16 -0
  53. package/node/wrappers/models/utils/serialization.d.ts +2 -1
  54. package/node/wrappers/models/utils/serialization.js +12 -2
  55. package/node/wrappers/models/utils/serialization.js.map +1 -1
  56. package/node/wrappers/models/utils/serialization.ts +14 -3
  57. package/node/wrappers/services/security-service/security.maturityLadder.test.js +1 -1
  58. package/node/wrappers/services/security-service/security.maturityLadder.test.js.map +1 -1
  59. package/node/wrappers/services/security-service/security.maturityLadder.test.ts +3 -2
  60. package/package.json +1 -1
  61. package/tsconfig.json +1 -0
@@ -0,0 +1,96 @@
1
+ import { Decimal } from 'decimal.js';
2
+ import { DecimalValueProto } from '../../../fintekkers/models/util/decimal_value_pb';
3
+ /**
4
+ * Codec for `DecimalValueProto` (LM-306, the JS side of LM-294; see
5
+ * docs/adr/compact_decimal.md and the Rust reference in
6
+ * ledger-models-rust/fintekkers/wrappers/models/utils/decimal.rs).
7
+ *
8
+ * value = unscaled x 10^-scale, where `unscaled_value` (field 11) is a minimal
9
+ * two's-complement big-endian integer of any size and `scale` is field 12. A
10
+ * non-empty `unscaled_value` means the compact form is set and it wins.
11
+ * Otherwise the deprecated `arbitrary_precision_value` string (field 10) is
12
+ * read, with a warning logged once per process (LM-307).
13
+ *
14
+ * Lossless: no binary floating point on any path (no JS `number` value, no
15
+ * `parseFloat`). A value that cannot be represented exactly is a
16
+ * `ModelValidationError`, never rounded. The codec does not know which field
17
+ * it is decoding: a caller that wants the field named wraps the call in
18
+ * `withField`.
19
+ *
20
+ * Stage 1 (until LM-295): writers set both forms, so readers on older
21
+ * ledger-models keep working. This module is the only code allowed to touch
22
+ * the deprecated string field.
23
+ */
24
+ /**
25
+ * Most decimal digits allowed in the unscaled value, and the largest scale.
26
+ * The same in every language (see the ADR).
27
+ */
28
+ export declare const MAX_DIGITS = 4096;
29
+ export declare const MAX_SCALE = 4096;
30
+ /**
31
+ * A minimal unscaled_value longer than this always has more than
32
+ * `MAX_DIGITS` digits, so it is rejected before it is parsed.
33
+ */
34
+ export declare const MAX_UNSCALED_BYTES = 1702;
35
+ /** An exact decimal: `unscaled x 10^-scale`. `scale` is a count, never a value. */
36
+ export interface CompactDecimal {
37
+ unscaled: bigint;
38
+ scale: number;
39
+ }
40
+ /** Where the once-per-process deprecation warning goes. Defaults to `console`. */
41
+ export interface DecimalLogger {
42
+ warn(message: string): void;
43
+ }
44
+ /** Sends the deprecation warning to `l` from now on. Tests use it to spy. */
45
+ export declare function setDecimalLogger(l: DecimalLogger): void;
46
+ /**
47
+ * Runs `fn`, labelling any ModelValidationError it throws with `field` (for
48
+ * example `price`). Violations that already name a field get it as a prefix.
49
+ */
50
+ export declare function withField<T>(field: string, fn: () => T): T;
51
+ /**
52
+ * Parses a decimal string, as written to `arbitrary_precision_value`.
53
+ *
54
+ * Grammar: `[+-]? (digits [. digits?] | . digits) ([eE] [+-]? digits)?`. No
55
+ * whitespace, no `NaN` or `Infinity`. The exponent is folded into the scale;
56
+ * a negative scale becomes scale 0 (`1E+3` is unscaled 1000, scale 0).
57
+ * Trailing zeros are kept: `1.50` is unscaled 150, scale 2. Anything else, or
58
+ * a result over `MAX_DIGITS` / `MAX_SCALE`, is a ModelValidationError.
59
+ */
60
+ export declare function parseDecimalString(s: string): CompactDecimal;
61
+ /** Plain notation, never an exponent, keeping trailing zeros: unscaled 150 scale 2 is `1.50`. */
62
+ export declare function toCanonicalString(v: CompactDecimal): string;
63
+ /** True when neither form is set: `unscaled_value` and `arbitrary_precision_value` are both empty. */
64
+ export declare function isUnsetDecimal(p: DecimalValueProto): boolean;
65
+ /**
66
+ * Decodes a `DecimalValueProto`. The compact form wins when set. Otherwise
67
+ * falls back to the deprecated string and logs a deprecation warning, once
68
+ * per process. Both forms empty is a ModelValidationError; so is a malformed
69
+ * or over-cap value. Takes the proto only (owner ruling, 12 Oct): label
70
+ * errors with `withField`.
71
+ */
72
+ export declare function decodeDecimal(p: DecimalValueProto): CompactDecimal;
73
+ /**
74
+ * Encodes both forms (stage 1): fields 11 and 12, plus the canonical string
75
+ * in field 10 for readers on ledger-models older than v0.4.34.
76
+ */
77
+ export declare function encodeDecimal(v: CompactDecimal): DecimalValueProto;
78
+ /**
79
+ * `p` rewritten in both forms (stage 1), keeping its value and scale. Used
80
+ * when re-saving a message loaded from older bytes.
81
+ */
82
+ export declare function reencodeDecimal(p: DecimalValueProto): DecimalValueProto;
83
+ /**
84
+ * The value as a decimal.js `Decimal`, built from the canonical string. The
85
+ * `Decimal` constructor is exact and ignores the global `precision`. A
86
+ * `Decimal` does not keep trailing zeros, so `1.50` reads back as `1.5`.
87
+ */
88
+ export declare function toDecimalJs(v: CompactDecimal): Decimal;
89
+ /**
90
+ * The exact value of a decimal.js `Decimal`, from `toFixed()`, which never
91
+ * rounds when given no argument. A `Decimal` does not keep trailing zeros, so
92
+ * `new Decimal('1.50')` becomes scale 1: callers that need scale 2 use
93
+ * `parseDecimalString('1.50')`. Negative zero becomes 0. NaN, Infinity and
94
+ * values over the limits are a ModelValidationError.
95
+ */
96
+ export declare function fromDecimalJs(d: Decimal): CompactDecimal;
@@ -0,0 +1,328 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromDecimalJs = exports.toDecimalJs = exports.reencodeDecimal = exports.encodeDecimal = exports.decodeDecimal = exports.isUnsetDecimal = exports.toCanonicalString = exports.parseDecimalString = exports.withField = exports.setDecimalLogger = exports.MAX_UNSCALED_BYTES = exports.MAX_SCALE = exports.MAX_DIGITS = void 0;
4
+ const decimal_js_1 = require("decimal.js");
5
+ const decimal_value_pb_1 = require("../../../fintekkers/models/util/decimal_value_pb");
6
+ const errors_1 = require("../errors");
7
+ /**
8
+ * Codec for `DecimalValueProto` (LM-306, the JS side of LM-294; see
9
+ * docs/adr/compact_decimal.md and the Rust reference in
10
+ * ledger-models-rust/fintekkers/wrappers/models/utils/decimal.rs).
11
+ *
12
+ * value = unscaled x 10^-scale, where `unscaled_value` (field 11) is a minimal
13
+ * two's-complement big-endian integer of any size and `scale` is field 12. A
14
+ * non-empty `unscaled_value` means the compact form is set and it wins.
15
+ * Otherwise the deprecated `arbitrary_precision_value` string (field 10) is
16
+ * read, with a warning logged once per process (LM-307).
17
+ *
18
+ * Lossless: no binary floating point on any path (no JS `number` value, no
19
+ * `parseFloat`). A value that cannot be represented exactly is a
20
+ * `ModelValidationError`, never rounded. The codec does not know which field
21
+ * it is decoding: a caller that wants the field named wraps the call in
22
+ * `withField`.
23
+ *
24
+ * Stage 1 (until LM-295): writers set both forms, so readers on older
25
+ * ledger-models keep working. This module is the only code allowed to touch
26
+ * the deprecated string field.
27
+ */
28
+ /**
29
+ * Most decimal digits allowed in the unscaled value, and the largest scale.
30
+ * The same in every language (see the ADR).
31
+ */
32
+ exports.MAX_DIGITS = 4096;
33
+ exports.MAX_SCALE = 4096;
34
+ /**
35
+ * A minimal unscaled_value longer than this always has more than
36
+ * `MAX_DIGITS` digits, so it is rejected before it is parsed.
37
+ */
38
+ exports.MAX_UNSCALED_BYTES = 1702;
39
+ /** The library release that first writes the compact form. */
40
+ const FIRST_COMPACT_RELEASE = 'v0.4.34';
41
+ // No bigint literals: tsconfig targets es2016.
42
+ const ZERO = BigInt(0);
43
+ const ONE = BigInt(1);
44
+ const EIGHT = BigInt(8);
45
+ let logger = console;
46
+ let warned = false;
47
+ /** Sends the deprecation warning to `l` from now on. Tests use it to spy. */
48
+ function setDecimalLogger(l) {
49
+ logger = l;
50
+ }
51
+ exports.setDecimalLogger = setDecimalLogger;
52
+ /** An unlabelled ModelValidationError: the field is empty until `withField` adds it. */
53
+ function invalid(message) {
54
+ return new errors_1.ModelValidationError([(0, errors_1.violation)('', undefined, message)]);
55
+ }
56
+ /**
57
+ * Runs `fn`, labelling any ModelValidationError it throws with `field` (for
58
+ * example `price`). Violations that already name a field get it as a prefix.
59
+ */
60
+ function withField(field, fn) {
61
+ try {
62
+ return fn();
63
+ }
64
+ catch (e) {
65
+ if (!(e instanceof errors_1.ModelValidationError))
66
+ throw e;
67
+ throw new errors_1.ModelValidationError(e.violations.map(v => {
68
+ const labelled = v.clone();
69
+ labelled.setField(v.getField() ? `${field}.${v.getField()}` : field);
70
+ return labelled;
71
+ }));
72
+ }
73
+ }
74
+ exports.withField = withField;
75
+ /** At most the first 64 characters of `s`, for error messages. */
76
+ function preview(s) {
77
+ return JSON.stringify(s.slice(0, 64));
78
+ }
79
+ function overCap(s) {
80
+ return invalid(`decimal is over the limit of ${exports.MAX_DIGITS} digits or scale ${exports.MAX_SCALE}: ${preview(s)}`);
81
+ }
82
+ /**
83
+ * The only conversion from bigint to a JS number: `b` must already be
84
+ * range-checked against MAX_DIGITS / MAX_SCALE, so it is a small integer and
85
+ * the conversion is exact.
86
+ */
87
+ function smallInt(b) {
88
+ const limit = BigInt(Math.max(exports.MAX_DIGITS, exports.MAX_SCALE));
89
+ if (b < -limit || b > limit) {
90
+ throw invalid(`decimal count ${b} is outside the limits`);
91
+ }
92
+ return Number(b); // lossless-allow: range-checked above, |b| <= 4096
93
+ }
94
+ function isDigit(c) {
95
+ return c !== undefined && c >= '0' && c <= '9';
96
+ }
97
+ /**
98
+ * Parses a decimal string, as written to `arbitrary_precision_value`.
99
+ *
100
+ * Grammar: `[+-]? (digits [. digits?] | . digits) ([eE] [+-]? digits)?`. No
101
+ * whitespace, no `NaN` or `Infinity`. The exponent is folded into the scale;
102
+ * a negative scale becomes scale 0 (`1E+3` is unscaled 1000, scale 0).
103
+ * Trailing zeros are kept: `1.50` is unscaled 150, scale 2. Anything else, or
104
+ * a result over `MAX_DIGITS` / `MAX_SCALE`, is a ModelValidationError.
105
+ */
106
+ function parseDecimalString(s) {
107
+ const notADecimal = () => invalid(`decimal is not a finite decimal: ${preview(s)}`);
108
+ let i = 0;
109
+ let negative = false;
110
+ if (s[0] === '-' || s[0] === '+') {
111
+ negative = s[0] === '-';
112
+ i = 1;
113
+ }
114
+ const intStart = i;
115
+ while (isDigit(s[i]))
116
+ i++;
117
+ const intDigits = s.slice(intStart, i);
118
+ let fracDigits = '';
119
+ if (s[i] === '.') {
120
+ i++;
121
+ const fracStart = i;
122
+ while (isDigit(s[i]))
123
+ i++;
124
+ fracDigits = s.slice(fracStart, i);
125
+ }
126
+ if (intDigits === '' && fracDigits === '')
127
+ throw notADecimal();
128
+ let exponent = ZERO;
129
+ if (s[i] === 'e' || s[i] === 'E') {
130
+ i++;
131
+ let expNegative = false;
132
+ if (s[i] === '-' || s[i] === '+') {
133
+ expNegative = s[i] === '-';
134
+ i++;
135
+ }
136
+ const expStart = i;
137
+ while (isDigit(s[i]))
138
+ i++;
139
+ if (i === expStart)
140
+ throw notADecimal();
141
+ const expDigits = s.slice(expStart, i).replace(/^0+/, '');
142
+ // Any exponent this long is far past the caps below.
143
+ if (expDigits.length > 12)
144
+ throw overCap(s);
145
+ const magnitude = expDigits === '' ? ZERO : BigInt(expDigits);
146
+ exponent = expNegative ? -magnitude : magnitude;
147
+ }
148
+ if (i !== s.length)
149
+ throw notADecimal();
150
+ const significant = (intDigits + fracDigits).replace(/^0+/, '');
151
+ const scale = BigInt(fracDigits.length) - exponent;
152
+ if (significant === '') {
153
+ // Zero has no sign and keeps its scale (`0.00` is scale 2); `0E+3` is scale 0.
154
+ const zeroScale = scale < ZERO ? ZERO : scale;
155
+ if (zeroScale > BigInt(exports.MAX_SCALE))
156
+ throw overCap(s);
157
+ return { unscaled: ZERO, scale: smallInt(zeroScale) };
158
+ }
159
+ const zerosToAppend = scale < ZERO ? -scale : ZERO;
160
+ if (scale > BigInt(exports.MAX_SCALE) || BigInt(significant.length) + zerosToAppend > BigInt(exports.MAX_DIGITS)) {
161
+ throw overCap(s);
162
+ }
163
+ const magnitude = BigInt(significant + '0'.repeat(smallInt(zerosToAppend)));
164
+ return {
165
+ unscaled: negative ? -magnitude : magnitude,
166
+ scale: smallInt(scale < ZERO ? ZERO : scale),
167
+ };
168
+ }
169
+ exports.parseDecimalString = parseDecimalString;
170
+ /** Plain notation, never an exponent, keeping trailing zeros: unscaled 150 scale 2 is `1.50`. */
171
+ function toCanonicalString(v) {
172
+ const negative = v.unscaled < ZERO;
173
+ const digits = (negative ? -v.unscaled : v.unscaled).toString();
174
+ const sign = negative ? '-' : '';
175
+ if (v.scale === 0)
176
+ return sign + digits;
177
+ if (digits.length > v.scale) {
178
+ return `${sign}${digits.slice(0, digits.length - v.scale)}.${digits.slice(digits.length - v.scale)}`;
179
+ }
180
+ return `${sign}0.${'0'.repeat(v.scale - digits.length)}${digits}`;
181
+ }
182
+ exports.toCanonicalString = toCanonicalString;
183
+ /** Minimal two's-complement big-endian bytes. Zero is the single byte 0x00. */
184
+ function bigIntToBytes(n) {
185
+ let hex;
186
+ if (n >= ZERO) {
187
+ hex = n.toString(16);
188
+ if (hex.length % 2 === 1)
189
+ hex = '0' + hex;
190
+ // A leading byte >= 0x80 would read back as negative.
191
+ if (/^[89a-f]/.test(hex))
192
+ hex = '00' + hex;
193
+ }
194
+ else {
195
+ const magnitude = -n;
196
+ let length = (magnitude.toString(16).length + 1) >> 1;
197
+ // The most negative value in `length` bytes is -(2^(8*length - 1)).
198
+ if (magnitude > ONE << (BigInt(length) * EIGHT - ONE))
199
+ length++;
200
+ hex = ((ONE << (BigInt(length) * EIGHT)) + n).toString(16);
201
+ hex = '0'.repeat(length * 2 - hex.length) + hex;
202
+ }
203
+ const out = new Uint8Array(hex.length / 2);
204
+ for (let i = 0; i < out.length; i++) {
205
+ out[i] = (hexValue(hex[2 * i]) << 4) | hexValue(hex[2 * i + 1]);
206
+ }
207
+ return out;
208
+ }
209
+ function hexValue(c) {
210
+ return '0123456789abcdef'.indexOf(c);
211
+ }
212
+ /** Reads two's-complement big-endian bytes of any length; non-minimal input is fine. */
213
+ function bytesToBigInt(bytes) {
214
+ if (bytes.length === 0)
215
+ return ZERO;
216
+ let hex = '';
217
+ for (const b of bytes)
218
+ hex += (b < 16 ? '0' : '') + b.toString(16);
219
+ const unsigned = BigInt('0x' + hex);
220
+ return bytes[0] & 0x80 ? unsigned - (ONE << (BigInt(bytes.length) * EIGHT)) : unsigned;
221
+ }
222
+ /**
223
+ * Decodes the compact form (fields 11 and 12). Rejects a scale over
224
+ * `MAX_SCALE`, then bytes over `MAX_UNSCALED_BYTES`, then more than
225
+ * `MAX_DIGITS` digits, before any large allocation (the same order as Rust).
226
+ */
227
+ function decodeCompact(unscaledValue, scale) {
228
+ if (scale > exports.MAX_SCALE) {
229
+ throw invalid(`decimal has scale ${scale}, over the limit of ${exports.MAX_SCALE}`);
230
+ }
231
+ if (unscaledValue.length > exports.MAX_UNSCALED_BYTES) {
232
+ throw invalid(`decimal has a ${unscaledValue.length}-byte unscaled_value, over the limit of ${exports.MAX_UNSCALED_BYTES} bytes`);
233
+ }
234
+ const unscaled = bytesToBigInt(unscaledValue);
235
+ if ((unscaled < ZERO ? -unscaled : unscaled).toString().length > exports.MAX_DIGITS) {
236
+ throw invalid(`decimal has more than ${exports.MAX_DIGITS} digits`);
237
+ }
238
+ return { unscaled, scale };
239
+ }
240
+ /** True when neither form is set: `unscaled_value` and `arbitrary_precision_value` are both empty. */
241
+ function isUnsetDecimal(p) {
242
+ return p.getUnscaledValue_asU8().length === 0 && p.getArbitraryPrecisionValue() === '';
243
+ }
244
+ exports.isUnsetDecimal = isUnsetDecimal;
245
+ /**
246
+ * Decodes a `DecimalValueProto`. The compact form wins when set. Otherwise
247
+ * falls back to the deprecated string and logs a deprecation warning, once
248
+ * per process. Both forms empty is a ModelValidationError; so is a malformed
249
+ * or over-cap value. Takes the proto only (owner ruling, 12 Oct): label
250
+ * errors with `withField`.
251
+ */
252
+ function decodeDecimal(p) {
253
+ const unscaledValue = p.getUnscaledValue_asU8();
254
+ if (unscaledValue.length > 0) {
255
+ return decodeCompact(unscaledValue, p.getScale());
256
+ }
257
+ const legacy = p.getArbitraryPrecisionValue();
258
+ if (legacy === '') {
259
+ throw invalid('decimal is required but unset');
260
+ }
261
+ emitDeprecation();
262
+ return parseDecimalString(legacy);
263
+ }
264
+ exports.decodeDecimal = decodeDecimal;
265
+ /**
266
+ * Encodes both forms (stage 1): fields 11 and 12, plus the canonical string
267
+ * in field 10 for readers on ledger-models older than v0.4.34.
268
+ */
269
+ function encodeDecimal(v) {
270
+ if (typeof v.unscaled !== 'bigint') {
271
+ throw invalid('decimal unscaled value must be a bigint');
272
+ }
273
+ if (!Number.isInteger(v.scale) || v.scale < 0 || v.scale > exports.MAX_SCALE) {
274
+ throw invalid(`decimal scale must be an integer from 0 to ${exports.MAX_SCALE}: ${v.scale}`);
275
+ }
276
+ return new decimal_value_pb_1.DecimalValueProto()
277
+ .setArbitraryPrecisionValue(toCanonicalString(v))
278
+ .setUnscaledValue(bigIntToBytes(v.unscaled))
279
+ .setScale(v.scale);
280
+ }
281
+ exports.encodeDecimal = encodeDecimal;
282
+ /**
283
+ * `p` rewritten in both forms (stage 1), keeping its value and scale. Used
284
+ * when re-saving a message loaded from older bytes.
285
+ */
286
+ function reencodeDecimal(p) {
287
+ return encodeDecimal(decodeDecimal(p));
288
+ }
289
+ exports.reencodeDecimal = reencodeDecimal;
290
+ /**
291
+ * The value as a decimal.js `Decimal`, built from the canonical string. The
292
+ * `Decimal` constructor is exact and ignores the global `precision`. A
293
+ * `Decimal` does not keep trailing zeros, so `1.50` reads back as `1.5`.
294
+ */
295
+ function toDecimalJs(v) {
296
+ return new decimal_js_1.Decimal(toCanonicalString(v));
297
+ }
298
+ exports.toDecimalJs = toDecimalJs;
299
+ /**
300
+ * The exact value of a decimal.js `Decimal`, from `toFixed()`, which never
301
+ * rounds when given no argument. A `Decimal` does not keep trailing zeros, so
302
+ * `new Decimal('1.50')` becomes scale 1: callers that need scale 2 use
303
+ * `parseDecimalString('1.50')`. Negative zero becomes 0. NaN, Infinity and
304
+ * values over the limits are a ModelValidationError.
305
+ */
306
+ function fromDecimalJs(d) {
307
+ if (!d.isFinite()) {
308
+ throw invalid(`decimal is not a finite decimal: ${d.toString()}`);
309
+ }
310
+ // Checked before toFixed(), which would write every digit out.
311
+ if (d.e >= exports.MAX_DIGITS || d.decimalPlaces() > exports.MAX_SCALE) {
312
+ throw overCap(d.toString());
313
+ }
314
+ return parseDecimalString(d.toFixed());
315
+ }
316
+ exports.fromDecimalJs = fromDecimalJs;
317
+ /**
318
+ * Logs that a decimal was read from the deprecated string, the first time
319
+ * only in this process.
320
+ */
321
+ function emitDeprecation() {
322
+ if (warned)
323
+ return;
324
+ warned = true;
325
+ logger.warn('DecimalValueProto read from deprecated arbitrary_precision_value; '
326
+ + `writer predates ledger-models ${FIRST_COMPACT_RELEASE}`);
327
+ }
328
+ //# sourceMappingURL=decimal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decimal.js","sourceRoot":"","sources":["decimal.ts"],"names":[],"mappings":";;;AAA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AAC"}
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const fs = __importStar(require("fs"));
30
+ const path = __importStar(require("path"));
31
+ const decimal_js_1 = require("decimal.js");
32
+ const price_pb_1 = require("../../../fintekkers/models/price/price_pb");
33
+ const security_pb_1 = require("../../../fintekkers/models/security/security_pb");
34
+ const transaction_pb_1 = require("../../../fintekkers/models/transaction/transaction_pb");
35
+ const decimal_value_pb_1 = require("../../../fintekkers/models/util/decimal_value_pb");
36
+ const Price_1 = __importDefault(require("../price/Price"));
37
+ const security_1 = __importDefault(require("../security/security"));
38
+ const MortgageBackedSecurity_1 = __importDefault(require("../security/MortgageBackedSecurity"));
39
+ const transaction_1 = __importDefault(require("../transaction/transaction"));
40
+ const serialization_1 = require("./serialization");
41
+ const uuid_1 = require("./uuid");
42
+ const portfolio_1 = __importDefault(require("../portfolio/portfolio"));
43
+ const portfolio_pb_1 = require("../../../fintekkers/models/portfolio/portfolio_pb");
44
+ const decimal_1 = require("./decimal");
45
+ /**
46
+ * Metric 2 (LM-306): bytes written by ledger-models v0.4.33 carry only the
47
+ * string form. They load through the wrappers to the same value and scale,
48
+ * and re-saving them writes both forms.
49
+ */
50
+ const LEGACY = path.join(__dirname, '../../../../../ledger-models-protos/fixtures/legacy_v0433');
51
+ const DESERIALIZERS = {
52
+ PriceProto: b => price_pb_1.PriceProto.deserializeBinary(b),
53
+ SecurityProto: b => security_pb_1.SecurityProto.deserializeBinary(b),
54
+ TransactionProto: b => transaction_pb_1.TransactionProto.deserializeBinary(b),
55
+ };
56
+ function load(name) {
57
+ const fixture = JSON.parse(fs.readFileSync(path.join(LEGACY, `${name}.json`), 'utf8'));
58
+ const deserialize = DESERIALIZERS[fixture.message];
59
+ if (!deserialize)
60
+ throw new Error(`no deserializer for ${fixture.message}`);
61
+ return { fixture, message: deserialize(new Uint8Array(fs.readFileSync(path.join(LEGACY, fixture.bin)))) };
62
+ }
63
+ const pascal = (segment) => segment.split('_').map(w => w[0].toUpperCase() + w.slice(1)).join('');
64
+ /** Walks `a.b_c` with getA().getBC(). */
65
+ function walk(message, dotted) {
66
+ return dotted.split('.').reduce((m, segment) => {
67
+ const value = m[`get${pascal(segment)}`]();
68
+ if (value === undefined)
69
+ throw new Error(`${dotted}: ${segment} is unset`);
70
+ return value;
71
+ }, message);
72
+ }
73
+ /** The wrapper getter that reads each path, as Rust's `read_by` names it. */
74
+ function readByWrapper(message, dotted) {
75
+ const mbs = (security) => {
76
+ const wrapped = security_1.default.create(security);
77
+ expect(wrapped).toBeInstanceOf(MortgageBackedSecurity_1.default);
78
+ return wrapped;
79
+ };
80
+ const parts = dotted.split('.');
81
+ const field = parts[parts.length - 1];
82
+ if (dotted === 'price')
83
+ return new Price_1.default(message).getPrice();
84
+ if (dotted === 'quantity')
85
+ return new transaction_1.default(message).getQuantity();
86
+ if (dotted === 'price.price')
87
+ return new Price_1.default(new transaction_1.default(message).getPrice()).getPrice();
88
+ const security = parts[0] === 'security' ? walk(message, 'security') : message;
89
+ const getter = `get${pascal(field)}`;
90
+ const value = mbs(security)[getter]();
91
+ if (!(value instanceof decimal_js_1.Decimal))
92
+ throw new Error(`${dotted}: ${getter} did not return a Decimal`);
93
+ return value;
94
+ }
95
+ beforeAll(() => {
96
+ (0, decimal_1.setDecimalLogger)({ warn: jest.fn() });
97
+ });
98
+ describe.each(['price', 'security', 'transaction'])('legacy_v0433/%s', (name) => {
99
+ const { fixture } = load(name);
100
+ test.each(fixture.decimals.map(d => [d.path, d]))('%s reads through the wrapper', (_p, d) => {
101
+ const { message } = load(name);
102
+ const proto = walk(message, d.path);
103
+ // Really string-only bytes.
104
+ expect(proto.getUnscaledValue_asU8().length).toBe(0);
105
+ expect(proto.getArbitraryPrecisionValue()).toBe(d.stored_string);
106
+ // Same value and scale as the fixture.
107
+ expect((0, decimal_1.decodeDecimal)(proto)).toEqual({ unscaled: BigInt(d.unscaled), scale: d.scale });
108
+ // The wrapper getter returns that exact value.
109
+ const expected = new decimal_js_1.Decimal(d.unscaled).div(new decimal_js_1.Decimal(10).pow(d.scale));
110
+ expect(readByWrapper(message, d.path).equals(expected)).toBe(true);
111
+ if (d.read_by.startsWith('ProtoSerializationUtil')) {
112
+ expect(serialization_1.ProtoSerializationUtil.deserialize(proto).equals(expected)).toBe(true);
113
+ }
114
+ });
115
+ test('re-saving writes both forms with the same value and scale', () => {
116
+ const { message } = load(name);
117
+ for (const d of fixture.decimals) {
118
+ const parentPath = d.path.split('.').slice(0, -1).join('.');
119
+ const parent = parentPath ? walk(message, parentPath) : message;
120
+ const field = d.path.split('.').pop();
121
+ const setter = `set${pascal(field)}`;
122
+ parent[setter]((0, decimal_1.reencodeDecimal)(walk(message, d.path)));
123
+ }
124
+ const reread = DESERIALIZERS[fixture.message](message.serializeBinary());
125
+ for (const d of fixture.decimals) {
126
+ const proto = walk(reread, d.path);
127
+ expect(proto.getUnscaledValue_asU8().length).toBeGreaterThan(0);
128
+ expect(proto.getArbitraryPrecisionValue()).not.toBe('');
129
+ const expected = { unscaled: BigInt(d.unscaled), scale: d.scale };
130
+ const stringOnly = new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue(proto.getArbitraryPrecisionValue());
131
+ const compactOnly = new decimal_value_pb_1.DecimalValueProto().setUnscaledValue(proto.getUnscaledValue_asU8()).setScale(proto.getScale());
132
+ expect((0, decimal_1.decodeDecimal)(compactOnly)).toEqual(expected);
133
+ expect((0, decimal_1.decodeDecimal)(stringOnly)).toEqual(expected);
134
+ }
135
+ });
136
+ });
137
+ describe('wrapper writers set both forms (metrics 2 and 5)', () => {
138
+ const bothForms = (proto, expected) => {
139
+ expect(proto).toBeDefined();
140
+ const p = proto;
141
+ const stringOnly = new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue(p.getArbitraryPrecisionValue());
142
+ const compactOnly = new decimal_value_pb_1.DecimalValueProto().setUnscaledValue(p.getUnscaledValue_asU8()).setScale(p.getScale());
143
+ expect(p.getUnscaledValue_asU8().length).toBeGreaterThan(0);
144
+ expect((0, decimal_1.decodeDecimal)(compactOnly)).toEqual((0, decimal_1.decodeDecimal)(stringOnly));
145
+ expect(new decimal_js_1.Decimal(p.getArbitraryPrecisionValue()).equals(expected)).toBe(true);
146
+ };
147
+ test('a legacy Price re-created through Price.create', () => {
148
+ const legacy = new Price_1.default(load('price').message);
149
+ const saved = Price_1.default.create(legacy.getPrice(), legacy.getSecurity(), legacy.getAsOf());
150
+ const reread = price_pb_1.PriceProto.deserializeBinary(saved.proto.serializeBinary());
151
+ bothForms(reread.getPrice(), new decimal_js_1.Decimal('100.25'));
152
+ });
153
+ test('a legacy Transaction re-created through the Transaction constructor', () => {
154
+ var _a;
155
+ const legacy = new transaction_1.default(load('transaction').message);
156
+ const legacyPrice = new Price_1.default(legacy.getPrice());
157
+ const saved = new transaction_1.default({
158
+ tradeDate: new Date(2026, 0, 2),
159
+ settlementDate: new Date(2026, 0, 4),
160
+ security: legacy.getSecurity(),
161
+ transactionType: legacy.getTransactionType(),
162
+ portfolio: new portfolio_1.default(new portfolio_pb_1.PortfolioProto()
163
+ .setObjectClass('Portfolio').setVersion('0.0.1')
164
+ .setUuid(uuid_1.UUID.random().toUUIDProto()).setPortfolioName('LM-306')),
165
+ quantity: legacy.getQuantity(),
166
+ price: legacyPrice.getPrice(),
167
+ asOfDate: new Date(2026, 0, 2),
168
+ });
169
+ const reread = transaction_pb_1.TransactionProto.deserializeBinary(saved.proto.serializeBinary());
170
+ bothForms(reread.getQuantity(), new decimal_js_1.Decimal(1000));
171
+ bothForms((_a = reread.getPrice()) === null || _a === void 0 ? void 0 : _a.getPrice(), new decimal_js_1.Decimal('-0.50'));
172
+ });
173
+ });
174
+ //# sourceMappingURL=decimal.legacy.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decimal.legacy.test.js","sourceRoot":"","sources":["decimal.legacy.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,2CAAqC;AAErC,wEAAuE;AACvE,iFAAgF;AAChF,0FAAyF;AACzF,uFAAqF;AACrF,2DAAmC;AACnC,oEAA4C;AAC5C,gGAAwE;AACxE,6EAAqD;AACrD,mDAAyD;AACzD,iCAA8B;AAC9B,uEAA+C;AAC/C,oFAAmF;AACnF,uCAA6E;AAE7E;;;;GAIG;AAEH,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,2DAA2D,CAAC,CAAC;AAKjG,MAAM,aAAa,GAA+C;IAC9D,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,qBAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAChD,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC,2BAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACtD,gBAAgB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