@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.
- package/build/bridge/nativeBridgeTypes.d.ts +4 -3
- package/build/bridge/nativeBridgeTypes.js.map +1 -1
- package/build/d402/client/types.d.ts +6 -3
- package/build/d402/server/D402Server.d.ts +25 -0
- package/build/d402/server/D402Server.js +63 -2
- package/build/d402/server/D402Server.js.map +1 -1
- package/build/d402/server/middleware.d.ts +7 -4
- package/build/d402/server/middleware.js.map +1 -1
- package/build/d402/server/types.d.ts +15 -7
- package/build/denomination/conversion.test.js +1 -1
- package/build/denomination/conversion.test.js.map +1 -1
- package/build/denomination/index.d.ts +3 -0
- package/build/denomination/index.js +6 -0
- package/build/denomination/index.js.map +1 -1
- package/build/denomination/networkInfo.d.ts +69 -0
- package/build/denomination/networkInfo.js +38 -0
- package/build/denomination/networkInfo.js.map +1 -0
- package/build/denomination/networkInfo.test.d.ts +1 -0
- package/build/denomination/networkInfo.test.js +28 -0
- package/build/denomination/networkInfo.test.js.map +1 -0
- package/build/denomination/roundTripHash.test.d.ts +1 -0
- package/build/denomination/roundTripHash.test.js +227 -0
- package/build/denomination/roundTripHash.test.js.map +1 -0
- package/build/denomination/serializerGate.d.ts +46 -0
- package/build/denomination/serializerGate.js +283 -0
- package/build/denomination/serializerGate.js.map +1 -0
- package/build/denomination/serializerGate.test.d.ts +1 -0
- package/build/denomination/serializerGate.test.js +245 -0
- package/build/denomination/serializerGate.test.js.map +1 -0
- package/build/escrow/EscrowTransaction.d.ts +36 -5
- package/build/escrow/EscrowTransaction.js +91 -10
- package/build/escrow/EscrowTransaction.js.map +1 -1
- package/build/ipfs/IPFSOperations.d.ts +37 -10
- package/build/ipfs/IPFSOperations.js +38 -8
- package/build/ipfs/IPFSOperations.js.map +1 -1
- package/build/storage/StorageProgram.d.ts +16 -8
- package/build/storage/StorageProgram.js +16 -8
- package/build/storage/StorageProgram.js.map +1 -1
- package/build/tlsnotary/TLSNotaryService.d.ts +19 -8
- package/build/tlsnotary/TLSNotaryService.js +22 -7
- package/build/tlsnotary/TLSNotaryService.js.map +1 -1
- package/build/tlsnotary/helpers.d.ts +11 -5
- package/build/tlsnotary/helpers.js +17 -5
- package/build/tlsnotary/helpers.js.map +1 -1
- package/build/types/blockchain/CustomCharges.d.ts +28 -16
- package/build/types/blockchain/CustomCharges.js +15 -5
- package/build/types/blockchain/CustomCharges.js.map +1 -1
- package/build/types/blockchain/GCREdit.d.ts +26 -2
- package/build/types/blockchain/Transaction.d.ts +14 -1
- package/build/types/blockchain/Transaction.js.map +1 -1
- package/build/types/blockchain/TransactionSubtypes/D402PaymentTransaction.d.ts +8 -3
- package/build/types/blockchain/TransactionSubtypes/StorageProgramTransaction.d.ts +6 -5
- package/build/types/blockchain/TransactionSubtypes/StorageProgramTransaction.js +15 -3
- package/build/types/blockchain/TransactionSubtypes/StorageProgramTransaction.js.map +1 -1
- package/build/types/blockchain/TxFee.d.ts +16 -3
- package/build/types/blockchain/address.d.ts +23 -0
- package/build/types/blockchain/rawTransaction.d.ts +13 -4
- package/build/types/blockchain/statusNative.d.ts +9 -1
- package/build/types/bridge/bridgeTradePayload.d.ts +1 -1
- package/build/types/gls/StateChange.d.ts +29 -3
- package/build/types/native/INativePayload.d.ts +6 -1
- package/build/wallet/Wallet.d.ts +27 -1
- package/build/wallet/Wallet.js +30 -17
- package/build/wallet/Wallet.js.map +1 -1
- package/build/websdk/DemosTransactions.d.ts +30 -4
- package/build/websdk/DemosTransactions.js +88 -9
- package/build/websdk/DemosTransactions.js.map +1 -1
- package/build/websdk/GCRGeneration.d.ts +10 -2
- package/build/websdk/GCRGeneration.js +30 -14
- package/build/websdk/GCRGeneration.js.map +1 -1
- package/build/websdk/demosclass.d.ts +152 -23
- package/build/websdk/demosclass.js +305 -38
- package/build/websdk/demosclass.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { describe, test, expect } from "@jest/globals";
|
|
2
|
+
import { serializeTransactionContent } from "./serializerGate.js";
|
|
3
|
+
import { demToOs, parseOsString, toOsString } from "./conversion.js";
|
|
4
|
+
// REVIEW: P4 commit 4 — load-bearing round-trip hash equality. The
|
|
5
|
+
// test inlines the node's `serializeTransactionContent` algorithm
|
|
6
|
+
// (verbatim port of `node/src/forks/serializerGate.ts`) so the SDK's
|
|
7
|
+
// implementation is asserted against the canonical node bytes
|
|
8
|
+
// without a cross-repo runtime dependency.
|
|
9
|
+
//
|
|
10
|
+
// If this test breaks, the SDK has produced bytes the node will
|
|
11
|
+
// reject with an InvalidSignature — STOP and triage before shipping.
|
|
12
|
+
/**
|
|
13
|
+
* Verbatim port of the node's `toOsBigint` from
|
|
14
|
+
* `node/src/forks/serializerGate.ts:41`. Kept inline so this test
|
|
15
|
+
* fails the day the node's coercion semantics drift, instead of
|
|
16
|
+
* silently passing against a stale fixture.
|
|
17
|
+
*/
|
|
18
|
+
function nodeToOsBigint(value) {
|
|
19
|
+
if (typeof value === "bigint") {
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
if (typeof value === "string") {
|
|
23
|
+
return parseOsString(value);
|
|
24
|
+
}
|
|
25
|
+
return demToOs(value);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Verbatim port of the node's `transformToOsTransactionContent` from
|
|
29
|
+
* `node/src/forks/serializerGate.ts:73`. Note the deliberate scope:
|
|
30
|
+
* the node only transforms top-level `amount` and `transaction_fee.*`.
|
|
31
|
+
* It does **not** walk `gcr_edits[]`. The SDK's serializer is the
|
|
32
|
+
* source of truth for that array — fixtures here therefore arrive
|
|
33
|
+
* with gcr_edits already in OS-string shape.
|
|
34
|
+
*/
|
|
35
|
+
function nodeTransformToOsTransactionContent(content) {
|
|
36
|
+
const transformed = { ...content };
|
|
37
|
+
if (typeof content.amount !== "undefined" && content.amount !== null) {
|
|
38
|
+
const osAmount = nodeToOsBigint(content.amount);
|
|
39
|
+
transformed.amount = toOsString(osAmount);
|
|
40
|
+
}
|
|
41
|
+
if (content.transaction_fee) {
|
|
42
|
+
const fee = content.transaction_fee;
|
|
43
|
+
transformed.transaction_fee = {
|
|
44
|
+
network_fee: toOsString(nodeToOsBigint(fee.network_fee)),
|
|
45
|
+
rpc_fee: toOsString(nodeToOsBigint(fee.rpc_fee)),
|
|
46
|
+
additional_fee: toOsString(nodeToOsBigint(fee.additional_fee)),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return transformed;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Verbatim port of the node's `serializeTransactionContent` from
|
|
53
|
+
* `node/src/forks/serializerGate.ts:124`. The block-height /
|
|
54
|
+
* `isForkActive` check is collapsed into a boolean parameter for the
|
|
55
|
+
* test — the SDK doesn't see blocks, the node does, but at the
|
|
56
|
+
* post-fork branch both produce the same bytes.
|
|
57
|
+
*/
|
|
58
|
+
function nodeSerializeTransactionContent(content, isPostFork) {
|
|
59
|
+
if (isPostFork) {
|
|
60
|
+
return JSON.stringify(nodeTransformToOsTransactionContent(content));
|
|
61
|
+
}
|
|
62
|
+
return JSON.stringify(content);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Build a transaction-content fixture in canonical key order with
|
|
66
|
+
* gcr_edits already populated as the SDK would emit them post-fork
|
|
67
|
+
* (`amount` is OS string for `balance` and `escrow.data.amount`; the
|
|
68
|
+
* `nonce` edit's `amount` stays a counter number). This matches what
|
|
69
|
+
* `GCRGeneration.generate` produces against a post-fork node.
|
|
70
|
+
*/
|
|
71
|
+
function buildPostForkShapedFixture() {
|
|
72
|
+
const gcr_edits = [
|
|
73
|
+
{
|
|
74
|
+
type: "balance",
|
|
75
|
+
isRollback: false,
|
|
76
|
+
operation: "remove",
|
|
77
|
+
account: "0xsender",
|
|
78
|
+
amount: "100000000001", // sub-DEM-precision OS string
|
|
79
|
+
txhash: "",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: "nonce",
|
|
83
|
+
isRollback: false,
|
|
84
|
+
operation: "add",
|
|
85
|
+
account: "0xsender",
|
|
86
|
+
amount: 1,
|
|
87
|
+
txhash: "",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
type: "balance",
|
|
91
|
+
isRollback: false,
|
|
92
|
+
operation: "add",
|
|
93
|
+
account: "0xreceiver",
|
|
94
|
+
amount: "100000000001",
|
|
95
|
+
txhash: "",
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
type: "escrow",
|
|
99
|
+
operation: "deposit",
|
|
100
|
+
account: "0xescrow",
|
|
101
|
+
data: {
|
|
102
|
+
sender: "0xsender",
|
|
103
|
+
platform: "twitter",
|
|
104
|
+
username: "@bob",
|
|
105
|
+
amount: "100000000001",
|
|
106
|
+
expiryDays: 30,
|
|
107
|
+
},
|
|
108
|
+
txhash: "",
|
|
109
|
+
isRollback: false,
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
return {
|
|
113
|
+
type: "native",
|
|
114
|
+
from: "0xsender",
|
|
115
|
+
to: "0xreceiver",
|
|
116
|
+
amount: "100000000001", // sub-DEM-precision OS string
|
|
117
|
+
data: [
|
|
118
|
+
"native",
|
|
119
|
+
{
|
|
120
|
+
nativeOperation: "send",
|
|
121
|
+
args: ["0xreceiver", "100000000001"],
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
nonce: 1,
|
|
125
|
+
timestamp: 1700000000000,
|
|
126
|
+
transaction_fee: {
|
|
127
|
+
network_fee: "1000000000",
|
|
128
|
+
rpc_fee: "0",
|
|
129
|
+
additional_fee: "0",
|
|
130
|
+
},
|
|
131
|
+
from_ed25519_address: "0xsender",
|
|
132
|
+
gcr_edits,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
describe("round-trip hash equality — SDK post-fork == node post-fork", () => {
|
|
136
|
+
test("OS-string fixture: SDK and node produce identical bytes", () => {
|
|
137
|
+
const content = buildPostForkShapedFixture();
|
|
138
|
+
const sdkBytes = serializeTransactionContent(content, true);
|
|
139
|
+
const nodeBytes = nodeSerializeTransactionContent(content, true);
|
|
140
|
+
expect(sdkBytes).toBe(nodeBytes);
|
|
141
|
+
});
|
|
142
|
+
test("legacy DEM-number fixture: post-fork SDK matches node post-fork output", () => {
|
|
143
|
+
// Build a fixture where the user has populated content with
|
|
144
|
+
// legacy DEM numbers (the v2 callers' pattern). Both SDK and
|
|
145
|
+
// node will normalise the top-level `amount` and
|
|
146
|
+
// `transaction_fee.*` to OS strings; the SDK additionally
|
|
147
|
+
// walks gcr_edits — but the node serializer leaves gcr_edits
|
|
148
|
+
// alone, so to get byte equality the fixture must already
|
|
149
|
+
// carry the post-fork-shaped edits. (This is exactly the SDK
|
|
150
|
+
// contract: gcr_edits are the SDK's responsibility.)
|
|
151
|
+
const content = buildPostForkShapedFixture();
|
|
152
|
+
// Override the wire-sensitive fields with legacy DEM numbers.
|
|
153
|
+
content.amount = 100;
|
|
154
|
+
content.transaction_fee = {
|
|
155
|
+
network_fee: 1,
|
|
156
|
+
rpc_fee: 0,
|
|
157
|
+
additional_fee: 0,
|
|
158
|
+
};
|
|
159
|
+
const sdkBytes = serializeTransactionContent(content, true);
|
|
160
|
+
const nodeBytes = nodeSerializeTransactionContent(content, true);
|
|
161
|
+
expect(sdkBytes).toBe(nodeBytes);
|
|
162
|
+
});
|
|
163
|
+
test("bigint amount: SDK normalises before stringify; node sees the SDK output", () => {
|
|
164
|
+
// The node never sees a raw bigint on the wire (JSON has no
|
|
165
|
+
// bigint). But the SDK's internal carrier is bigint, and the
|
|
166
|
+
// serializer must coerce to OS string before JSON.stringify.
|
|
167
|
+
// Verify both produce the same canonical output for an
|
|
168
|
+
// OS-string fixture that started from a bigint input.
|
|
169
|
+
const sourceBigintOs = 100000000001n;
|
|
170
|
+
const content = buildPostForkShapedFixture();
|
|
171
|
+
content.amount = toOsString(sourceBigintOs);
|
|
172
|
+
const sdkBytes = serializeTransactionContent(content, true);
|
|
173
|
+
const nodeBytes = nodeSerializeTransactionContent(content, true);
|
|
174
|
+
expect(sdkBytes).toBe(nodeBytes);
|
|
175
|
+
const parsed = JSON.parse(sdkBytes);
|
|
176
|
+
expect(parsed.amount).toBe("100000000001");
|
|
177
|
+
});
|
|
178
|
+
test("non-canonical OS-string normalises identically on both sides", () => {
|
|
179
|
+
const content = buildPostForkShapedFixture();
|
|
180
|
+
content.amount = "00100";
|
|
181
|
+
const sdkBytes = serializeTransactionContent(content, true);
|
|
182
|
+
const nodeBytes = nodeSerializeTransactionContent(content, true);
|
|
183
|
+
expect(sdkBytes).toBe(nodeBytes);
|
|
184
|
+
const parsed = JSON.parse(sdkBytes);
|
|
185
|
+
expect(parsed.amount).toBe("100");
|
|
186
|
+
});
|
|
187
|
+
test("pre-fork branch: SDK and node both stringify content as-is", () => {
|
|
188
|
+
// For pre-fork content with no internal bigints / OS strings,
|
|
189
|
+
// both branches produce `JSON.stringify(content)` verbatim.
|
|
190
|
+
const content = {
|
|
191
|
+
type: "native",
|
|
192
|
+
from: "0xsender",
|
|
193
|
+
to: "0xreceiver",
|
|
194
|
+
amount: 100,
|
|
195
|
+
data: [
|
|
196
|
+
"native",
|
|
197
|
+
{
|
|
198
|
+
nativeOperation: "send",
|
|
199
|
+
args: ["0xreceiver", 100],
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
nonce: 1,
|
|
203
|
+
timestamp: 1700000000000,
|
|
204
|
+
transaction_fee: {
|
|
205
|
+
network_fee: 1,
|
|
206
|
+
rpc_fee: 0,
|
|
207
|
+
additional_fee: 0,
|
|
208
|
+
},
|
|
209
|
+
from_ed25519_address: "0xsender",
|
|
210
|
+
gcr_edits: [
|
|
211
|
+
{
|
|
212
|
+
type: "balance",
|
|
213
|
+
isRollback: false,
|
|
214
|
+
operation: "remove",
|
|
215
|
+
account: "0xsender",
|
|
216
|
+
amount: 100,
|
|
217
|
+
txhash: "",
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
};
|
|
221
|
+
const sdkBytes = serializeTransactionContent(content, false);
|
|
222
|
+
const nodeBytes = nodeSerializeTransactionContent(content, false);
|
|
223
|
+
expect(sdkBytes).toBe(nodeBytes);
|
|
224
|
+
expect(sdkBytes).toBe(JSON.stringify(content));
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
//# sourceMappingURL=roundTripHash.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roundTripHash.test.js","sourceRoot":"","sources":["../../../src/denomination/roundTripHash.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAA;AAC9D,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAIjE,mEAAmE;AACnE,kEAAkE;AAClE,qEAAqE;AACrE,8DAA8D;AAC9D,2CAA2C;AAC3C,EAAE;AACF,gEAAgE;AAChE,qEAAqE;AAErE;;;;;GAKG;AACH,SAAS,cAAc,CAAC,KAA+B;IACnD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAA;IAChB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,aAAa,CAAC,KAAK,CAAC,CAAA;IAC/B,CAAC;IACD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAA;AACzB,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,mCAAmC,CACxC,OAA2B;IAE3B,MAAM,WAAW,GAAG,EAAE,GAAG,OAAO,EAAwB,CAAA;IAExD,IAAI,OAAO,OAAO,CAAC,MAAM,KAAK,WAAW,IAAI,OAAO,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;QACnE,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,MAAkC,CAAC,CAAA;QAC3E,WAAW,CAA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CAAC,CAAA;QACjE,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QAChC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IAClD,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dual-format transaction-content serializer.
|
|
3
|
+
*
|
|
4
|
+
* This is the SDK-side mirror of the node's `forks/serializerGate.ts`. It
|
|
5
|
+
* stringifies a `TransactionContent` for hashing/signing and chooses
|
|
6
|
+
* between two wire shapes based on the connected node's fork status:
|
|
7
|
+
*
|
|
8
|
+
* - **Pre-fork**: legacy DEM-`number` JSON. Any internal `bigint` OS
|
|
9
|
+
* amounts are coerced back to JS `number` in DEM via integer division
|
|
10
|
+
* by `OS_PER_DEM`, and the rest of the content is passed through
|
|
11
|
+
* `JSON.stringify` verbatim.
|
|
12
|
+
* - **Post-fork**: OS-decimal-string JSON. The top-level `amount`,
|
|
13
|
+
* every `transaction_fee.*` field, and the per-entry `amount` field
|
|
14
|
+
* on every `gcr_edits[]` entry that carries one (`balance` and
|
|
15
|
+
* `escrow.data.amount`) are converted to canonical OS strings. All
|
|
16
|
+
* other fields are passed through verbatim.
|
|
17
|
+
*
|
|
18
|
+
* Property order is consensus-critical: the node hashes the result of
|
|
19
|
+
* `JSON.stringify`, which serializes keys in insertion order. The
|
|
20
|
+
* implementation uses object spread (`{ ...content, amount, ... }`) which
|
|
21
|
+
* preserves the source's insertion order and overwrites the
|
|
22
|
+
* wire-sensitive fields in place without reordering them.
|
|
23
|
+
*
|
|
24
|
+
* The branching is by node fork status (a boolean), not by block height
|
|
25
|
+
* — the SDK doesn't see blocks. Detection of that boolean lives in
|
|
26
|
+
* `Demos.getNetworkInfo()` (see P4 commit 3) and is cached per-instance.
|
|
27
|
+
*
|
|
28
|
+
* @module denomination/serializerGate
|
|
29
|
+
*/
|
|
30
|
+
import type { TransactionContent } from "../types/blockchain/Transaction";
|
|
31
|
+
/**
|
|
32
|
+
* Serialize transaction content for hashing/signing.
|
|
33
|
+
*
|
|
34
|
+
* This is the load-bearing wire boundary: the bytes returned here are
|
|
35
|
+
* fed into `sha256` and the resulting hash is what the keypair signs.
|
|
36
|
+
* The receiving node hashes its in-memory `TransactionContent` through
|
|
37
|
+
* its own `serializerGate.serializeTransactionContent`; if our bytes
|
|
38
|
+
* differ from the node's bytes the signature will not validate.
|
|
39
|
+
*
|
|
40
|
+
* @param content - The transaction content to serialize.
|
|
41
|
+
* @param isPostFork - `true` when the connected node has activated the
|
|
42
|
+
* `osDenomination` fork. When `false` (pre-fork or unknown), the
|
|
43
|
+
* legacy DEM-number wire shape is emitted.
|
|
44
|
+
* @returns Canonical JSON string for hashing.
|
|
45
|
+
*/
|
|
46
|
+
export declare function serializeTransactionContent(content: TransactionContent, isPostFork: boolean): string;
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dual-format transaction-content serializer.
|
|
3
|
+
*
|
|
4
|
+
* This is the SDK-side mirror of the node's `forks/serializerGate.ts`. It
|
|
5
|
+
* stringifies a `TransactionContent` for hashing/signing and chooses
|
|
6
|
+
* between two wire shapes based on the connected node's fork status:
|
|
7
|
+
*
|
|
8
|
+
* - **Pre-fork**: legacy DEM-`number` JSON. Any internal `bigint` OS
|
|
9
|
+
* amounts are coerced back to JS `number` in DEM via integer division
|
|
10
|
+
* by `OS_PER_DEM`, and the rest of the content is passed through
|
|
11
|
+
* `JSON.stringify` verbatim.
|
|
12
|
+
* - **Post-fork**: OS-decimal-string JSON. The top-level `amount`,
|
|
13
|
+
* every `transaction_fee.*` field, and the per-entry `amount` field
|
|
14
|
+
* on every `gcr_edits[]` entry that carries one (`balance` and
|
|
15
|
+
* `escrow.data.amount`) are converted to canonical OS strings. All
|
|
16
|
+
* other fields are passed through verbatim.
|
|
17
|
+
*
|
|
18
|
+
* Property order is consensus-critical: the node hashes the result of
|
|
19
|
+
* `JSON.stringify`, which serializes keys in insertion order. The
|
|
20
|
+
* implementation uses object spread (`{ ...content, amount, ... }`) which
|
|
21
|
+
* preserves the source's insertion order and overwrites the
|
|
22
|
+
* wire-sensitive fields in place without reordering them.
|
|
23
|
+
*
|
|
24
|
+
* The branching is by node fork status (a boolean), not by block height
|
|
25
|
+
* — the SDK doesn't see blocks. Detection of that boolean lives in
|
|
26
|
+
* `Demos.getNetworkInfo()` (see P4 commit 3) and is cached per-instance.
|
|
27
|
+
*
|
|
28
|
+
* @module denomination/serializerGate
|
|
29
|
+
*/
|
|
30
|
+
import { OS_PER_DEM } from "./constants.js";
|
|
31
|
+
import { demToOs, parseOsString, toOsString } from "./conversion.js";
|
|
32
|
+
// REVIEW: P4 commit 2 — load-bearing wire boundary. Mirrors the node's
|
|
33
|
+
// `serializeTransactionContent` (forks/serializerGate.ts) byte for byte
|
|
34
|
+
// for post-fork output; pre-fork output is identical to the legacy
|
|
35
|
+
// `JSON.stringify(content)` path the SDK has used since v1.
|
|
36
|
+
/**
|
|
37
|
+
* Coerce a wire-format amount/fee value to an OS `bigint`.
|
|
38
|
+
*
|
|
39
|
+
* Accepts:
|
|
40
|
+
* - `bigint`: returned as-is.
|
|
41
|
+
* - `string`: parsed as a canonical OS decimal integer string (post-fork
|
|
42
|
+
* wire shape).
|
|
43
|
+
* - `number`: treated as DEM (pre-fork wire shape) and converted to OS.
|
|
44
|
+
*
|
|
45
|
+
* Throws on un-coercible inputs (non-numeric strings, fractional numbers
|
|
46
|
+
* smaller than 1 OS, negative results — all surfaced by the underlying
|
|
47
|
+
* `denomination` helpers).
|
|
48
|
+
*
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
function toOsBigint(value) {
|
|
52
|
+
if (typeof value === "bigint") {
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
if (typeof value === "string") {
|
|
56
|
+
return parseOsString(value);
|
|
57
|
+
}
|
|
58
|
+
return demToOs(value);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Coerce an OS-bigint back to a DEM JS `number` for legacy wire shape.
|
|
62
|
+
*
|
|
63
|
+
* Used by the pre-fork branch when an internal bigint amount needs to go
|
|
64
|
+
* onto the wire as the legacy DEM-number. Performs an integer division
|
|
65
|
+
* by `OS_PER_DEM`; the caller is responsible for ensuring the input has
|
|
66
|
+
* no sub-DEM precision (the public-API guard in P4 commit 3 enforces
|
|
67
|
+
* this before we get here).
|
|
68
|
+
*
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
function osToDemNumber(os) {
|
|
72
|
+
return Number(os / OS_PER_DEM);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Normalise an `amount`/fee field for the **pre-fork** wire shape.
|
|
76
|
+
*
|
|
77
|
+
* - `bigint` (internal OS) → `number` (DEM, legacy wire).
|
|
78
|
+
* - `string` (post-fork OS) → `number` (DEM). This path is entered when
|
|
79
|
+
* a v3 caller has already produced post-fork-shaped content but the
|
|
80
|
+
* connected node turned out to be pre-fork. The serializer is the
|
|
81
|
+
* last chance to coerce.
|
|
82
|
+
* - `number` (legacy DEM) → returned unchanged.
|
|
83
|
+
*
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
function toPreForkWireNumber(value) {
|
|
87
|
+
if (typeof value === "number")
|
|
88
|
+
return value;
|
|
89
|
+
return osToDemNumber(toOsBigint(value));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Normalise an `amount`/fee field for the **post-fork** wire shape.
|
|
93
|
+
*
|
|
94
|
+
* - `bigint` (internal OS) → canonical OS decimal string.
|
|
95
|
+
* - `number` (legacy DEM) → DEM-to-OS conversion → canonical OS string.
|
|
96
|
+
* - `string` → re-parsed and re-emitted as a canonical OS string. This
|
|
97
|
+
* normalises non-canonical shapes (`"00100"`, `" 100 "`) to `"100"`
|
|
98
|
+
* so the hash matches the node's `transformToOsTransactionContent`
|
|
99
|
+
* output.
|
|
100
|
+
*
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
function toPostForkWireString(value) {
|
|
104
|
+
return toOsString(toOsBigint(value));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Walk a single `GCREdit` entry and rewrite its embedded amount fields
|
|
108
|
+
* for the post-fork wire shape. The two carriers we touch (per SPEC_P4
|
|
109
|
+
* §2.2) are:
|
|
110
|
+
*
|
|
111
|
+
* - `GCREditBalance.amount` — top-level numeric balance edit.
|
|
112
|
+
* - `GCREditEscrow.data.amount` — nested escrow deposit amount.
|
|
113
|
+
*
|
|
114
|
+
* Other variants (`nonce`, `assign`, `identity`, `smartContract`,
|
|
115
|
+
* `storageProgram`, `tlsnotary`, `validatorStake`,
|
|
116
|
+
* `networkUpgrade`, `networkUpgradeVote`) are passed through unchanged.
|
|
117
|
+
* `validatorStake.amount` is already a bigint-as-string by construction
|
|
118
|
+
* (see GCREdit.ts:258); we still re-parse and re-emit through
|
|
119
|
+
* `toPostForkWireString` so non-canonical inputs are normalised.
|
|
120
|
+
*
|
|
121
|
+
* Object spread preserves key order; the targeted overwrites do not
|
|
122
|
+
* change the position of any existing key.
|
|
123
|
+
*
|
|
124
|
+
* @internal
|
|
125
|
+
*/
|
|
126
|
+
function transformEditPostFork(edit) {
|
|
127
|
+
if (edit.type === "balance") {
|
|
128
|
+
return {
|
|
129
|
+
...edit,
|
|
130
|
+
amount: toPostForkWireString(edit.amount),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (edit.type === "escrow") {
|
|
134
|
+
const data = edit.data ?? {};
|
|
135
|
+
if (typeof data.amount === "undefined" || data.amount === null) {
|
|
136
|
+
return edit;
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
...edit,
|
|
140
|
+
data: {
|
|
141
|
+
...data,
|
|
142
|
+
amount: toPostForkWireString(data.amount),
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (edit.type === "validatorStake") {
|
|
147
|
+
// Already string-typed in the static type, but normalise anyway.
|
|
148
|
+
return {
|
|
149
|
+
...edit,
|
|
150
|
+
amount: toPostForkWireString(edit.amount),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return edit;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Rewrite a single `GCREdit` for the **pre-fork** wire shape.
|
|
157
|
+
*
|
|
158
|
+
* Symmetric to {@link transformEditPostFork} but emits legacy DEM
|
|
159
|
+
* numbers. Used when SDK v3 callers have already populated edits with
|
|
160
|
+
* OS-strings/bigints (commit 1's widened types) but the connected node
|
|
161
|
+
* is pre-fork.
|
|
162
|
+
*
|
|
163
|
+
* @internal
|
|
164
|
+
*/
|
|
165
|
+
function transformEditPreFork(edit) {
|
|
166
|
+
if (edit.type === "balance") {
|
|
167
|
+
return {
|
|
168
|
+
...edit,
|
|
169
|
+
amount: toPreForkWireNumber(edit.amount),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (edit.type === "escrow") {
|
|
173
|
+
const data = edit.data ?? {};
|
|
174
|
+
if (typeof data.amount === "undefined" || data.amount === null) {
|
|
175
|
+
return edit;
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
...edit,
|
|
179
|
+
data: {
|
|
180
|
+
...data,
|
|
181
|
+
// Pre-fork escrow.data.amount was a JS number historically.
|
|
182
|
+
amount: toPreForkWireNumber(data.amount),
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
return edit;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Re-emit a `TransactionContent` with `amount`, `transaction_fee.*`, and
|
|
190
|
+
* each `gcr_edits[]` entry's amount fields encoded as canonical OS
|
|
191
|
+
* decimal strings.
|
|
192
|
+
*
|
|
193
|
+
* Property order is preserved by spreading the source content first and
|
|
194
|
+
* then overwriting the wire-sensitive fields in place. This is the
|
|
195
|
+
* post-fork branch's analogue to the node's
|
|
196
|
+
* `transformToOsTransactionContent`. The SDK additionally walks
|
|
197
|
+
* `gcr_edits[]` here because, unlike the node's serializer, the SDK is
|
|
198
|
+
* the source of truth for those entries — the node's serializer
|
|
199
|
+
* intentionally does not transform them.
|
|
200
|
+
*
|
|
201
|
+
* @internal
|
|
202
|
+
*/
|
|
203
|
+
function transformToPostFork(content) {
|
|
204
|
+
const transformed = { ...content };
|
|
205
|
+
if (typeof content.amount !== "undefined" && content.amount !== null) {
|
|
206
|
+
transformed.amount = toPostForkWireString(content.amount);
|
|
207
|
+
}
|
|
208
|
+
if (content.transaction_fee) {
|
|
209
|
+
const fee = content.transaction_fee;
|
|
210
|
+
// PR-86 myc#19: spread the source fee object first so source
|
|
211
|
+
// insertion order is preserved (consensus-critical) and any
|
|
212
|
+
// extra fields the SDK doesn't know about pass through. Then
|
|
213
|
+
// overwrite the three known carriers in place — `{...fee, ...}`
|
|
214
|
+
// does not change the position of pre-existing keys.
|
|
215
|
+
transformed.transaction_fee = {
|
|
216
|
+
...fee,
|
|
217
|
+
network_fee: toPostForkWireString(fee.network_fee),
|
|
218
|
+
rpc_fee: toPostForkWireString(fee.rpc_fee),
|
|
219
|
+
additional_fee: toPostForkWireString(fee.additional_fee),
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
if (Array.isArray(content.gcr_edits)) {
|
|
223
|
+
transformed.gcr_edits = content.gcr_edits.map(transformEditPostFork);
|
|
224
|
+
}
|
|
225
|
+
return transformed;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Re-emit a `TransactionContent` for the **pre-fork** wire shape.
|
|
229
|
+
*
|
|
230
|
+
* Coerces any `bigint` (internal) or `string` (post-fork-shaped)
|
|
231
|
+
* amount/fee fields back to JS `number` in DEM, walks `gcr_edits[]` to
|
|
232
|
+
* do the same, and otherwise passes the content through verbatim.
|
|
233
|
+
*
|
|
234
|
+
* Why this exists: SDK v3's internal arithmetic uses `bigint` OS even
|
|
235
|
+
* when talking to a pre-fork node. Without this normaliser the legacy
|
|
236
|
+
* wire would carry stringified bigints and break hash equality on the
|
|
237
|
+
* receiving side.
|
|
238
|
+
*
|
|
239
|
+
* @internal
|
|
240
|
+
*/
|
|
241
|
+
function transformToPreFork(content) {
|
|
242
|
+
const transformed = { ...content };
|
|
243
|
+
if (typeof content.amount !== "undefined" && content.amount !== null) {
|
|
244
|
+
transformed.amount = toPreForkWireNumber(content.amount);
|
|
245
|
+
}
|
|
246
|
+
if (content.transaction_fee) {
|
|
247
|
+
const fee = content.transaction_fee;
|
|
248
|
+
// PR-86 myc#19: spread to preserve source key order; see the
|
|
249
|
+
// matching block in `transformToPostFork` for the rationale.
|
|
250
|
+
transformed.transaction_fee = {
|
|
251
|
+
...fee,
|
|
252
|
+
network_fee: toPreForkWireNumber(fee.network_fee),
|
|
253
|
+
rpc_fee: toPreForkWireNumber(fee.rpc_fee),
|
|
254
|
+
additional_fee: toPreForkWireNumber(fee.additional_fee),
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
if (Array.isArray(content.gcr_edits)) {
|
|
258
|
+
transformed.gcr_edits = content.gcr_edits.map(transformEditPreFork);
|
|
259
|
+
}
|
|
260
|
+
return transformed;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Serialize transaction content for hashing/signing.
|
|
264
|
+
*
|
|
265
|
+
* This is the load-bearing wire boundary: the bytes returned here are
|
|
266
|
+
* fed into `sha256` and the resulting hash is what the keypair signs.
|
|
267
|
+
* The receiving node hashes its in-memory `TransactionContent` through
|
|
268
|
+
* its own `serializerGate.serializeTransactionContent`; if our bytes
|
|
269
|
+
* differ from the node's bytes the signature will not validate.
|
|
270
|
+
*
|
|
271
|
+
* @param content - The transaction content to serialize.
|
|
272
|
+
* @param isPostFork - `true` when the connected node has activated the
|
|
273
|
+
* `osDenomination` fork. When `false` (pre-fork or unknown), the
|
|
274
|
+
* legacy DEM-number wire shape is emitted.
|
|
275
|
+
* @returns Canonical JSON string for hashing.
|
|
276
|
+
*/
|
|
277
|
+
export function serializeTransactionContent(content, isPostFork) {
|
|
278
|
+
if (isPostFork) {
|
|
279
|
+
return JSON.stringify(transformToPostFork(content));
|
|
280
|
+
}
|
|
281
|
+
return JSON.stringify(transformToPreFork(content));
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=serializerGate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializerGate.js","sourceRoot":"","sources":["../../../src/denomination/serializerGate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAQH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEjE,uEAAuE;AACvE,wEAAwE;AACxE,mEAAmE;AACnE,4DAA4D;AAE5D;;;;;;;;;;;;;;GAcG;AACH,SAAS,UAAU,CAAC,KAA+B;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAA;IAChB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,aAAa,CAAC,KAAK,CAAC,CAAA;IAC/B,CAAC;IACD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAA;AACzB,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,aAAa,CAAC,EAAU;IAC7B,OAAO,MAAM,CAAC,EAAE,GAAG,UAAU,CAAC,CAAA;AAClC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,mBAAmB,CAAC,KAA+B;IACxD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3C,OAAO,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAA;AAC3C,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,oBAAoB,CAAC,KAA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