@kynesyslabs/demosdk 2.12.2 → 3.1.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.
Files changed (74) hide show
  1. package/build/bridge/nativeBridgeTypes.d.ts +4 -3
  2. package/build/bridge/nativeBridgeTypes.js.map +1 -1
  3. package/build/d402/client/types.d.ts +6 -3
  4. package/build/d402/server/D402Server.d.ts +25 -0
  5. package/build/d402/server/D402Server.js +63 -2
  6. package/build/d402/server/D402Server.js.map +1 -1
  7. package/build/d402/server/middleware.d.ts +7 -4
  8. package/build/d402/server/middleware.js.map +1 -1
  9. package/build/d402/server/types.d.ts +15 -7
  10. package/build/denomination/conversion.test.js +1 -1
  11. package/build/denomination/conversion.test.js.map +1 -1
  12. package/build/denomination/index.d.ts +3 -0
  13. package/build/denomination/index.js +6 -0
  14. package/build/denomination/index.js.map +1 -1
  15. package/build/denomination/networkInfo.d.ts +69 -0
  16. package/build/denomination/networkInfo.js +38 -0
  17. package/build/denomination/networkInfo.js.map +1 -0
  18. package/build/denomination/networkInfo.test.d.ts +1 -0
  19. package/build/denomination/networkInfo.test.js +28 -0
  20. package/build/denomination/networkInfo.test.js.map +1 -0
  21. package/build/denomination/roundTripHash.test.d.ts +1 -0
  22. package/build/denomination/roundTripHash.test.js +227 -0
  23. package/build/denomination/roundTripHash.test.js.map +1 -0
  24. package/build/denomination/serializerGate.d.ts +46 -0
  25. package/build/denomination/serializerGate.js +283 -0
  26. package/build/denomination/serializerGate.js.map +1 -0
  27. package/build/denomination/serializerGate.test.d.ts +1 -0
  28. package/build/denomination/serializerGate.test.js +245 -0
  29. package/build/denomination/serializerGate.test.js.map +1 -0
  30. package/build/escrow/EscrowTransaction.d.ts +36 -5
  31. package/build/escrow/EscrowTransaction.js +91 -10
  32. package/build/escrow/EscrowTransaction.js.map +1 -1
  33. package/build/ipfs/IPFSOperations.d.ts +37 -10
  34. package/build/ipfs/IPFSOperations.js +38 -8
  35. package/build/ipfs/IPFSOperations.js.map +1 -1
  36. package/build/storage/StorageProgram.d.ts +16 -8
  37. package/build/storage/StorageProgram.js +16 -8
  38. package/build/storage/StorageProgram.js.map +1 -1
  39. package/build/tlsnotary/TLSNotaryService.d.ts +19 -8
  40. package/build/tlsnotary/TLSNotaryService.js +22 -7
  41. package/build/tlsnotary/TLSNotaryService.js.map +1 -1
  42. package/build/tlsnotary/helpers.d.ts +11 -5
  43. package/build/tlsnotary/helpers.js +17 -5
  44. package/build/tlsnotary/helpers.js.map +1 -1
  45. package/build/types/blockchain/CustomCharges.d.ts +28 -16
  46. package/build/types/blockchain/CustomCharges.js +15 -5
  47. package/build/types/blockchain/CustomCharges.js.map +1 -1
  48. package/build/types/blockchain/GCREdit.d.ts +26 -2
  49. package/build/types/blockchain/Transaction.d.ts +14 -1
  50. package/build/types/blockchain/Transaction.js.map +1 -1
  51. package/build/types/blockchain/TransactionSubtypes/D402PaymentTransaction.d.ts +8 -3
  52. package/build/types/blockchain/TransactionSubtypes/StorageProgramTransaction.d.ts +6 -5
  53. package/build/types/blockchain/TransactionSubtypes/StorageProgramTransaction.js +15 -3
  54. package/build/types/blockchain/TransactionSubtypes/StorageProgramTransaction.js.map +1 -1
  55. package/build/types/blockchain/TxFee.d.ts +16 -3
  56. package/build/types/blockchain/address.d.ts +23 -0
  57. package/build/types/blockchain/rawTransaction.d.ts +13 -4
  58. package/build/types/blockchain/statusNative.d.ts +9 -1
  59. package/build/types/bridge/bridgeTradePayload.d.ts +1 -1
  60. package/build/types/gls/StateChange.d.ts +29 -3
  61. package/build/types/native/INativePayload.d.ts +6 -1
  62. package/build/wallet/Wallet.d.ts +27 -1
  63. package/build/wallet/Wallet.js +30 -17
  64. package/build/wallet/Wallet.js.map +1 -1
  65. package/build/websdk/DemosTransactions.d.ts +30 -4
  66. package/build/websdk/DemosTransactions.js +88 -9
  67. package/build/websdk/DemosTransactions.js.map +1 -1
  68. package/build/websdk/GCRGeneration.d.ts +10 -2
  69. package/build/websdk/GCRGeneration.js +30 -14
  70. package/build/websdk/GCRGeneration.js.map +1 -1
  71. package/build/websdk/demosclass.d.ts +152 -23
  72. package/build/websdk/demosclass.js +305 -38
  73. package/build/websdk/demosclass.js.map +1 -1
  74. package/package.json +1 -1
