@kynesyslabs/demosdk 2.12.2 → 4.0.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 (81) hide show
  1. package/build/bridge/nativeBridge.js +1 -0
  2. package/build/bridge/nativeBridge.js.map +1 -1
  3. package/build/bridge/nativeBridgeTypes.d.ts +4 -3
  4. package/build/bridge/nativeBridgeTypes.js.map +1 -1
  5. package/build/d402/client/types.d.ts +6 -3
  6. package/build/d402/server/D402Server.d.ts +25 -0
  7. package/build/d402/server/D402Server.js +63 -2
  8. package/build/d402/server/D402Server.js.map +1 -1
  9. package/build/d402/server/middleware.d.ts +7 -4
  10. package/build/d402/server/middleware.js.map +1 -1
  11. package/build/d402/server/types.d.ts +15 -7
  12. package/build/denomination/conversion.test.js +1 -1
  13. package/build/denomination/conversion.test.js.map +1 -1
  14. package/build/denomination/index.d.ts +3 -0
  15. package/build/denomination/index.js +6 -0
  16. package/build/denomination/index.js.map +1 -1
  17. package/build/denomination/networkInfo.d.ts +69 -0
  18. package/build/denomination/networkInfo.js +38 -0
  19. package/build/denomination/networkInfo.js.map +1 -0
  20. package/build/denomination/networkInfo.test.d.ts +1 -0
  21. package/build/denomination/networkInfo.test.js +28 -0
  22. package/build/denomination/networkInfo.test.js.map +1 -0
  23. package/build/denomination/roundTripHash.test.d.ts +1 -0
  24. package/build/denomination/roundTripHash.test.js +231 -0
  25. package/build/denomination/roundTripHash.test.js.map +1 -0
  26. package/build/denomination/serializerGate.d.ts +46 -0
  27. package/build/denomination/serializerGate.js +283 -0
  28. package/build/denomination/serializerGate.js.map +1 -0
  29. package/build/denomination/serializerGate.test.d.ts +1 -0
  30. package/build/denomination/serializerGate.test.js +255 -0
  31. package/build/denomination/serializerGate.test.js.map +1 -0
  32. package/build/escrow/EscrowTransaction.d.ts +36 -5
  33. package/build/escrow/EscrowTransaction.js +91 -10
  34. package/build/escrow/EscrowTransaction.js.map +1 -1
  35. package/build/ipfs/IPFSOperations.d.ts +37 -10
  36. package/build/ipfs/IPFSOperations.js +38 -8
  37. package/build/ipfs/IPFSOperations.js.map +1 -1
  38. package/build/storage/StorageProgram.d.ts +16 -8
  39. package/build/storage/StorageProgram.js +16 -8
  40. package/build/storage/StorageProgram.js.map +1 -1
  41. package/build/tlsnotary/TLSNotaryService.d.ts +19 -8
  42. package/build/tlsnotary/TLSNotaryService.js +22 -7
  43. package/build/tlsnotary/TLSNotaryService.js.map +1 -1
  44. package/build/tlsnotary/helpers.d.ts +11 -5
  45. package/build/tlsnotary/helpers.js +17 -5
  46. package/build/tlsnotary/helpers.js.map +1 -1
  47. package/build/types/blockchain/CustomCharges.d.ts +28 -16
  48. package/build/types/blockchain/CustomCharges.js +15 -5
  49. package/build/types/blockchain/CustomCharges.js.map +1 -1
  50. package/build/types/blockchain/GCREdit.d.ts +26 -2
  51. package/build/types/blockchain/NetworkParameters.d.ts +33 -0
  52. package/build/types/blockchain/Transaction.d.ts +14 -1
  53. package/build/types/blockchain/Transaction.js.map +1 -1
  54. package/build/types/blockchain/TransactionSubtypes/D402PaymentTransaction.d.ts +8 -3
  55. package/build/types/blockchain/TransactionSubtypes/StorageProgramTransaction.d.ts +6 -5
  56. package/build/types/blockchain/TransactionSubtypes/StorageProgramTransaction.js +15 -3
  57. package/build/types/blockchain/TransactionSubtypes/StorageProgramTransaction.js.map +1 -1
  58. package/build/types/blockchain/TxFee.d.ts +33 -3
  59. package/build/types/blockchain/address.d.ts +23 -0
  60. package/build/types/blockchain/rawTransaction.d.ts +20 -4
  61. package/build/types/blockchain/statusNative.d.ts +9 -1
  62. package/build/types/bridge/bridgeTradePayload.d.ts +1 -1
  63. package/build/types/gls/StateChange.d.ts +29 -3
  64. package/build/types/native/INativePayload.d.ts +6 -1
  65. package/build/wallet/Wallet.d.ts +27 -1
  66. package/build/wallet/Wallet.js +30 -17
  67. package/build/wallet/Wallet.js.map +1 -1
  68. package/build/websdk/DemosTokens.js +2 -0
  69. package/build/websdk/DemosTokens.js.map +1 -1
  70. package/build/websdk/DemosTransactions.d.ts +30 -4
  71. package/build/websdk/DemosTransactions.js +88 -9
  72. package/build/websdk/DemosTransactions.js.map +1 -1
  73. package/build/websdk/GCRGeneration.d.ts +10 -2
  74. package/build/websdk/GCRGeneration.js +30 -14
  75. package/build/websdk/GCRGeneration.js.map +1 -1
  76. package/build/websdk/demosclass.d.ts +152 -23
  77. package/build/websdk/demosclass.js +308 -38
  78. package/build/websdk/demosclass.js.map +1 -1
  79. package/build/websdk/utils/skeletons.js +1 -0
  80. package/build/websdk/utils/skeletons.js.map +1 -1
  81. package/package.json +1 -1
