@kynesyslabs/demosdk 2.11.6 → 2.12.0

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.
@@ -0,0 +1,24 @@
1
+ /**
2
+ * DEM/OS denomination constants.
3
+ *
4
+ * The Demos Network uses two denomination units:
5
+ * - DEM: human-readable, the "display" unit users think in.
6
+ * - OS: the smallest indivisible unit, used internally and on the wire.
7
+ *
8
+ * Conversion: 1 DEM = 10^9 OS (1 000 000 000 OS).
9
+ *
10
+ * All on-chain math is performed in OS as `bigint` to avoid floating-point
11
+ * precision loss. Wire format is the OS amount serialized as a decimal string.
12
+ */
13
+ /** Number of decimal places between DEM and OS. */
14
+ export declare const OS_DECIMALS = 9;
15
+ /**
16
+ * Number of OS in 1 DEM, as a `bigint`.
17
+ *
18
+ * @example OS_PER_DEM === 1_000_000_000n
19
+ */
20
+ export declare const OS_PER_DEM: bigint;
21
+ /** Minimum transferable amount: 1 OS. */
22
+ export declare const MIN_AMOUNT_OS = 1n;
23
+ /** Zero amount constant in OS. */
24
+ export declare const ZERO_OS = 0n;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * DEM/OS denomination constants.
3
+ *
4
+ * The Demos Network uses two denomination units:
5
+ * - DEM: human-readable, the "display" unit users think in.
6
+ * - OS: the smallest indivisible unit, used internally and on the wire.
7
+ *
8
+ * Conversion: 1 DEM = 10^9 OS (1 000 000 000 OS).
9
+ *
10
+ * All on-chain math is performed in OS as `bigint` to avoid floating-point
11
+ * precision loss. Wire format is the OS amount serialized as a decimal string.
12
+ */
13
+ // REVIEW: P0 foundation — denomination constants exported but not yet used by
14
+ // any existing SDK code. Adoption happens in later phases.
15
+ /** Number of decimal places between DEM and OS. */
16
+ export const OS_DECIMALS = 9;
17
+ /**
18
+ * Number of OS in 1 DEM, as a `bigint`.
19
+ *
20
+ * @example OS_PER_DEM === 1_000_000_000n
21
+ */
22
+ export const OS_PER_DEM = BigInt(10 ** OS_DECIMALS); // 1_000_000_000n
23
+ /** Minimum transferable amount: 1 OS. */
24
+ export const MIN_AMOUNT_OS = 1n;
25
+ /** Zero amount constant in OS. */
26
+ export const ZERO_OS = 0n;
27
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/denomination/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,8EAA8E;AAC9E,2DAA2D;AAE3D,mDAAmD;AACnD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAA;AAE5B;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,EAAE,IAAI,WAAW,CAAC,CAAA,CAAC,iBAAiB;AAErE,yCAAyC;AACzC,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAA;AAE/B,kCAAkC;AAClC,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,CAAA"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * DEM <-> OS conversion utilities.
3
+ *
4
+ * Internal representation: `bigint` (OS, smallest unit).
5
+ * Wire representation: decimal `string` (OS).
6
+ * Display representation: decimal `string` (DEM, human-readable).
7
+ *
8
+ * 1 DEM = 10^9 OS.
9
+ */
10
+ /**
11
+ * Convert a DEM amount (human-readable) to an OS amount (smallest unit).
12
+ *
13
+ * Accepts `number` or `string` for ergonomics. The result is always a `bigint`.
14
+ * Strings are preferred for high-precision input because JavaScript `number`
15
+ * cannot represent every 9-decimal value exactly.
16
+ *
17
+ * Throws if:
18
+ * - The input has more than {@link OS_DECIMALS} fractional digits.
19
+ * - The resulting amount is negative.
20
+ *
21
+ * @example demToOs(1) // => 1_000_000_000n
22
+ * @example demToOs("0.5") // => 500_000_000n
23
+ * @example demToOs(100) // => 100_000_000_000n
24
+ * @example demToOs("1.123456789")// => 1_123_456_789n
25
+ *
26
+ * @param dem - DEM amount as `number` or decimal `string`.
27
+ * @returns OS amount as `bigint`.
28
+ */
29
+ export declare function demToOs(dem: number | string): bigint;
30
+ /**
31
+ * Convert an OS amount (smallest unit) to a DEM string (human-readable).
32
+ *
33
+ * Always returns a `string` to preserve precision. The result has exactly one
34
+ * decimal point, with trailing fractional zeros trimmed (but at least one
35
+ * fractional digit retained).
36
+ *
37
+ * Negative inputs are supported and produce a leading `-`.
38
+ *
39
+ * @example osToDem(1_000_000_000n) // => "1.0"
40
+ * @example osToDem(500_000_000n) // => "0.5"
41
+ * @example osToDem(1n) // => "0.000000001"
42
+ * @example osToDem(0n) // => "0.0"
43
+ *
44
+ * @param os - OS amount as `bigint`.
45
+ * @returns DEM amount as decimal `string`.
46
+ */
47
+ export declare function osToDem(os: bigint): string;
48
+ /**
49
+ * Parse a wire-format OS string into a `bigint`.
50
+ *
51
+ * The wire format is always the OS amount as a base-10 integer string.
52
+ *
53
+ * @example parseOsString("1000000000") // => 1_000_000_000n
54
+ *
55
+ * @param osString - OS amount as a decimal integer string.
56
+ * @returns OS amount as `bigint`.
57
+ */
58
+ export declare function parseOsString(osString: string): bigint;
59
+ /**
60
+ * Serialize a `bigint` OS amount to its wire-format string.
61
+ *
62
+ * @example toOsString(1_000_000_000n) // => "1000000000"
63
+ *
64
+ * @param os - OS amount as `bigint`.
65
+ * @returns OS amount as a decimal integer string.
66
+ */
67
+ export declare function toOsString(os: bigint): string;
68
+ /**
69
+ * Format an OS amount as a human-readable DEM string with a unit suffix.
70
+ *
71
+ * Useful for log lines, error messages, and UI display.
72
+ *
73
+ * @example formatDem(1_000_000_000n) // => "1.0 DEM"
74
+ *
75
+ * @param os - OS amount as `bigint`.
76
+ * @returns Human-readable DEM string with " DEM" suffix.
77
+ */
78
+ export declare function formatDem(os: bigint): string;
@@ -0,0 +1,114 @@
1
+ /**
2
+ * DEM <-> OS conversion utilities.
3
+ *
4
+ * Internal representation: `bigint` (OS, smallest unit).
5
+ * Wire representation: decimal `string` (OS).
6
+ * Display representation: decimal `string` (DEM, human-readable).
7
+ *
8
+ * 1 DEM = 10^9 OS.
9
+ */
10
+ import { OS_DECIMALS, ZERO_OS } from "./constants.js";
11
+ // REVIEW: P0 foundation — conversion utilities exported but not yet wired into
12
+ // any existing SDK code path. They are dormant until later migration phases.
13
+ /**
14
+ * Convert a DEM amount (human-readable) to an OS amount (smallest unit).
15
+ *
16
+ * Accepts `number` or `string` for ergonomics. The result is always a `bigint`.
17
+ * Strings are preferred for high-precision input because JavaScript `number`
18
+ * cannot represent every 9-decimal value exactly.
19
+ *
20
+ * Throws if:
21
+ * - The input has more than {@link OS_DECIMALS} fractional digits.
22
+ * - The resulting amount is negative.
23
+ *
24
+ * @example demToOs(1) // => 1_000_000_000n
25
+ * @example demToOs("0.5") // => 500_000_000n
26
+ * @example demToOs(100) // => 100_000_000_000n
27
+ * @example demToOs("1.123456789")// => 1_123_456_789n
28
+ *
29
+ * @param dem - DEM amount as `number` or decimal `string`.
30
+ * @returns OS amount as `bigint`.
31
+ */
32
+ export function demToOs(dem) {
33
+ const str = typeof dem === "number" ? dem.toString() : dem;
34
+ // Split on decimal point. Missing fractional part defaults to "".
35
+ const [whole, frac = ""] = str.split(".");
36
+ if (frac.length > OS_DECIMALS) {
37
+ throw new Error(`DEM amount "${str}" exceeds maximum ${OS_DECIMALS} decimal places`);
38
+ }
39
+ // Pad fractional part to exactly OS_DECIMALS digits, then concatenate.
40
+ const paddedFrac = frac.padEnd(OS_DECIMALS, "0");
41
+ const combined = `${whole}${paddedFrac}`;
42
+ const result = BigInt(combined);
43
+ if (result < ZERO_OS) {
44
+ throw new Error(`Negative amounts not allowed: ${str}`);
45
+ }
46
+ return result;
47
+ }
48
+ /**
49
+ * Convert an OS amount (smallest unit) to a DEM string (human-readable).
50
+ *
51
+ * Always returns a `string` to preserve precision. The result has exactly one
52
+ * decimal point, with trailing fractional zeros trimmed (but at least one
53
+ * fractional digit retained).
54
+ *
55
+ * Negative inputs are supported and produce a leading `-`.
56
+ *
57
+ * @example osToDem(1_000_000_000n) // => "1.0"
58
+ * @example osToDem(500_000_000n) // => "0.5"
59
+ * @example osToDem(1n) // => "0.000000001"
60
+ * @example osToDem(0n) // => "0.0"
61
+ *
62
+ * @param os - OS amount as `bigint`.
63
+ * @returns DEM amount as decimal `string`.
64
+ */
65
+ export function osToDem(os) {
66
+ const isNegative = os < ZERO_OS;
67
+ const abs = isNegative ? -os : os;
68
+ // Pad so we always have at least OS_DECIMALS+1 digits, ensuring the
69
+ // whole-number slice is non-empty for sub-1-DEM values.
70
+ const str = abs.toString().padStart(OS_DECIMALS + 1, "0");
71
+ const whole = str.slice(0, str.length - OS_DECIMALS);
72
+ const frac = str.slice(str.length - OS_DECIMALS);
73
+ // Trim trailing zeros from fractional part, but keep at least one digit.
74
+ const trimmedFrac = frac.replace(/0+$/, "") || "0";
75
+ return `${isNegative ? "-" : ""}${whole}.${trimmedFrac}`;
76
+ }
77
+ /**
78
+ * Parse a wire-format OS string into a `bigint`.
79
+ *
80
+ * The wire format is always the OS amount as a base-10 integer string.
81
+ *
82
+ * @example parseOsString("1000000000") // => 1_000_000_000n
83
+ *
84
+ * @param osString - OS amount as a decimal integer string.
85
+ * @returns OS amount as `bigint`.
86
+ */
87
+ export function parseOsString(osString) {
88
+ return BigInt(osString);
89
+ }
90
+ /**
91
+ * Serialize a `bigint` OS amount to its wire-format string.
92
+ *
93
+ * @example toOsString(1_000_000_000n) // => "1000000000"
94
+ *
95
+ * @param os - OS amount as `bigint`.
96
+ * @returns OS amount as a decimal integer string.
97
+ */
98
+ export function toOsString(os) {
99
+ return os.toString();
100
+ }
101
+ /**
102
+ * Format an OS amount as a human-readable DEM string with a unit suffix.
103
+ *
104
+ * Useful for log lines, error messages, and UI display.
105
+ *
106
+ * @example formatDem(1_000_000_000n) // => "1.0 DEM"
107
+ *
108
+ * @param os - OS amount as `bigint`.
109
+ * @returns Human-readable DEM string with " DEM" suffix.
110
+ */
111
+ export function formatDem(os) {
112
+ return `${osToDem(os)} DEM`;
113
+ }
114
+ //# sourceMappingURL=conversion.js.map
@@ -0,0 +1 @@
1
+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;IACxD,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,WAAW,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;IAEzD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,GAAG,WAAW,CAAC,CAAA;IACpD,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,GAAG,WAAW,CAAC,CAAA;IAEhD,yEAAyE;IACzE,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAA;IAElD,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,WAAW,EAAE,CAAA;AAC5D,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC1C,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAA;AAC3B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,EAAU;IACjC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAA;AACxB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS,CAAC,EAAU;IAChC,OAAO,GAAG,OAAO,CAAC,EAAE,CAAC,MAAM,CAAA;AAC/B,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,60 @@
1
+ import { describe, test, expect } from "bun:test";
2
+ import { demToOs, osToDem, parseOsString, toOsString, formatDem, } from "./conversion.js";
3
+ // REVIEW: P0 foundation — verbatim test suite from IDEA.md §0.5 plus three
4
+ // edge-case tests called out in the P0 task brief.
5
+ describe("demToOs", () => {
6
+ test("converts whole DEM to OS", () => {
7
+ expect(demToOs(1)).toBe(1000000000n);
8
+ expect(demToOs(100)).toBe(100000000000n);
9
+ expect(demToOs(0)).toBe(0n);
10
+ });
11
+ test("converts fractional DEM to OS", () => {
12
+ expect(demToOs("0.5")).toBe(500000000n);
13
+ expect(demToOs("0.000000001")).toBe(1n);
14
+ expect(demToOs("1.123456789")).toBe(1123456789n);
15
+ });
16
+ test("rejects too many decimals", () => {
17
+ expect(() => demToOs("0.0000000001")).toThrow("exceeds maximum 9 decimal places");
18
+ });
19
+ test("accepts string input", () => {
20
+ expect(demToOs("100")).toBe(100000000000n);
21
+ });
22
+ // Edge case: explicit zero string input.
23
+ test("converts the string \"0\" to 0n", () => {
24
+ expect(demToOs("0")).toBe(0n);
25
+ });
26
+ // Edge case: negative inputs are rejected with a clear message. The
27
+ // BigInt of "-1000000000" is < 0n, which trips the negativity guard.
28
+ test("rejects negative DEM input", () => {
29
+ expect(() => demToOs(-1)).toThrow("Negative amounts not allowed");
30
+ });
31
+ });
32
+ describe("osToDem", () => {
33
+ test("converts OS to DEM string", () => {
34
+ expect(osToDem(1000000000n)).toBe("1.0");
35
+ expect(osToDem(500000000n)).toBe("0.5");
36
+ expect(osToDem(1n)).toBe("0.000000001");
37
+ expect(osToDem(0n)).toBe("0.0");
38
+ });
39
+ test("handles large amounts", () => {
40
+ expect(osToDem(1000000000000000000n)).toBe("1000000000.0");
41
+ });
42
+ // Edge case: negative OS amounts produce a leading "-" and otherwise
43
+ // follow the same trimming rules as positive amounts.
44
+ test("handles negative OS amounts", () => {
45
+ expect(osToDem(-500000000n)).toBe("-0.5");
46
+ });
47
+ });
48
+ describe("wire format", () => {
49
+ test("round-trips through string serialization", () => {
50
+ const original = 123456789012n;
51
+ const wire = toOsString(original);
52
+ expect(parseOsString(wire)).toBe(original);
53
+ });
54
+ });
55
+ describe("formatDem", () => {
56
+ test("formats with unit", () => {
57
+ expect(formatDem(1000000000n)).toBe("1.0 DEM");
58
+ });
59
+ });
60
+ //# sourceMappingURL=conversion.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversion.test.js","sourceRoot":"","sources":["../../../src/denomination/conversion.test.ts"],"names":[],"mappings":"AAA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AAE;IACzB,IAAI,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,MAAM,QAAQ,GAAG,aAAgB,CAAA;QACjC,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;QACjC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC9C,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACvB,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,SAAS,CAAC,WAAc,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACrD,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * DEM/OS denomination utilities.
3
+ *
4
+ * Public surface for converting between human-readable DEM amounts and
5
+ * the internal/wire OS unit. See `./constants` and `./conversion` for details.
6
+ *
7
+ * 1 DEM = 10^9 OS.
8
+ */
9
+ export { OS_DECIMALS, OS_PER_DEM, MIN_AMOUNT_OS, ZERO_OS, } from "./constants";
10
+ export { demToOs, osToDem, parseOsString, toOsString, formatDem, } from "./conversion";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * DEM/OS denomination utilities.
3
+ *
4
+ * Public surface for converting between human-readable DEM amounts and
5
+ * the internal/wire OS unit. See `./constants` and `./conversion` for details.
6
+ *
7
+ * 1 DEM = 10^9 OS.
8
+ */
9
+ // REVIEW: P0 foundation — barrel export for the new denomination module.
10
+ export { OS_DECIMALS, OS_PER_DEM, MIN_AMOUNT_OS, ZERO_OS, } from "./constants.js";
11
+ export { demToOs, osToDem, parseOsString, toOsString, formatDem, } from "./conversion.js";
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/denomination/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,yEAAyE;AAEzE,OAAO,EACH,WAAW,EACX,UAAU,EACV,aAAa,EACb,OAAO,GACV,MAAM,aAAa,CAAA;AAEpB,OAAO,EACH,OAAO,EACP,OAAO,EACP,aAAa,EACb,UAAU,EACV,SAAS,GACZ,MAAM,cAAc,CAAA"}
package/build/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * as types from "./types";
2
2
  export * as encryption from "./encryption";