@@ -5,33 +5,40 @@
5
5
  * before execution. Used in the confirm/execute two-step transaction flow
6
6
  * to provide cost transparency.
7
7
  *
8
- * @fileoverview Custom charges type definitions for cost estimation
8
+ * @fileoverview Custom charges type definitions for cost estimation.
9
+ *
10
+ * P4 denomination migration:
11
+ * All cost fields are bigint-as-decimal-`string` in **OS** (smallest
12
+ * unit, 1 DEM = 10^9 OS). Field names changed from `*_dem` to `*_os` to
13
+ * reflect the new denomination. Pre-fork-compatible bridges should
14
+ * serialise these via the SDK's `serializerGate`, which converts to
15
+ * the legacy DEM-`number` shape for pre-fork nodes.
9
16
  */
10
17
  /**
11
18
  * Cost breakdown for IPFS operations
12
19
  *
13
20
  * Provides detailed cost calculation components so users can understand
14
- * what they're paying for.
21
+ * what they're paying for. All values are decimal-string OS amounts.
15
22
  */
16
23
  export interface IPFSCostBreakdown {
17
- /** Base cost for the operation in DEM wei */
24
+ /** Base cost for the operation, decimal-string OS. */
18
25
  base_cost: string;
19
- /** Cost based on file size in DEM wei */
26
+ /** Cost based on file size, decimal-string OS. */
20
27
  size_cost: string;
21
- /** Cost based on storage duration in DEM wei (optional for indefinite pins) */
28
+ /** Cost based on storage duration, decimal-string OS (optional for indefinite pins). */
22
29
  duration_cost?: string;
23
- /** Any additional costs (network fees, etc.) */
30
+ /** Any additional costs (network fees, etc.) — decimal-string OS values. */
24
31
  additional_costs?: Record<string, string>;
25
32
  }
26
33
  /**
27
34
  * IPFS custom charges configuration
28
35
  *
29
36
  * Included in transaction content to specify maximum cost user agrees to pay.
30
- * Node will validate that actual cost does not exceed max_cost_dem.
37
+ * Node will validate that actual cost does not exceed `max_cost_os`.
31
38
  */