@@ -0,0 +1,255 @@
1
+ import { describe, test, expect } from "@jest/globals";
2
+ import { serializeTransactionContent } from "./serializerGate.js";
3
+ // REVIEW: P4 commit 2 — load-bearing wire boundary. Tests assert byte
4
+ // identity for the pre-fork branch (must equal legacy `JSON.stringify`)
5
+ // and the canonical post-fork shape (`amount`, `transaction_fee.*`, and
6
+ // targeted `gcr_edits[].amount` carriers as OS strings; key order
7
+ // preserved).
8
+ /**
9
+ * Build a `TransactionContent` fixture in the canonical key order, with
10
+ * a mix of `gcr_edits` entries to exercise the per-variant transformer.
11
+ */
12
+ function buildFixture() {
13
+ const gcr_edits = [
14
+ {
15
+ type: "balance",
16
+ isRollback: false,
17
+ operation: "remove",
18
+ account: "0xsender",
19
+ amount: 100, // legacy DEM number
20
+ txhash: "",
21
+ },
22
+ {
23
+ type: "nonce",
24
+ isRollback: false,
25
+ operation: "add",
26
+ account: "0xsender",
27
+ amount: 1,
28
+ txhash: "",
29
+ },
30
+ {
31
+ type: "balance",
32
+ isRollback: false,
33
+ operation: "add",
34
+ account: "0xreceiver",
35
+ amount: 100,
36
+ txhash: "",
37
+ },
38
+ {
39
+ type: "escrow",
40
+ operation: "deposit",
41
+ account: "0xescrow",
42
+ data: {
43
+ sender: "0xsender",
44
+ platform: "twitter",
45
+ username: "@bob",
46
+ amount: 100, // legacy DEM number — should become OS string post-fork
47
+ expiryDays: 30,
48
+ },
49
+ txhash: "",
50
+ isRollback: false,
51
+ },
52
+ ];
53
+ const content = {
54
+ type: "native",
55
+ from: "0xsender",
56
+ to: "0xreceiver",
57
+ amount: 100, // legacy DEM
58
+ data: [
59
+ "native",
60
+ {
61
+ nativeOperation: "send",
62
+ args: ["0xreceiver", 100],
63
+ },
64
+ ],
65
+ nonce: 1,
66
+ timestamp: 1700000000000,
67
+ transaction_fee: {
68
+ network_fee: 1,
69
+ rpc_fee: 0,
70
+ additional_fee: 0,
71
+ rpc_address: null,
72
+ },
73
+ from_ed25519_address: "0xsender",
74
+ gcr_edits,
75
+ };
76
+ return content;
77
+ }
78
+ describe("serializerGate — pre-fork branch", () => {
79
+ test("output is byte-identical to legacy JSON.stringify for current SDK content", () => {
80
+ const content = buildFixture();
81
+ const expected = JSON.stringify(content);
82
+ expect(serializeTransactionContent(content, false)).toBe(expected);
83
+ });
84
+ test("normalises stray bigint amount back to legacy DEM number", () => {
85
+ const content = buildFixture();
86
+ // Simulate an internal bigint OS amount leaking into content.
87
+ // 100 DEM = 100_000_000_000n OS.
88
+ content.amount = 100000000000n;
89
+ const out = serializeTransactionContent(content, false);
90
+ const parsed = JSON.parse(out);
91
+ expect(parsed.amount).toBe(100);
92
+ });
93
+ test("normalises stray OS-string amount back to DEM number", () => {
94
+ const content = buildFixture();
95
+ content.amount = "100000000000";
96
+ const out = serializeTransactionContent(content, false);
97
+ const parsed = JSON.parse(out);
98
+ expect(parsed.amount).toBe(100);
99
+ });
100
+ test("normalises bigint balance edit back to DEM number", () => {
101
+ const content = buildFixture();
102
+ content.gcr_edits[0].amount = 100000000000n;
103
+ const out = serializeTransactionContent(content, false);
104
+ const parsed = JSON.parse(out);
105
+ expect(parsed.gcr_edits[0].amount).toBe(100);
106
+ });
107
+ });
108
+ describe("serializerGate — post-fork branch", () => {
109
+ test("amount becomes OS string", () => {
110
+ const content = buildFixture();
111
+ const out = serializeTransactionContent(content, true);
112
+ const parsed = JSON.parse(out);
113
+ expect(parsed.amount).toBe("100000000000");
114
+ });
115
+ test("transaction_fee fields all become OS strings", () => {
116
+ const content = buildFixture();
117
+ const out = serializeTransactionContent(content, true);
118
+ const parsed = JSON.parse(out);
119
+ expect(parsed.transaction_fee.network_fee).toBe("1000000000");
120
+ expect(parsed.transaction_fee.rpc_fee).toBe("0");
121
+ expect(parsed.transaction_fee.additional_fee).toBe("0");
122
+ });
123
+ test("gcr_edits balance amounts become OS strings; nonce stays a number", () => {
124
+ const content = buildFixture();
125
+ const out = serializeTransactionContent(content, true);
126
+ const parsed = JSON.parse(out);
127
+ expect(parsed.gcr_edits[0].amount).toBe("100000000000");
128
+ expect(parsed.gcr_edits[1].amount).toBe(1); // nonce — counter, untouched
129
+ expect(parsed.gcr_edits[2].amount).toBe("100000000000");
130
+ });
131
+ test("escrow nested amount becomes OS string", () => {
132
+ const content = buildFixture();
133
+ const out = serializeTransactionContent(content, true);
134
+ const parsed = JSON.parse(out);
135
+ expect(parsed.gcr_edits[3].data.amount).toBe("100000000000");
136
+ });
137
+ test("post-fork output preserves canonical top-level key order", () => {
138
+ const content = buildFixture();
139
+ const out = serializeTransactionContent(content, true);
140
+ const parsed = JSON.parse(out);
141
+ // Canonical order from SPEC_P4 §3.5.
142
+ expect(Object.keys(parsed)).toEqual([
143
+ "type",
144
+ "from",
145
+ "to",
146
+ "amount",
147
+ "data",
148
+ "nonce",
149
+ "timestamp",
150
+ "transaction_fee",
151
+ "from_ed25519_address",
152
+ "gcr_edits",
153
+ ]);
154
+ });
155
+ test("post-fork output preserves transaction_fee key order", () => {
156
+ const content = buildFixture();
157
+ const out = serializeTransactionContent(content, true);
158
+ const parsed = JSON.parse(out);
159
+ // DEM-665: rpc_address is now part of the canonical TxFee shape;
160
+ // buildFixture writes it after additional_fee.
161
+ expect(Object.keys(parsed.transaction_fee)).toEqual([
162
+ "network_fee",
163
+ "rpc_fee",
164
+ "additional_fee",
165
+ "rpc_address",
166
+ ]);
167
+ });
168
+ test("non-canonical OS string is normalised", () => {
169
+ const content = buildFixture();
170
+ // "00100" must become "100" after re-emit.
171
+ content.amount = "00100";
172
+ const out = serializeTransactionContent(content, true);
173
+ const parsed = JSON.parse(out);
174
+ expect(parsed.amount).toBe("100");
175
+ });
176
+ test("bigint amount round-trips through the wire", () => {
177
+ const content = buildFixture();
178
+ content.amount = 1500000000n;
179
+ const out = serializeTransactionContent(content, true);
180
+ const parsed = JSON.parse(out);
181
+ expect(parsed.amount).toBe("1500000000");
182
+ });
183
+ test("sub-DEM precision preserved via OS string", () => {
184
+ const content = buildFixture();
185
+ // 0.000000001 DEM = 1n OS.
186
+ content.amount = 1n;
187
+ const out = serializeTransactionContent(content, true);
188
+ const parsed = JSON.parse(out);
189
+ expect(parsed.amount).toBe("1");
190
+ });
191
+ });
192
+ describe("serializerGate — input invariance", () => {
193
+ test("does not mutate the input content object", () => {
194
+ const content = buildFixture();
195
+ const before = JSON.stringify(content);
196
+ serializeTransactionContent(content, true);
197
+ expect(JSON.stringify(content)).toBe(before);
198
+ });
199
+ });
200
+ describe("serializerGate — transaction_fee key order (myc#19)", () => {
201
+ test("post-fork preserves non-canonical fee insertion order", () => {
202
+ const content = buildFixture();
203
+ // Construct fee with `additional_fee` first to break the old
204
+ // hard-coded literal order. DEM-665: rpc_address joins the
205
+ // ordered key set and must round-trip in its declared position.
206
+ content.transaction_fee = {
207
+ additional_fee: 0,
208
+ rpc_address: null,
209
+ rpc_fee: 0,
210
+ network_fee: 1,
211
+ };
212
+ const out = serializeTransactionContent(content, true);
213
+ const parsed = JSON.parse(out);
214
+ expect(Object.keys(parsed.transaction_fee)).toEqual([
215
+ "additional_fee",
216
+ "rpc_address",
217
+ "rpc_fee",
218
+ "network_fee",
219
+ ]);
220
+ });
221
+ test("pre-fork preserves non-canonical fee insertion order", () => {
222
+ const content = buildFixture();
223
+ content.transaction_fee = {
224
+ additional_fee: 0,
225
+ rpc_address: null,
226
+ rpc_fee: 0,
227
+ network_fee: 1,
228
+ };
229
+ const out = serializeTransactionContent(content, false);
230
+ const parsed = JSON.parse(out);
231
+ expect(Object.keys(parsed.transaction_fee)).toEqual([
232
+ "additional_fee",
233
+ "rpc_address",
234
+ "rpc_fee",
235
+ "network_fee",
236
+ ]);
237
+ });
238
+ test("post-fork passes through unknown extra fee fields verbatim", () => {
239
+ const content = buildFixture();
240
+ content.transaction_fee = {
241
+ network_fee: 1,
242
+ rpc_fee: 0,
243
+ additional_fee: 0,
244
+ rpc_address: null,
245
+ // Future extension field the SDK doesn't know about — must
246
+ // not be dropped (consensus would diverge if the node knows
247
+ // it and we strip it).
248
+ future_field: "abc",
249
+ };
250
+ const out = serializeTransactionContent(content, true);
251
+ const parsed = JSON.parse(out);
252
+ expect(parsed.transaction_fee.future_field).toBe("abc");
253
+ });
254
+ });
255
+ //# sourceMappingURL=serializerGate.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializerGate.test.js","sourceRoot":"","sources":["../../../src/denomination/serializerGate.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAA;AAI9D,sEAAsE;AACtE,wEAAwE;AACxE,wEAAwE;AACxE,kEAAkE;AAClE,cAAc;AAEd;;;GAGG;AACH,SAAS,YAAY;IACjB,MAAM,SAAS,GAAc;QACzB;YACI,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,KAAK;YACjB,SAAS,EAAE,QAAQ;YACnB,OAAO,EAAE,UAAU;YACnB,MAAM,EAAE,GAAG,EAAE,oBAAoB;YACjC,MAAM,EAAE,EAAE;SACb;QACD;YACI,IAAI,EAAE,OAAO;YACb,UAAU,EAAE,KAAK;YACjB,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,UAAU;YACnB,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,EAAE;SACb;QACD;YACI,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,KAAK;YAC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ACN,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC9D,MAAM,OAAO,GAAG,YAAY,EAAE,CAAA;QAC9B,OAAO,CAAC,eAAe,GAAG;YACtB,cAAc,EAAE,CAAC;YACjB,WAAW,EAAE,IAAI;YACjB,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,CAAC;SACV,CAAA;QACR,MAAM,GAAG,GAAG,2BAA2B,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QACvD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC9B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC;YAChD,gBAAgB;YAChB,aAAa;YACb,SAAS;YACT,aAAa;SAChB,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,MAAM,OAAO,GAAG,YAAY,EAAE,CAAA;QAC9B,OAAO,CAAC,eAAe,GAAG;YACtB,WAAW,EAAE,CAAC;YACd,OAAO,EAAE,CAAC;YACV,cAAc,EAAE,CAAC;YACjB,WAAW,EAAE,IAAI;YACjB,2DAA2D;YAC3D,4DAA4D;YAC5D,uBAAuB;YACvB,YAAY,EAAE,KAAK;SACf,CAAA;QACR,MAAM,GAAG,GAAG,2BAA2B,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QACtD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC9B,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC3D,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
@@ -15,31 +15,62 @@ export declare class EscrowTransaction {
15
15
  */
16
16
  static getEscrowAddress(platform: string, username: string): string;
17
17
  /**
18
- * Creates a transaction to send DEM to a social identity escrow
18
+ * Creates a transaction to send DEM to a social identity escrow.
19
+ *
20
+ * P4 dual-input:
21
+ * - `bigint` (preferred, post-v3): OS amount.
22
+ * - `number` (deprecated, v2 callers): DEM amount, auto-converted.
23
+ *
24
+ * Internal carrier in `tx.content.amount` and `gcr_edits[].amount`
25
+ * is bigint OS; the serializerGate (called from `demos.sign`)
26
+ * picks the wire shape per fork status. Sub-DEM precision against
27
+ * a pre-fork node throws `SubDemPrecisionError`.
19
28
  *
20
29
  * @example
21
30
  * ```typescript
31
+ * import { denomination } from "@kynesyslabs/demosdk"
22
32
  * const tx = await EscrowTransaction.sendToIdentity(
23
33
  * demos,
24
34
  * "twitter",
25
35
  * "@bob",
26
- * 100,
36
+ * denomination.demToOs(100), // 100 DEM
27
37
  * { expiryDays: 30, message: "Welcome to Demos!" }
28
38
  * )
29
- * await demos.submitTransaction(tx)
39
+ * await demos.confirm(tx)
30
40
  * ```
31
41
  *
32
42
  * @param demos - Demos SDK instance (must have keypair set)
33
43
  * @param platform - Social platform ("twitter", "github", "telegram")
34
44
  * @param username - Username on that platform
35
- * @param amount - Amount of DEM to send (number)
45
+ * @param amount - DEM `number` (legacy) or OS `bigint` (preferred).
36
46
  * @param options - Optional parameters
37
47
  * @returns Signed transaction ready to submit
38
48
  */
39
- static sendToIdentity(demos: Demos, platform: "twitter" | "github" | "telegram", username: string, amount: number, options?: {
49
+ static sendToIdentity(demos: Demos, platform: "twitter" | "github" | "telegram", username: string, amount: number | bigint, options?: {
40
50
  expiryDays?: number;
41
51
  message?: string;
42
52
  }): Promise<Transaction>;
53
+ /**
54
+ * Normalise a public-API amount input (`number` legacy DEM or
55
+ * `bigint` OS) into both forms. Used at every boundary that needs
56
+ * dual-shape support during the pre-/post-fork rollout.
57
+ *
58
+ * - `number` input: must be a non-negative integer DEM amount;
59
+ * converted to OS via `OS_PER_DEM`. Fractional DEM `number` is
60
+ * rejected — silently flooring (the previous behaviour) discarded
61
+ * up to ~10^9 OS per call. Callers who need sub-DEM precision
62
+ * must pass a `bigint` OS amount (e.g. `denomination.demToOs("1.5")`).
63
+ * - `bigint` input: treated as OS; DEM form is the integer division
64
+ * `amountOs / OS_PER_DEM`. The pre-fork sub-DEM precision rejection
65
+ * lives in `Demos._assertAmountAcceptableOnTargetNode` (called by
66
+ * `sendToIdentity` before this helper runs).
67
+ *
68
+ * @internal Exposed only to keep the migration paths discoverable.
69
+ */
70
+ static normalizeAmountInput(amount: number | bigint): {
71
+ amountDem: number;
72
+ amountOs: bigint;
73
+ };
43
74
  /**
44
75
  * Creates a transaction to claim escrowed funds
45
76
  *
@@ -11,6 +11,7 @@ KyneSys Labs: https://www.kynesys.xyz/
11
11
  import { Hashing } from "../encryption/Hashing.js";
12
12
  import { uint8ArrayToHex } from "../encryption/unifiedCrypto.js";
13
13
  import * as skeletons from "../websdk/utils/skeletons.js";
14
+ import { OS_PER_DEM } from "../denomination/index.js";
14
15
  /**
15
16
  * High-level API for creating escrow transactions
16
17
  * Enables trustless sending of DEM to unclaimed social identities
@@ -31,28 +32,51 @@ export class EscrowTransaction {
31
32
  return Hashing.sha3_256(identity);
32
33
  }
33
34
  /**
34
- * Creates a transaction to send DEM to a social identity escrow
35
+ * Creates a transaction to send DEM to a social identity escrow.
36
+ *
37
+ * P4 dual-input:
38
+ * - `bigint` (preferred, post-v3): OS amount.
39
+ * - `number` (deprecated, v2 callers): DEM amount, auto-converted.
40
+ *
41
+ * Internal carrier in `tx.content.amount` and `gcr_edits[].amount`
42
+ * is bigint OS; the serializerGate (called from `demos.sign`)
43
+ * picks the wire shape per fork status. Sub-DEM precision against
44
+ * a pre-fork node throws `SubDemPrecisionError`.
35
45
  *
36
46
  * @example
37
47
  * ```typescript
48
+ * import { denomination } from "@kynesyslabs/demosdk"
38
49
  * const tx = await EscrowTransaction.sendToIdentity(
39
50
  * demos,
40
51
  * "twitter",
41
52
  * "@bob",
42
- * 100,
53
+ * denomination.demToOs(100), // 100 DEM
43
54
  * { expiryDays: 30, message: "Welcome to Demos!" }
44
55
  * )
45
- * await demos.submitTransaction(tx)
56
+ * await demos.confirm(tx)
46
57
  * ```
47
58
  *
48
59
  * @param demos - Demos SDK instance (must have keypair set)
49
60
  * @param platform - Social platform ("twitter", "github", "telegram")
50
61
  * @param username - Username on that platform
51
- * @param amount - Amount of DEM to send (number)
62
+ * @param amount - DEM `number` (legacy) or OS `bigint` (preferred).
52
63
  * @param options - Optional parameters
53
64
  * @returns Signed transaction ready to submit
54
65
  */
55
66
  static async sendToIdentity(demos, platform, username, amount, options) {
67
+ // P4 commit 3: bigint OS is the canonical internal carrier; the
68
+ // serializerGate (run via demos.sign) emits the right wire shape
69
+ // per the connected node's fork status.
70
+ const { amountOs } = EscrowTransaction.normalizeAmountInput(amount);
71
+ // Sub-DEM precision guard — runs before tx construction so the
72
+ // caller never produces a tx that a pre-fork node will silently
73
+ // truncate. Calls into the cached `getNetworkInfo` fork status.
74
+ // The helper is `private` on Demos but reachable at runtime;
75
+ // cast through `any` to bypass the access modifier (escrow is
76
+ // package-internal — the alternative is to widen Demos's
77
+ // public surface, which we don't want).
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
+ await demos._assertAmountAcceptableOnTargetNode(amountOs);
56
80
  // Get sender address from demos instance
57
81
  const { publicKey } = await demos.crypto.getIdentity("ed25519");
58
82
  const sender = uint8ArrayToHex(publicKey);
@@ -62,14 +86,25 @@ export class EscrowTransaction {
62
86
  const nonce = await demos.getAddressNonce(sender);
63
87
  // Create empty transaction
64
88
  let tx = structuredClone(skeletons.transaction);
65
- // Build GCREdits
89
+ // Build GCREdits. NOTE: `demos.sign()` calls `GCRGeneration.generate`
90
+ // which currently overwrites `gcr_edits` with edits derived from
91
+ // the tx content; the inline edits here are dead code today
92
+ // (flagged in SPEC_P4 §2.1). Kept type-correct so they still
93
+ // match the (now-widened) `GCREditBalance.amount` type if/when
94
+ // the dead-code path is wired up.
95
+ //
96
+ // P4 commit 3: edits carry bigint OS internally. The
97
+ // serializerGate normalises them to the right wire shape per
98
+ // fork status. The `GCREditBalance.amount` static type is
99
+ // `number | string`; bigints are passed through `unknown` to
100
+ // satisfy TS — the runtime serializer handles all three shapes.
66
101
  const gcrEdits = [
67
102
  // 1. Deduct from sender's balance
68
103
  {
69
104
  type: "balance",
70
105
  operation: "remove",
71
106
  account: sender,
72
- amount: amount,
107
+ amount: amountOs,
73
108
  txhash: "",
74
109
  isRollback: false,
75
110
  },
@@ -82,7 +117,7 @@ export class EscrowTransaction {
82
117
  sender,
83
118
  platform,
84
119
  username,
85
- amount: amount,
120
+ amount: amountOs,
86
121
  expiryDays: options?.expiryDays || 30,
87
122
  message: options?.message,
88
123
  },
@@ -90,11 +125,13 @@ export class EscrowTransaction {
90
125
  isRollback: false,
91
126
  },
92
127
  ];
93
- // Fill transaction content
128
+ // Fill transaction content. Internal carrier is bigint OS; the
129
+ // serializerGate emits the right wire shape (DEM number pre-fork,
130
+ // OS string post-fork) when `demos.sign` hashes.
94
131
  tx.content.from = sender;
95
132
  tx.content.to = escrowAddress;
96
133
  tx.content.nonce = nonce + 1;
97
- tx.content.amount = amount;
134
+ tx.content.amount = amountOs;
98
135
  tx.content.type = "escrow";
99
136
  tx.content.timestamp = Date.now();
100
137
  tx.content.gcr_edits = gcrEdits;
@@ -103,13 +140,57 @@ export class EscrowTransaction {
103
140
  {
104
141
  platform,
105
142
  username,
106
- amount: amount.toString(),
143
+ // The escrow payload's `amount` is a free-form string here;
144
+ // emit canonical OS for forward compatibility with the
145
+ // post-fork node's escrow handler. Pre-fork node tolerates
146
+ // arbitrary strings on this nested field.
147
+ amount: amountOs.toString(),
107
148
  operation: "deposit",
108
149
  },
109
150
  ];
110
151
  // Sign transaction
111
152
  return await demos.sign(tx);
112
153
  }
154
+ /**
155
+ * Normalise a public-API amount input (`number` legacy DEM or
156
+ * `bigint` OS) into both forms. Used at every boundary that needs
157
+ * dual-shape support during the pre-/post-fork rollout.
158
+ *
159
+ * - `number` input: must be a non-negative integer DEM amount;
160
+ * converted to OS via `OS_PER_DEM`. Fractional DEM `number` is
161
+ * rejected — silently flooring (the previous behaviour) discarded
162
+ * up to ~10^9 OS per call. Callers who need sub-DEM precision
163
+ * must pass a `bigint` OS amount (e.g. `denomination.demToOs("1.5")`).
164
+ * - `bigint` input: treated as OS; DEM form is the integer division
165
+ * `amountOs / OS_PER_DEM`. The pre-fork sub-DEM precision rejection
166
+ * lives in `Demos._assertAmountAcceptableOnTargetNode` (called by
167
+ * `sendToIdentity` before this helper runs).
168
+ *
169
+ * @internal Exposed only to keep the migration paths discoverable.
170
+ */
171
+ static normalizeAmountInput(amount) {
172
+ if (typeof amount === "bigint") {
173
+ if (amount < 0n) {
174
+ throw new Error(`[EscrowTransaction] amount must be non-negative, got ${amount}`);
175
+ }
176
+ const amountOs = amount;
177
+ // Sub-DEM precision is allowed at the bigint level — the
178
+ // public API rejection lives in `_assertAmountAcceptableOnTargetNode`,
179
+ // gated on pre-fork node detection. The `amountDem` returned
180
+ // here is integer-truncated; callers that need exact DEM
181
+ // should branch on `amountOs % OS_PER_DEM === 0n` first.
182
+ const amountDem = Number(amountOs / OS_PER_DEM);
183
+ return { amountDem, amountOs };
184
+ }
185
+ if (!Number.isFinite(amount) || amount < 0) {
186
+ throw new Error(`[EscrowTransaction] amount must be a non-negative finite number or bigint, got ${amount}`);
187
+ }
188
+ if (!Number.isInteger(amount)) {
189
+ throw new Error(`[EscrowTransaction] fractional DEM not supported on the number path (got ${amount}); pass a bigint OS amount via denomination.demToOs("${amount}") instead`);
190
+ }
191
+ const amountOs = BigInt(amount) * OS_PER_DEM;
192
+ return { amountDem: amount, amountOs };
193
+ }
113
194
  /**
114
195
  * Creates a transaction to claim escrowed funds
115
196
  *
@@ -1 +1 @@
1
- {"version":3,"file":"EscrowTransaction.js","sourceRoot":"","sources":["../../../src/escrow/EscrowTransaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;EASE;AAIF,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO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AAC,OAAO,CAAC,KAAK,GAAG,KAAK,GAAG,CAAC,CAAA;QAC5B,EAAE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAA,CAAE,wBAAwB;QAC/C,EAAE,CAAC,OAAO,CAAC,IAAI,GAAG,QAAQ,CAAA;QAC1B,EAAE,CAAC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACjC,EAAE,CAAC,OAAO,CAAC,SAAS,GAAG,QAAQ,CAAA;QAC/B,EAAE,CAAC,OAAO,CAAC,IAAI,GAAG;YACd,QAAQ;YACR;gBACI,QAAQ;gBACR,QAAQ;gBACR,SAAS,EAAE,QAAQ;aACtB;SACJ,CAAA;QAED,mBAAmB;QACnB,OAAO,MAAM,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC/B,CAAC;CACJ"}
@@ -118,11 +118,28 @@ export interface IPFSPinsResponse {
118
118
  * Response from ipfsQuote nodeCall
119
119
  *
120
120
  * Provides cost estimation before transaction is built and signed.
121
- * Use this to populate custom_charges in the transaction.
121
+ * Use this to populate `custom_charges` in the transaction.
122
+ *
123
+ * P4 dual-shape compatibility:
124
+ * - Pre-fork node returns `cost_dem` (decimal string, DEM).
125
+ * - Post-fork node returns `cost_os` (decimal string, OS).
126
+ *
127
+ * SDK helpers (`quoteToCustomCharges`, `createCustomCharges`) prefer
128
+ * `cost_os` when present and otherwise convert `cost_dem` via
129
+ * `denomination.demToOs`. Likewise `breakdown.{base_cost,size_cost}` is
130
+ * shape-stable across the fork.
122
131
  */
123
132
  export interface IpfsQuoteResponse {
124
- /** Estimated cost in DEM (as string for BigInt safety) */
125
- cost_dem: string;
133
+ /**
134
+ * Estimated cost in DEM as a decimal string (legacy/pre-fork shape).
135
+ * Kept for back-compat with current node responses.
136
+ */
137
+ cost_dem?: string;
138
+ /**
139
+ * Estimated cost in OS as a decimal string (post-fork shape).
140
+ * Preferred when present.
141
+ */
142
+ cost_os?: string;
126
143
  /** File size used for calculation */
127
144
  file_size_bytes: number;
128
145
  /** Whether sender is a genesis account */
@@ -147,8 +164,8 @@ export interface IpfsQuoteResponse {
147
164
  export interface AddOptionsWithCharges extends AddOptions {
148
165
  /** Optional custom charges configuration for cost control */
149
166
  customCharges?: {
150
- /** Maximum cost user agrees to pay (from ipfsQuote response) */
151
- maxCostDem: string;
167
+ /** Maximum cost user agrees to pay, decimal-string OS (from ipfsQuote response). */
168
+ maxCostOs: string;
152
169
  /** Optional cost breakdown for reference */
153
170
  estimatedBreakdown?: IPFSCostBreakdown;
154
171
  };
@@ -161,8 +178,8 @@ export interface PinOptionsWithCharges extends PinOptions {
161
178
  fileSize?: number;
162
179
  /** Optional custom charges configuration for cost control */
163
180
  customCharges?: {
164
- /** Maximum cost user agrees to pay (from ipfsQuote response) */
165
- maxCostDem: string;
181
+ /** Maximum cost user agrees to pay, decimal-string OS (from ipfsQuote response). */
182
+ maxCostOs: string;
166
183
  /** Optional cost breakdown for reference */
167
184
  estimatedBreakdown?: IPFSCostBreakdown;
168
185
  };
@@ -221,7 +238,7 @@ export declare class IPFSOperations {
221
238
  * content,
222
239
  * {
223
240
  * filename: 'data.json',
224
- * customCharges: { maxCostDem: quote.cost_dem }
241
+ * customCharges: IPFSOperations.quoteToCustomCharges(quote)
225
242
  * }
226
243
  * )
227
244
  * ```
@@ -251,7 +268,7 @@ export declare class IPFSOperations {
251
268
  * const quote = await demos.ipfs.quote(fileSize, 'IPFS_PIN')
252
269
  * const chargedPayload = IPFSOperations.createPinPayload('QmExample...', {
253
270
  * fileSize: 1024,
254
- * customCharges: { maxCostDem: quote.cost_dem }
271
+ * customCharges: IPFSOperations.quoteToCustomCharges(quote)
255
272
  * })
256
273
  * ```
257
274
  */
@@ -365,9 +382,19 @@ export declare class IPFSOperations {
365
382
  * ```
366
383
  */
367
384
  static quoteToCustomCharges(quote: IpfsQuoteResponse): {
368
- maxCostDem: string;
385
+ maxCostOs: string;
369
386
  estimatedBreakdown: IPFSCostBreakdown;
370
387
  };
388
+ /**
389
+ * Normalise an `IpfsQuoteResponse` into a single canonical OS-decimal
390
+ * cost string. Prefers `cost_os` (post-fork) over `cost_dem`
391
+ * (pre-fork). Throws if neither is present or both are unparseable.
392
+ *
393
+ * Exposed as a private static helper so internal payload builders and
394
+ * the public `quoteToCustomCharges` / `createCustomCharges` helpers
395
+ * share one implementation.
396
+ */
397
+ private static _normalizeQuoteCostOs;
371
398
  /**
372
399
  * Create IPFSCustomCharges object from quote response
373
400
  *