@amadeus-protocol/sdk 1.0.4 → 1.0.5

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.
@@ -20,15 +20,17 @@ export declare function fromAtomicAma(atomicAma: number | string): number;
20
20
  /**
21
21
  * Convert human-readable AMA amount to atomic units
22
22
  *
23
- * Uses Math.trunc to avoid floating-point precision issues.
23
+ * Uses string splitting to avoid floating-point precision issues
24
+ * while preserving truncation (never rounds up) for safety.
24
25
  *
25
- * @param ama - Human-readable AMA amount
26
+ * @param ama - Human-readable AMA amount (number or string)
26
27
  * @returns Atomic units (integer)
27
28
  *
28
29
  * @example
29
30
  * ```ts
30
- * const atomic = toAtomicAma(1.5) // Returns 1500000000
31
+ * const atomic = toAtomicAma(1.5) // Returns 1500000000
32
+ * const atomic = toAtomicAma('1.00000001') // Returns 1000000010
31
33
  * ```
32
34
  */
33
- export declare function toAtomicAma(ama: number): number;
35
+ export declare function toAtomicAma(ama: number | string): number;
34
36
  //# sourceMappingURL=conversion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"conversion.d.ts","sourceRoot":"","sources":["../src/conversion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAgBhE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C"}
1
+ {"version":3,"file":"conversion.d.ts","sourceRoot":"","sources":["../src/conversion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAgBhE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAIxD"}
@@ -4,7 +4,7 @@
4
4
  * This module provides functions for converting between atomic units
5
5
  * and human-readable token amounts for the AMA token.
6
6
  */
7
- import { AMA_TOKEN_DECIMALS_MULTIPLIER } from './constants';
7
+ import { AMA_TOKEN_DECIMALS, AMA_TOKEN_DECIMALS_MULTIPLIER } from './constants';
8
8
  /**
9
9
  * Convert atomic AMA units to human-readable AMA amount
10
10
  *
@@ -36,17 +36,21 @@ export function fromAtomicAma(atomicAma) {
36
36
  /**
37
37
  * Convert human-readable AMA amount to atomic units
38
38
  *
39
- * Uses Math.trunc to avoid floating-point precision issues.
39
+ * Uses string splitting to avoid floating-point precision issues
40
+ * while preserving truncation (never rounds up) for safety.
40
41
  *
41
- * @param ama - Human-readable AMA amount
42
+ * @param ama - Human-readable AMA amount (number or string)
42
43
  * @returns Atomic units (integer)
43
44
  *
44
45
  * @example
45
46
  * ```ts
46
- * const atomic = toAtomicAma(1.5) // Returns 1500000000
47
+ * const atomic = toAtomicAma(1.5) // Returns 1500000000
48
+ * const atomic = toAtomicAma('1.00000001') // Returns 1000000010
47
49
  * ```
48
50
  */
49
51
  export function toAtomicAma(ama) {
50
- return Math.trunc(ama * AMA_TOKEN_DECIMALS_MULTIPLIER);
52
+ const num = typeof ama === 'string' ? parseFloat(ama) : ama;
53
+ const [int, frac = ''] = num.toFixed(AMA_TOKEN_DECIMALS).split('.');
54
+ return parseInt(int + frac, 10);
51
55
  }
52
56
  //# sourceMappingURL=conversion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"conversion.js","sourceRoot":"","sources":["../src/conversion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAE3D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,SAA0B;IACvD,MAAM,eAAe,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;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AK,CAAC,sBAAsB,CAAC,CAAA;IACxC,CAAC;IACD,IAAI,eAAe,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;IACtD,CAAC;IACD,OAAO,eAAe,GAAG,6BAA6B,CAAA;AACvD,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,WAAW,CAAC,GAAoB;IAC/C,MAAM,GAAG,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IAC3D,MAAM,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACnE,OAAO,QAAQ,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC,CAAA;AAChC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amadeus-protocol/sdk",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Official TypeScript/JavaScript SDK for Amadeus Protocol - Core utilities for serialization, cryptography, transaction building, and API client",
5
5
  "repository": {
6
6
  "type": "git",