32
39
  export interface IPFSCustomCharges {
33
- /** Maximum cost user is willing to pay (in DEM wei as string for BigInt safety) */
34
- max_cost_dem: string;
40
+ /** Maximum cost user is willing to pay, decimal-string OS (BigInt-safe). */
41
+ max_cost_os: string;
35
42
  /** File size in bytes - used for cost calculation validation */
36
43
  file_size_bytes: number;
37
44
  /** IPFS operation type */
@@ -54,7 +61,7 @@ export interface IPFSCustomCharges {
54
61
  * // ... other fields
55
62
  * custom_charges: {
56
63
  * ipfs: {
57
- * max_cost_dem: "1000000000000000000",
64
+ * max_cost_os: "1000000000", // 1 DEM in OS
58
65
  * file_size_bytes: 1024,
59
66
  * operation: "IPFS_ADD"
60
67
  * }
@@ -70,14 +77,16 @@ export interface CustomCharges {
70
77
  *
71
78
  * Returned by confirmTx to show actual costs vs maximum user agreed to pay.
72
79
  * Allows user to review and abort if actual cost is higher than expected.
80
+ *
81
+ * All cost fields are decimal-string OS.
73
82
  */
74
83
  export interface ValidityDataCustomCharges {
75
84
  /** Charge type identifier */
76
85
  type: "ipfs_storage" | "ipfs_bandwidth" | "compute" | string;
77
- /** What user signed as maximum (from TX custom_charges) */
78
- max_cost_dem: string;
79
- /** What node will actually charge (must be <= max_cost_dem) */
80
- actual_cost_dem: string;
86
+ /** What user signed as maximum (from TX `custom_charges`), decimal-string OS. */
87
+ max_cost_os: string;
88
+ /** What node will actually charge (must be `<= max_cost_os`), decimal-string OS. */
89
+ actual_cost_os: string;
81
90
  /** Detailed breakdown of actual costs */
82
91
  breakdown: IPFSCostBreakdown;
83
92
  }
@@ -88,6 +97,9 @@ export declare function hasIPFSCustomCharges(charges: CustomCharges | undefined)
88
97
  ipfs: IPFSCustomCharges;
89
98
  };
90
99
  /**
91
- * Validate that actual cost does not exceed maximum
100
+ * Validate that actual cost does not exceed maximum.
101
+ *
102
+ * Inputs are decimal-string OS amounts; both must parse cleanly as
103
+ * non-negative bigints.
92
104
  */
93
- export declare function isValidCharge(maxCostDem: string, actualCostDem: string): boolean;
105
+ export declare function isValidCharge(maxCostOs: string, actualCostOs: string): boolean;
@@ -5,7 +5,14 @@
5
5
  * before execution. Used in the confirm/execute two-step transaction flow
6
6
  * to provide cost transparency.
7
7
  *
8
- * @fileoverview Custom charges type definitions for cost estimation
8
+ * @fileoverview Custom charges type definitions for cost estimation.
9
+ *
10
+ * P4 denomination migration:
11
+ * All cost fields are bigint-as-decimal-`string` in **OS** (smallest
12
+ * unit, 1 DEM = 10^9 OS). Field names changed from `*_dem` to `*_os` to
13
+ * reflect the new denomination. Pre-fork-compatible bridges should
14
+ * serialise these via the SDK's `serializerGate`, which converts to
15
+ * the legacy DEM-`number` shape for pre-fork nodes.
9
16
  */
10
17
  // ============================================================================
11
18
  // Type Guards
@@ -17,12 +24,15 @@ export function hasIPFSCustomCharges(charges) {
17
24
  return charges?.ipfs !== undefined;
18
25
  }
19
26
  /**
20
- * Validate that actual cost does not exceed maximum
27
+ * Validate that actual cost does not exceed maximum.
28
+ *
29
+ * Inputs are decimal-string OS amounts; both must parse cleanly as
30
+ * non-negative bigints.
21
31
  */
22
- export function isValidCharge(maxCostDem, actualCostDem) {
32
+ export function isValidCharge(maxCostOs, actualCostOs) {
23
33
  try {
24
- const max = BigInt(maxCostDem);
25
- const actual = BigInt(actualCostDem);
34
+ const max = BigInt(maxCostOs);
35
+ const actual = BigInt(actualCostOs);
26
36
  return actual <= max;
27
37
  }
28
38
  catch {
@@ -1 +1 @@
1
- {"version":3,"file":"CustomCharges.js","sourceRoot":"","sources":["../../../../src/types/blockchain/CustomCharges.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA2GH,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAChC,OAAkC;IAElC,OAAO,OAAO,EAAE,IAAI,KAAK,SAAS,CAAA;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CACzB,UAAkB,EAClB,aAAqB;IAErB,IAAI,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;QAC9B,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;QACpC,OAAO,MAAM,IAAI,GAAG,CAAA;IACxB,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,KAAK,CAAA;IAChB,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"CustomCharges.js","sourceRoot":"","sources":["../../../../src/types/blockchain/CustomCharges.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA6GH,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAChC,OAAkC;IAElC,OAAO,OAAO,EAAE,IAAI,KAAK,SAAS,CAAA;AACtC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CACzB,SAAiB,EACjB,YAAoB;IAEpB,IAAI,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;QAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;QACnC,OAAO,MAAM,IAAI,GAAG,CAAA;IACxB,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,KAAK,CAAA;IAChB,CAAC;AACL,CAAC"}
@@ -1,13 +1,32 @@
1
1
  import { IdentityAttestationPayload, IdentityCommitmentPayload, PqcIdentityRemovePayload, UDIdentityPayload, XMCoreTargetIdentityPayload, NomisWalletIdentity, HumanPassportIdentityData, EthosWalletIdentity, TLSNIdentityContext, TLSNProofRanges } from "../abstraction";
2
2
  import { SigningAlgorithm } from "../cryptography";
3
+ /**
4
+ * Balance-mutation GCR edit — adds to or subtracts from a sender/receiver
5
+ * balance, or burns a fee.
6
+ *
7
+ * Wire-format compatibility (P4): `amount` may be either a JS `number`
8
+ * (pre-fork node, DEM) or a decimal `string` in OS (post-fork node). The
9
+ * SDK's `GCRGeneration` populates the field with whichever shape matches
10
+ * the connected node's fork status.
11
+ *
12
+ * Important: the node's post-fork serializer (`forks/serializerGate.ts`)
13
+ * does **not** re-encode `gcr_edits[].amount`. Whatever the SDK puts here
14
+ * **is** the wire format and contributes directly to the transaction
15
+ * hash. Construction-site correctness is the contract.
16
+ */
3
17
  export interface GCREditBalance {
4
18
  type: "balance";
5
19
  isRollback: boolean;
6
20
  operation: "add" | "remove";
7
21
  account: string;
8
- amount: number;
22
+ amount: number | string;
9
23
  txhash: string;
10
24
  }
25
+ /**
26
+ * Nonce-increment GCR edit. `amount` is a counter delta, not a token
27
+ * amount — always `1` in current code. Kept as `number` because the fork
28
+ * does not change its encoding. Do **not** confuse with `GCREditBalance.amount`.
29
+ */
11
30
  export interface GCREditNonce {
12
31
  type: "nonce";
13
32
  isRollback: boolean;
@@ -137,7 +156,12 @@ export interface GCREditEscrow {
137
156
  sender?: string;
138
157
  platform?: "twitter" | "github" | "telegram";
139
158
  username?: string;
140
- amount?: number;
159
+ /**
160
+ * Escrow deposit amount. Wire format follows the same pre-fork /
161
+ * post-fork rule as `GCREditBalance.amount`: `number` DEM
162
+ * pre-fork, decimal `string` OS post-fork.
163
+ */
164
+ amount?: number | string;
141
165
  expiryDays?: number;
142
166
  message?: string;
143
167
  claimant?: string;
@@ -30,7 +30,20 @@ export interface TransactionContent {
30
30
  from: string;
31
31
  from_ed25519_address: string;
32
32
  to: string;
33
- amount: number;
33
+ /**
34
+ * Native DEM amount transferred by this transaction.
35
+ *
36
+ * Wire-format compatibility:
37
+ * - Pre-fork node: encoded as JS `number` in DEM.
38
+ * - Post-fork node: encoded as a decimal `string` in OS (1 DEM = 10^9 OS).
39
+ *
40
+ * Both shapes are accepted on input; the SDK's `serializerGate`
41
+ * (P4 commit 2) normalises to the right wire shape per fork status
42
+ * before signing. SDK-internal arithmetic always uses `bigint` OS via
43
+ * `denomination` utilities — never raw `number`, which loses precision
44
+ * above 2^53 OS (~9 million DEM).
45
+ */
46
+ amount: number | string;
34
47
  data: TransactionContentData;
35
48
  gcr_edits: GCREdit[];
36
49
  nonce: number;
@@ -1 +1 @@
1
- {"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../../src/types/blockchain/Transaction.ts"],"names":[],"mappings":"AA2HA,uCAAuC;AACvC,cAAc,uBAAuB,CAAA"}
1
+ {"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../../src/types/blockchain/Transaction.ts"],"names":[],"mappings":"AAwIA,uCAAuC;AACvC,cAAc,uBAAuB,CAAA"}
@@ -1,13 +1,18 @@
1
1
  import { Transaction, TransactionContent } from "../Transaction";
2
2
  /**
3
3
  * D402 Payment Payload
4
- * Represents a gasless payment transaction in the D402 protocol
4
+ * Represents a gasless payment transaction in the D402 protocol.
5
+ *
6
+ * Wire-format compatibility (P4): `amount` may be either a JS `number`
7
+ * (pre-fork DEM, legacy) or a decimal `string` in OS (post-fork). The
8
+ * SDK's serializerGate normalises at the wire boundary based on the
9
+ * connected node's fork status.
5
10
  */
6
11
  export interface D402PaymentPayload {
7
12
  /** Recipient's Demos address */
8
13
  to: string;
9
- /** Payment amount in smallest unit */
10
- amount: number;
14
+ /** Payment amount: pre-fork `number` (DEM) or post-fork `string` (OS). */
15
+ amount: number | string;
11
16
  /** Optional memo/description for the payment */
12
17
  memo?: string;
13
18
  }
@@ -1,14 +1,15 @@
1
1
  import { Transaction, TransactionContent } from "../Transaction";
2
- /**
3
- * Storage Program constants for validation and pricing
4
- */
5
2
  export declare const STORAGE_PROGRAM_CONSTANTS: {
6
3
  /** Maximum storage size in bytes (1MB) */
7
4
  readonly MAX_SIZE_BYTES: 1048576;
8
5
  /** Size chunk for pricing in bytes (10KB) */
9
6
  readonly PRICING_CHUNK_BYTES: 10240;
10
- /** Fee per chunk in DEM */
11
- readonly FEE_PER_CHUNK: 1n;
7
+ /**
8
+ * Fee per chunk, expressed in OS (= 1 DEM = 10^9 OS).
9
+ * Use bigint arithmetic at every call site; the SDK never widens
10
+ * back to JS `number`, which loses precision above 2^53.
11
+ */
12
+ readonly FEE_PER_CHUNK: bigint;
12
13
  /** Maximum nesting depth for JSON encoding */
13
14
  readonly MAX_JSON_NESTING_DEPTH: 64;
14
15
  };
@@ -3,15 +3,27 @@
3
3
  // Constants
4
4
  // ============================================================================
5
5
  /**
6
- * Storage Program constants for validation and pricing
6
+ * Storage Program constants for validation and pricing.
7
+ *
8
+ * P4 fix: prior to this revision `FEE_PER_CHUNK` was hard-coded as `1n`,
9
+ * which represented "1 OS" (the smallest unit) — off by `10^9` from the
10
+ * intended "1 DEM per chunk" pricing. Now expressed as `OS_PER_DEM` to
11
+ * make the unit explicit and the pricing correct on the SDK side. (Note:
12
+ * the node's matching constant must be aligned by P5 to avoid SDK/node
13
+ * fee-schedule drift — flagged for follow-up.)
7
14
  */
15
+ import { OS_PER_DEM } from "../../../denomination/index.js";
8
16
  export const STORAGE_PROGRAM_CONSTANTS = {
9
17
  /** Maximum storage size in bytes (1MB) */
10
18
  MAX_SIZE_BYTES: 1048576,
11
19
  /** Size chunk for pricing in bytes (10KB) */
12
20
  PRICING_CHUNK_BYTES: 10240,
13
- /** Fee per chunk in DEM */
14
- FEE_PER_CHUNK: 1n,
21
+ /**
22
+ * Fee per chunk, expressed in OS (= 1 DEM = 10^9 OS).
23
+ * Use bigint arithmetic at every call site; the SDK never widens
24
+ * back to JS `number`, which loses precision above 2^53.
25
+ */
26
+ FEE_PER_CHUNK: OS_PER_DEM,
15
27
  /** Maximum nesting depth for JSON encoding */
16
28
  MAX_JSON_NESTING_DEPTH: 64,
17
29
  };
@@ -1 +1 @@
1
- {"version":3,"file":"StorageProgramTransaction.js","sourceRoot":"","sources":["../../../../../src/types/blockchain/TransactionSubtypes/StorageProgramTransaction.ts"],"names":[],"mappings":"AAEA,qFAAqF;AAErF,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACrC,0CAA0C;IAC1C,cAAc,EAAE,OAAO;IAEvB,6CAA6C;IAC7C,mBAAmB,EAAE,KAAK;IAE1B,2BAA2B;IAC3B,aAAa,EAAE,EAAE;IAEjB,8CAA8C;IAC9C,sBAAsB,EAAE,EAAE;CACpB,CAAA;AA0OV,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACpD,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IACzD,MAAM,CAAC,GAAG,OAAkC,CAAA;IAC5C,MAAM,eAAe,GAAG;QACpB,wBAAwB;QACxB,eAAe;QACf,cAAc;QACd,uBAAuB;QACvB,wBAAwB;QACxB,sBAAsB;QACtB,WAAW;QACX,UAAU;QACV,aAAa;QACb,cAAc;QACd,aAAa;KAChB,CAAA;IACD,OAAO,CACH,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ;QAC/B,OAAO,CAAC,CAAC,cAAc,KAAK,QAAQ;QACpC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAmB,CAAC,CAClD,CAAA;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,QAAiB;IAC7C,OAAO,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,QAAQ,CAAA;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAiB;IACpD,OAAO,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,MAAM,CAAA;AACxD,CAAC"}
1
+ {"version":3,"file":"StorageProgramTransaction.js","sourceRoot":"","sources":["../../../../../src/types/blockchain/TransactionSubtypes/StorageProgramTransaction.ts"],"names":[],"mappings":"AAEA,qFAAqF;AAErF,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAElD,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACrC,0CAA0C;IAC1C,cAAc,EAAE,OAAO;IAEvB,6CAA6C;IAC7C,mBAAmB,EAAE,KAAK;IAE1B;;;;OAIG;IACH,aAAa,EAAE,UAAU;IAEzB,8CAA8C;IAC9C,sBAAsB,EAAE,EAAE;CACpB,CAAA;AA0OV,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACpD,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IACzD,MAAM,CAAC,GAAG,OAAkC,CAAA;IAC5C,MAAM,eAAe,GAAG;QACpB,wBAAwB;QACxB,eAAe;QACf,cAAc;QACd,uBAAuB;QACvB,wBAAwB;QACxB,sBAAsB;QACtB,WAAW;QACX,UAAU;QACV,aAAa;QACb,cAAc;QACd,aAAa;KAChB,CAAA;IACD,OAAO,CACH,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ;QAC/B,OAAO,CAAC,CAAC,cAAc,KAAK,QAAQ;QACpC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAmB,CAAC,CAClD,CAAA;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,QAAiB;IAC7C,OAAO,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,QAAQ,CAAA;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAiB;IACpD,OAAO,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,MAAM,CAAA;AACxD,CAAC"}
@@ -1,5 +1,18 @@
1
+ /**
2
+ * Transaction fee container.
3
+ *
4
+ * Wire-format compatibility note: pre-fork wire encodes each field as a JS
5
+ * `number` in DEM. Post-fork wire encodes them as decimal strings in OS
6
+ * (smallest unit, 1 DEM = 10^9 OS). Both shapes are accepted on input; the
7
+ * SDK's `serializerGate` (P4 commit 2) is the wire boundary that picks the
8
+ * correct on-the-wire shape per the connected node's fork status.
9
+ *
10
+ * Internally, fee math is performed in `bigint` OS via `denomination`
11
+ * conversion utilities — never as `number` (which loses precision above
12
+ * 2^53 OS, ~9 million DEM).
13
+ */
1
14
  export interface TxFee {
2
- network_fee: number;
3
- rpc_fee: number;
4
- additional_fee: number;
15
+ network_fee: number | string;
16
+ rpc_fee: number | string;
17
+ additional_fee: number | string;
5
18
  }
@@ -1,3 +1,25 @@
1
+ /**
2
+ * Snapshot of an address's on-chain state.
3
+ *
4
+ * P4: `balance` is `bigint`. The magnitude depends on the connected
5
+ * node's fork status:
6
+ *
7
+ * - **Post-fork**: the node returns balance in **OS** (smallest unit,
8
+ * 1 DEM = 10^9 OS). The SDK passes this through unchanged.
9
+ * - **Pre-fork**: the node returns balance in **DEM**. The SDK passes
10
+ * this through unchanged — it does **not** auto-convert client-side.
11
+ *
12
+ * Consumers that need to do arithmetic in OS regardless of node version
13
+ * should branch on `demos.getNetworkInfo()` (or the internal
14
+ * `_isPostForkCached`) and call `denomination.demToOs(balance)` only
15
+ * on the pre-fork branch. For display, use `denomination.osToDem(balance)`
16
+ * post-fork or treat the value as DEM directly pre-fork.
17
+ *
18
+ * (Earlier drafts of this doc claimed the SDK multiplied pre-fork
19
+ * balances client-side via `osToDem`; that was inaccurate on both
20
+ * counts — `osToDem` divides, and the SDK does not multiply at all.
21
+ * Fixed in PR-86 review.)
22
+ */
1
23
  export interface AddressInfo {
2
24
  pubkey: string;
3
25
  assignedTxs: string[];
@@ -6,5 +28,6 @@ export interface AddressInfo {
6
28
  web2: Map<string, string[]>;
7
29
  };
8
30
  nonce: number;
31
+ /** Address balance, `bigint` in OS (smallest unit). */
9
32
  balance: bigint;
10
33
  }
@@ -1,4 +1,13 @@
1
1
  import { TransactionContent } from "./Transaction";
2
+ /**
3
+ * Raw transaction row as it surfaces from the node's storage layer.
4
+ *
5
+ * Wire-format compatibility note (P4): `amount`, `networkFee`, `rpcFee`, and
6
+ * `additionalFee` may arrive as either JS `number` (pre-fork node, DEM) or
7
+ * decimal `string` (post-fork node, OS). Consumers must coerce via
8
+ * `denomination.parseOsString` / `BigInt(...)` before doing arithmetic;
9
+ * never call raw `Number(...)` once OS-magnitude values are possible.
10
+ */
2
11
  export interface RawTransaction {
3
12
  id: number;
4
13
  blockNumber: number;
@@ -9,12 +18,12 @@ export interface RawTransaction {
9
18
  type: TransactionContent["type"];
10
19
  from: any;
11
20
  to: any;
12
- amount: number;
21
+ amount: number | string;
13
22
  nonce: number;
14
23
  timestamp: number;
15
- networkFee: number;
16
- rpcFee: number;
17
- additionalFee: number;
24
+ networkFee: number | string;
25
+ rpcFee: number | string;
26
+ additionalFee: number | string;
18
27
  ed25519_signature: string;
19
28
  from_ed25519_address: string;
20
29
  }
@@ -1,6 +1,14 @@
1
+ /**
2
+ * Native chain status snapshot for an address.
3
+ *
4
+ * Wire-format compatibility (P4): `balance` may arrive as a JS `number`
5
+ * (pre-fork node, DEM) or a decimal `string` (post-fork node, OS).
6
+ * Consumers should normalise via `BigInt(...)` to OS internally before
7
+ * arithmetic. Direct `Number(balance)` truncates above 2^53.
8
+ */
1
9
  export interface StatusNative {
2
10
  address: string;
3
- balance: number;
11
+ balance: number | string;
4
12
  nonce: number;
5
13
  tx_list: string;
6
14
  }
@@ -1,7 +1,7 @@
1
1
  export interface BridgeTradePayload {
2
2
  fromToken: "NATIVE" | "USDC" | "USDT";
3
3
  toToken: "NATIVE" | "USDC" | "USDT";
4
- amount: number;
4
+ amount: number | string;
5
5
  fromChainId: number;
6
6
  toChainId: number;
7
7
  }
@@ -1,17 +1,43 @@
1
1
  import forge from "node-forge";
2
+ /**
3
+ * Indexer-style state change record. Wire-format compatibility (P4):
4
+ * `nativeAmount`, `TokenTransfer.amount`, and `NFTTransfer.amount` may
5
+ * arrive as JS `number` (pre-fork DEM) or decimal `string` (post-fork OS).
6
+ *
7
+ * Consumers should normalise via the denomination helpers, **not**
8
+ * `BigInt(...)`, because:
9
+ *
10
+ * - `BigInt(numberWithFractional)` throws `RangeError`.
11
+ * - `BigInt("non-numeric")` throws `SyntaxError`.
12
+ * - `BigInt(...)` does not validate decimal-string OS canonicality —
13
+ * indexer responses can arrive with whitespace, leading zeros, or
14
+ * signed-integer notation.
15
+ *
16
+ * Recommended:
17
+ *
18
+ * - `denomination.parseOsString(value)` for OS decimal-string inputs
19
+ * (post-fork wire). Strips noise and validates the integer shape.
20
+ * - `denomination.demToOs(value)` for DEM `number` inputs (pre-fork
21
+ * wire). Validates and converts to OS bigint.
22
+ *
23
+ * Branch on the source's known fork status (e.g. via
24
+ * `demos.getNetworkInfo()`), not on `typeof value` — the literal `"5"`
25
+ * could be either a pre-fork DEM string or a post-fork OS string,
26
+ * which differ by a factor of 10^9.
27
+ */
2
28
  interface TokenTransfer {
3
29
  address: string;
4
- amount: number;
30
+ amount: number | string;
5
31
  }
6
32
  interface NFTTransfer {
7
33
  address: string;
8
34
  tokenId: string;
9
- amount: number;
35
+ amount: number | string;
10
36
  }
11
37
  export interface StateChange {
12
38
  sender: forge.pki.ed25519.BinaryBuffer;
13
39
  receiver: forge.pki.ed25519.BinaryBuffer;
14
- nativeAmount: number;
40
+ nativeAmount: number | string;
15
41
  tx_hash: string;
16
42
  token: TokenTransfer;
17
43
  nft: NFTTransfer;
@@ -1,6 +1,11 @@
1
1
  interface INativeSend {
2
2
  nativeOperation: "send";
3
- args: [string, number];
3
+ /**
4
+ * `[to, amount]`. P4 dual-shape: `amount` may be a JS `number` (pre-fork
5
+ * DEM) or decimal `string` (post-fork OS). Internal arithmetic uses
6
+ * `bigint` OS via `denomination` utilities.
7
+ */
8
+ args: [string, number | string];
4
9
  }
5
10
  interface INativeTlsnRequest {
6
11
  nativeOperation: "tlsn_request";
@@ -21,7 +21,33 @@ export default class Wallet {
21
21
  load(filename: string): Promise<void>;
22
22
  save(filename: string): Promise<void>;
23
23
  getBalance(): Promise<void>;
24
- transfer(to: Address, amount: number, demos: websdk.Demos): Promise<RPCResponseWithValidityData>;
24
+ /**
25
+ * Transfer native DEM tokens to a recipient address.
26
+ *
27
+ * P4 dual-input:
28
+ * - `bigint` (preferred, post-v3): OS amount. 1 DEM = 10^9 OS.
29
+ * - `number` (deprecated, v2 callers): DEM amount, auto-converted.
30
+ *
31
+ * Internal carrier is OS bigint; the serializerGate (run from
32
+ * `demos.sign`) chooses pre-fork vs post-fork wire encoding from
33
+ * the cached `getNetworkInfo` fork status. Sub-DEM precision
34
+ * against a pre-fork node throws `SubDemPrecisionError` from
35
+ * `demos.pay` before any tx construction happens — we delegate to
36
+ * `demos.pay` which carries the guard.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * import { denomination, websdk, wallet } from "@kynesyslabs/demosdk"
41
+ * const w = wallet.default.getInstance("alice")
42
+ * await w.transfer("0x...", denomination.demToOs(100), demos)
43
+ * await w.transfer("0x...", 100_000_000_000n, demos) // raw OS
44
+ * ```
45
+ *
46
+ * @param to - Recipient address (0x-prefixed hex).
47
+ * @param amount - DEM `number` (legacy) or OS `bigint`.
48
+ * @param demos - Demos client used to sign and submit.
49
+ */
50
+ transfer(to: Address, amount: number | bigint, demos: websdk.Demos): Promise<RPCResponseWithValidityData>;
25
51
  broadcast(validityData: RPCResponseWithValidityData, demos: websdk.Demos): Promise<any>;
26
52
  generatePasskey(): Promise<string>;
27
53
  }
@@ -1,6 +1,5 @@
1
1
  // TODO & REVIEW See if the fs methods are useful in this context or nah (also the public ip)
2
2
  import * as websdk from "../websdk/index.js";
3
- import { DemosTransactions } from "../websdk/index.js";
4
3
  import { PasskeyGenerator } from "./passkeys/passkeys.js";
5
4
  import { Cryptography } from "../encryption/Cryptography.js";
6
5
  class Wallet {
@@ -49,23 +48,37 @@ class Wallet {
49
48
  }
50
49
  /* SECTION Basic writes */
51
50
  // NOTE All the writes return a validity object that needs to be confirmed and broadcasted
51
+ /**
52
+ * Transfer native DEM tokens to a recipient address.
53
+ *
54
+ * P4 dual-input:
55
+ * - `bigint` (preferred, post-v3): OS amount. 1 DEM = 10^9 OS.
56
+ * - `number` (deprecated, v2 callers): DEM amount, auto-converted.
57
+ *
58
+ * Internal carrier is OS bigint; the serializerGate (run from
59
+ * `demos.sign`) chooses pre-fork vs post-fork wire encoding from
60
+ * the cached `getNetworkInfo` fork status. Sub-DEM precision
61
+ * against a pre-fork node throws `SubDemPrecisionError` from
62
+ * `demos.pay` before any tx construction happens — we delegate to
63
+ * `demos.pay` which carries the guard.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * import { denomination, websdk, wallet } from "@kynesyslabs/demosdk"
68
+ * const w = wallet.default.getInstance("alice")
69
+ * await w.transfer("0x...", denomination.demToOs(100), demos)
70
+ * await w.transfer("0x...", 100_000_000_000n, demos) // raw OS
71
+ * ```
72
+ *
73
+ * @param to - Recipient address (0x-prefixed hex).
74
+ * @param amount - DEM `number` (legacy) or OS `bigint`.
75
+ * @param demos - Demos client used to sign and submit.
76
+ */
52
77
  async transfer(to, amount, demos) {
53
- let tx = DemosTransactions.empty();
54
- // Putting the right data in the transaction
55
- // tx.content.from = keypair.publicKey.toString("hex")
56
- tx.content.from = demos.keypair.publicKey.toString("hex");
57
- // tx.content.to = to
58
- tx.content.type = "native";
59
- tx.content.data = [
60
- "native",
61
- {
62
- nativeOperation: "send",
63
- args: [to, amount],
64
- },
65
- ];
66
- // tx.content.amount = amount
67
- tx = await demos.sign(tx);
68
- // Sending the transaction and getting the validity data
78
+ // Delegate to demos.pay so we get the sub-DEM guard, the
79
+ // serializerGate, and the canonical native-send tx shape (with
80
+ // nonce, timestamp, gcr_edits, fee derivation) for free.
81
+ const tx = await demos.pay(to, amount);
69
82
  return await demos.confirm(tx);
70
83
  }
71
84
  // TODO Implement other methods too
@@ -1 +1 @@
1
- {"version":3,"file":"Wallet.js","sourceRoot":"","sources":["../../../src/wallet/Wallet.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAI7F,OAAO,KAAK,MAAM,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAIxD,MAAqB,MAAM;IAgBvB;Q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CACV,EAAW,EACX,MAAuB,EACvB,KAAmB;QAEnB,yDAAyD;QACzD,+DAA+D;QAC/D,yDAAyD;QACzD,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;QACtC,OAAO,MAAM,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAClC,CAAC;IAED,mCAAmC;IAEnC,2FAA2F;IAC3F,KAAK,CAAC,SAAS,CACX,YAAyC,EACzC,KAAmB;QAEnB,OAAO,MAAM,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,CAAA;IAC9C,CAAC;IAED,0BAA0B;IAC1B,KAAK,CAAC,eAAe;QACjB,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAA;QAC/C,OAAO,MAAM,gBAAgB,CAAC,QAAQ,EAAE,CAAA;IAC5C,CAAC;;AA1HD,yGAAyG;AAC1F,gBAAS,GAA8B,EAAE,CAAA;eAFvC,MAAM"}
@@ -9,23 +9,49 @@ export declare const DemosTransactions: {
9
9
  /**
10
10
  * Create a signed DEMOS transaction to send native tokens to a given address.
11
11
  *
12
+ * P4 dual-input:
13
+ * - `bigint`: OS amount (preferred — 1 DEM = 10^9 OS).
14
+ * - `number`: DEM amount (legacy, deprecated). Auto-converted to OS.
15
+ *
16
+ * Internal carrier in `tx.content.amount` is bigint OS; the
17
+ * serializerGate (run from `demos.sign`) emits the right wire shape
18
+ * per the connected node's fork status.
19
+ *
12
20
  * @param to - The reciever
13
- * @param amount - The amount in DEM
21
+ * @param amount - DEM `number` (legacy) or OS `bigint`.
14
22
  * @param demos - The demos instance (for getting the address nonce)
15
23
  *
16
24
  * @returns The signed transaction.
17
25
  */
18
- pay(to: string, amount: number, demos: Demos): Promise<Transaction>;
26
+ pay(to: string, amount: number | bigint, demos: Demos): Promise<Transaction>;
27
+ /**
28
+ * Convert a legacy DEM `number` input to an OS `bigint` for internal
29
+ * carrying. Only whole-DEM `number` inputs are accepted on this
30
+ * legacy path — fractional DEM is rejected with a clear error
31
+ * directing callers to the bigint OS path (`denomination.demToOs`).
32
+ *
33
+ * Rationale: silently flooring (the previous behaviour) discarded up
34
+ * to ~10^9 OS per call without warning. The migration period
35
+ * tolerates legacy `number` callers, but only at exact DEM
36
+ * granularity — anything sub-DEM must come in as `bigint` so the
37
+ * caller has explicitly opted into OS arithmetic.
38
+ *
39
+ * @internal
40
+ */
41
+ _demNumberToOsBigint(amountDem: number): bigint;
19
42
  /**
20
43
  * Create a signed DEMOS transaction to send native tokens to a given address.
21
44
  *
45
+ * Alias of {@link pay}. Same dual-input semantics — `bigint` OS
46
+ * preferred, `number` DEM accepted as the deprecated path.
47
+ *
22
48
  * @param to - The reciever
23
- * @param amount - The amount in DEM
49
+ * @param amount - DEM `number` (legacy) or OS `bigint`.
24
50
  * @param demos - The demos instance (for getting the address nonce)
25
51
  *
26
52
  * @returns The signed transaction.
27
53
  */
28
- transfer(to: string, amount: number, demos: Demos): Promise<Transaction>;
54
+ transfer(to: string, amount: number | bigint, demos: Demos): Promise<Transaction>;
29
55
  /**
30
56
  * Signs a transaction after hashing its content.
31
57
  *