3
3
  export * as utils from "./utils";
4
+ export * as denomination from "./denomination";
4
5
  export * as xmlocalsdk from "./multichain/localsdk";
5
6
  export * as xmwebsdk from "./multichain/websdk";
6
7
  export * as xmcore from "./multichain/core";
package/build/index.js CHANGED
@@ -3,6 +3,9 @@ export * as types from "./types/index.js";
3
3
  // Basic cryptographic and data manipulation functions
4
4
  export * as encryption from "./encryption/index.js";
5
5
  export * as utils from "./utils/index.js";
6
+ // REVIEW: P0 foundation — DEM/OS denomination utilities. Dormant exports;
7
+ // not yet consumed by any other SDK module.
8
+ export * as denomination from "./denomination/index.js";
6
9
  // Specific features of the SDK
7
10
  export * as xmlocalsdk from "./multichain/localsdk/index.js";
8
11
  export * as xmwebsdk from "./multichain/websdk/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAA;AAChC,sDAAsD;AACtD,OAAO,KAAK,UAAU,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,KAAK,MAAM,SAAS,CAAA;AAEhC,gCAAgC;AAChC,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA,CAAC,gCAAgC;AAE5E,OAAO,KAAK,MAAM,MAAM,UAAU,CAAA;AAClC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAA;AAExC,OAAO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AAO,KAAK,gBAAgB,MAAM,qBAAqB,CAAA;AAEvD,OAAO,KAAK,OAAO,MAAM,WAAW,CAAA;AAEpC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAA;AAElC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA;AAE9B,OAAO,KAAK,SAAS,MAAM,aAAa,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kynesyslabs/demosdk",
3
- "version": "2.11.6",
3
+ "version": "2.12.0",
4
4
  "type": "module",
5
5
  "description": "Demosdk is a JavaScript/TypeScript SDK that provides a unified interface for interacting with Demos network",
6
6
  "main": "build/index.js",