@dashevo/wasm-dpp2 4.2.0-beta.3 → 4.2.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/dist/dpp.compressed.js +1 -1
- package/dist/dpp.d.ts +2740 -1961
- package/dist/dpp.js +1 -1
- package/dist/raw/wasm_dpp2.d.ts +2740 -1961
- package/dist/raw/wasm_dpp2.js +436 -25
- package/dist/raw/wasm_dpp2.no_url.js +436 -25
- package/dist/raw/wasm_dpp2_bg.wasm +0 -0
- package/dist/raw/wasm_dpp2_bg.wasm.d.ts +1937 -1919
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,3 +11,38 @@ Internal build of the Dash Platform Protocol v2 WebAssembly bindings.
|
|
|
11
11
|
|
|
12
12
|
The build scripts defer to `packages/scripts/build-wasm.sh` to keep behaviour
|
|
13
13
|
consistent with other WASM packages such as `@dashevo/wasm-sdk`.
|
|
14
|
+
|
|
15
|
+
## Document ids
|
|
16
|
+
|
|
17
|
+
From protocol version 14 the id of a new document commits to the identity
|
|
18
|
+
contract nonce of its create transition (see the book, *Data Model →
|
|
19
|
+
Documents → Document ID Generation*), so a `Document` built with
|
|
20
|
+
`new Document({...})` and no `identityContractNonce` carries a **placeholder**
|
|
21
|
+
id: the entropy-only derivation of earlier versions, which consensus no longer
|
|
22
|
+
accepts.
|
|
23
|
+
|
|
24
|
+
The id becomes final where the nonce is known, and the bindings derive it for
|
|
25
|
+
you:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
const document = new Document({ properties, documentTypeName, dataContractId, ownerId });
|
|
29
|
+
|
|
30
|
+
// Derives the id from the document's entropy and the nonce, writes it onto
|
|
31
|
+
// the transition and back onto `document`: document.id equals transition.base.id.
|
|
32
|
+
const transition = new DocumentCreateTransition({ document, identityContractNonce: nonce });
|
|
33
|
+
|
|
34
|
+
// To know the id before the transition exists (another document in the same
|
|
35
|
+
// batch references it):
|
|
36
|
+
document.setIdForCreation(nonce);
|
|
37
|
+
// or derive it without a Document:
|
|
38
|
+
const idBytes = Document.generateId(documentTypeName, ownerId, dataContractId, entropy, nonce);
|
|
39
|
+
// or build the document with its final id from the start:
|
|
40
|
+
const ready = new Document({ properties, documentTypeName, dataContractId, ownerId, identityContractNonce: nonce });
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Each of these takes an optional `platformVersion` (latest by default); before
|
|
44
|
+
protocol version 14 the derivation ignores the nonce. Whatever id a `Document`
|
|
45
|
+
carried before it is passed to `DocumentCreateTransition` is replaced: the
|
|
46
|
+
transition can only carry the id consensus recomputes. For the same reason
|
|
47
|
+
`new Document({...})` refuses an explicit `id` that disagrees with the one its
|
|
48
|
+
`identityContractNonce` derives. No app needs to reimplement the hash.
|