@dashevo/wasm-dpp2 4.2.0-beta.4 → 4.2.0-beta.7

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.
@@ -2537,6 +2537,15 @@ export class ConsensusError {
2537
2537
  const ret = wasm.consensuserror_document_encryption_error_code(this.__wbg_ptr);
2538
2538
  return ret === 0 ? undefined : ret;
2539
2539
  }
2540
+ /**
2541
+ * The generatedFrom error this is, or `undefined` when it is not code
2542
+ * 10424.
2543
+ * @returns {DocumentGeneratedFromErrorCode | undefined}
2544
+ */
2545
+ get documentGeneratedFromErrorCode() {
2546
+ const ret = wasm.consensuserror_document_generated_from_error_code(this.__wbg_ptr);
2547
+ return ret === 0 ? undefined : ret;
2548
+ }
2540
2549
  /**
2541
2550
  * The immutable-property error this is, or `undefined` when it is not
2542
2551
  * code 40128.
@@ -2565,7 +2574,7 @@ export class ConsensusError {
2565
2574
  }
2566
2575
  /**
2567
2576
  * The reference-validation error this is, or `undefined` when it is
2568
- * not one of codes 40120-40125, 40131, 40135 and 40136.
2577
+ * not one of codes 40120-40125, 40131, 40135-40138, 40142 and 10423.
2569
2578
  * @returns {DocumentReferenceErrorCode | undefined}
2570
2579
  */
2571
2580
  get documentReferenceErrorCode() {
@@ -3478,7 +3487,8 @@ export class ContractUserModeration {
3478
3487
  wasm.__wbg_contractusermoderation_free(ptr, 0);
3479
3488
  }
3480
3489
  /**
3481
- * The action's name: ban, unban, suspend, unsuspend, warn, clearWarnings, deleteDocument or restoreDocument
3490
+ * The action's name: ban, unban, suspend, unsuspend, warn, clearWarnings, deleteDocument,
3491
+ * restoreDocument or changeDocumentFields
3482
3492
  * @returns {string}
3483
3493
  */
3484
3494
  get action() {
@@ -3527,7 +3537,8 @@ export class ContractUserModeration {
3527
3537
  return v1;
3528
3538
  }
3529
3539
  /**
3530
- * For a deleteDocument, the document it deletes
3540
+ * For a deleteDocument, the document it deletes, and for a changeDocumentFields, the
3541
+ * document it changes
3531
3542
  * @returns {Identifier | undefined}
3532
3543
  */
3533
3544
  get documentId() {
@@ -3535,7 +3546,8 @@ export class ContractUserModeration {
3535
3546
  return ret === 0 ? undefined : Identifier.__wrap(ret);
3536
3547
  }
3537
3548
  /**
3538
- * For a deleteDocument or a restoreDocument, the document type of its document
3549
+ * For a deleteDocument, a restoreDocument or a changeDocumentFields, the document type of
3550
+ * its document
3539
3551
  * @returns {string | undefined}
3540
3552
  */
3541
3553
  get documentTypeName() {
@@ -3547,6 +3559,19 @@ export class ContractUserModeration {
3547
3559
  }
3548
3560
  return v1;
3549
3561
  }
3562
+ /**
3563
+ * For a changeDocumentFields, the fields it sets, in the forms the constructor takes back:
3564
+ * integers as bigints, identifiers and bytes as Uint8Arrays, and `null` for a field it
3565
+ * removes
3566
+ * @returns {Record<string, unknown> | undefined}
3567
+ */
3568
+ get fields() {
3569
+ const ret = wasm.contractusermoderation_fields(this.__wbg_ptr);
3570
+ if (ret[2]) {
3571
+ throw takeFromExternrefTable0(ret[1]);
3572
+ }
3573
+ return takeFromExternrefTable0(ret[0]);
3574
+ }
3550
3575
  /**
3551
3576
  * @param {string} base64
3552
3577
  * @returns {ContractUserModeration}
@@ -3628,8 +3653,9 @@ export class ContractUserModeration {
3628
3653
  return BigInt.asUintN(64, ret);
3629
3654
  }
3630
3655
  /**
3631
- * The identity the action targets, undefined for a deleteDocument and a restoreDocument:
3632
- * they name a document, and whose it is is only known once the document is read
3656
+ * The identity the action targets, undefined for a deleteDocument, a restoreDocument and a
3657
+ * changeDocumentFields: they name a document, and whose it is is only known once the
3658
+ * document is read
3633
3659
  * @returns {Identifier | undefined}
3634
3660
  */
3635
3661
  get identityId() {
@@ -3644,7 +3670,7 @@ export class ContractUserModeration {
3644
3670
  return Identifier.__wrap(ret);
3645
3671
  }
3646
3672
  /**
3647
- * For a ban, a suspend, a warn and a deleteDocument, why
3673
+ * For a ban, a suspend, a warn, a deleteDocument and a changeDocumentFields, why
3648
3674
  * @returns {ContractModerationReason | undefined}
3649
3675
  */
3650
3676
  get reason() {
@@ -4045,6 +4071,34 @@ export class DataContract {
4045
4071
  const ptr = this.__destroy_into_raw();
4046
4072
  wasm.__wbg_datacontract_free(ptr, 0);
4047
4073
  }
4074
+ /**
4075
+ * The first `propertyConstraints` rule `document` breaks, in name order,
4076
+ * evaluated with the same code consensus runs on a create or replace: its
4077
+ * properties, its owner for `$ownerId`, and for the system times the
4078
+ * device clock in place of the block time the write will record (the
4079
+ * document's stored creation and transfer times when it has them). A
4080
+ * rule reading a block height the write records is not judged, since the
4081
+ * height is unknown until the block, and neither is a rule reading a
4082
+ * `countOf` or `sumOf` total, which only the platform reads from state
4083
+ * (a rule's `readsTotals` lists them).
4084
+ * `undefined` when it meets every rule of its document type.
4085
+ *
4086
+ * A pre-check, so an app can refuse a document before paying for a
4087
+ * transition consensus would refuse with
4088
+ * `DocumentPropertyConstraintViolatedError` (code 10422). It judges the
4089
+ * rules alone, not the document's JSON schema. Throws when the document
4090
+ * belongs to another contract or names a document type this one lacks.
4091
+ * @param {Document} document
4092
+ * @returns {DocumentPropertyConstraintViolation | undefined}
4093
+ */
4094
+ checkDocumentPropertyConstraints(document) {
4095
+ _assertClass(document, Document);
4096
+ const ret = wasm.datacontract_checkDocumentPropertyConstraints(this.__wbg_ptr, document.__wbg_ptr);
4097
+ if (ret[2]) {
4098
+ throw takeFromExternrefTable0(ret[1]);
4099
+ }
4100
+ return takeFromExternrefTable0(ret[0]);
4101
+ }
4048
4102
  /**
4049
4103
  * @returns {DataContractConfig}
4050
4104
  */
@@ -4144,6 +4198,33 @@ export class DataContract {
4144
4198
  }
4145
4199
  return takeFromExternrefTable0(ret[0]);
4146
4200
  }
4201
+ /**
4202
+ * All `propertyConstraints` rules of one document type, in name order,
4203
+ * the order consensus checks them in: each rule's name, the rule as the
4204
+ * schema declares it, every property it reads and how, and whether it
4205
+ * reads `$ownerId` (then a transfer or a purchase is judged against it
4206
+ * too).
4207
+ *
4208
+ * Returns an empty array when the document type declares none. Throws
4209
+ * when the contract has no document type by that name, so "no such
4210
+ * type" and "no rules" stay distinguishable.
4211
+ *
4212
+ * The keyword is only parsed from protocol version 14 onward. A
4213
+ * contract deserialized against an earlier platform version reports
4214
+ * none, which is exactly what consensus enforced at that version, while
4215
+ * `toJSON()` still shows the raw keyword either way.
4216
+ * @param {string} documentTypeName
4217
+ * @returns {Array<DocumentPropertyConstraint>}
4218
+ */
4219
+ documentTypePropertyConstraints(documentTypeName) {
4220
+ const ptr0 = passStringToWasm0(documentTypeName, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4221
+ const len0 = WASM_VECTOR_LEN;
4222
+ const ret = wasm.datacontract_documentTypePropertyConstraints(this.__wbg_ptr, ptr0, len0);
4223
+ if (ret[2]) {
4224
+ throw takeFromExternrefTable0(ret[1]);
4225
+ }
4226
+ return takeFromExternrefTable0(ret[0]);
4227
+ }
4147
4228
  /**
4148
4229
  * All `refersTo` declarations of one document type: its `ownerRefersTo`
4149
4230
  * or `creatorRefersTo` first, at the path `$ownerId` or `$creatorId`,
@@ -4241,6 +4322,21 @@ export class DataContract {
4241
4322
  }
4242
4323
  return takeFromExternrefTable0(ret[0]);
4243
4324
  }
4325
+ /**
4326
+ * Every document type that declares `propertyConstraints`, keyed by
4327
+ * document type name.
4328
+ *
4329
+ * Document types with no rules are omitted, so an empty `Map` means
4330
+ * "this contract declares no propertyConstraints at all".
4331
+ * @returns {Map<string, Array<DocumentPropertyConstraint>>}
4332
+ */
4333
+ get documentPropertyConstraints() {
4334
+ const ret = wasm.datacontract_document_property_constraints(this.__wbg_ptr);
4335
+ if (ret[2]) {
4336
+ throw takeFromExternrefTable0(ret[1]);
4337
+ }
4338
+ return takeFromExternrefTable0(ret[0]);
4339
+ }
4244
4340
  /**
4245
4341
  * Every document type that declares at least one reference, keyed by
4246
4342
  * document type name.
@@ -4574,6 +4670,47 @@ export class DataContract {
4574
4670
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
4575
4671
  }
4576
4672
  }
4673
+ /**
4674
+ * Whether `newContract` is an update of this contract the platform
4675
+ * accepts, judged with the code consensus runs on a data contract update
4676
+ * transition (`DataContract::validate_update`): the owner may not change,
4677
+ * the version must rise by exactly one, the config and every existing
4678
+ * document type follow their update rules, `schemaDefs` stay compatible,
4679
+ * groups and tokens are kept, and an added token's pre-programmed
4680
+ * distributions may not start before the block time.
4681
+ *
4682
+ * Returns the consensus errors a refused update would carry, each with
4683
+ * the `code` a rejected transition reaches JS with, or an empty array
4684
+ * when the update is valid. Most checks stop at the first failure, so a
4685
+ * refused update usually reports one error.
4686
+ *
4687
+ * The two contracts are compared whatever their ids; the platform judges
4688
+ * an update against the stored contract with the new contract's id.
4689
+ * Build `newContract` with full validation
4690
+ * (`DataContract.fromJSON(json, true, platformVersion)`): the transition's
4691
+ * structural checks run there, not here. No state is read, so what the
4692
+ * platform checks against state on top is not covered: that the contract
4693
+ * exists, that group members, identities named by token configurations
4694
+ * and appointed moderators exist, that references into other contracts
4695
+ * resolve, and the signature, nonce and fees.
4696
+ *
4697
+ * `blockInfo` is the block the update would be executed in; only its
4698
+ * time is read. `undefined` lets the device clock stand in for it.
4699
+ * @param {DataContract} newContract
4700
+ * @param {BlockInfo | undefined} blockInfo
4701
+ * @param {PlatformVersionLike} platformVersion
4702
+ * @returns {ConsensusError[]}
4703
+ */
4704
+ validateUpdate(newContract, blockInfo, platformVersion) {
4705
+ _assertClass(newContract, DataContract);
4706
+ const ret = wasm.datacontract_validateUpdate(this.__wbg_ptr, newContract.__wbg_ptr, blockInfo, platformVersion);
4707
+ if (ret[3]) {
4708
+ throw takeFromExternrefTable0(ret[2]);
4709
+ }
4710
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
4711
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
4712
+ return v1;
4713
+ }
4577
4714
  /**
4578
4715
  * @returns {number}
4579
4716
  */
@@ -6494,6 +6631,24 @@ export class Document {
6494
6631
  const ret = wasm.document_id(this.__wbg_ptr);
6495
6632
  return Identifier.__wrap(ret);
6496
6633
  }
6634
+ /**
6635
+ * The block time at which a moderator of the contract last wrote the fields the document
6636
+ * type keeps for its moderators (`moderatorAbilities.changeFields`); `undefined` until one
6637
+ * does.
6638
+ * @returns {bigint | undefined}
6639
+ */
6640
+ get moderatedAt() {
6641
+ const ret = wasm.document_moderated_at(this.__wbg_ptr);
6642
+ return ret[0] === 0 ? undefined : BigInt.asUintN(64, ret[1]);
6643
+ }
6644
+ /**
6645
+ * The moderator who last wrote those fields; `undefined` until one does.
6646
+ * @returns {Identifier | undefined}
6647
+ */
6648
+ get moderatedBy() {
6649
+ const ret = wasm.document_moderated_by(this.__wbg_ptr);
6650
+ return ret === 0 ? undefined : Identifier.__wrap(ret);
6651
+ }
6497
6652
  /**
6498
6653
  * @returns {Identifier}
6499
6654
  */
@@ -7451,6 +7606,35 @@ export const DocumentEncryptionErrorCode = Object.freeze({
7451
7606
  InvalidEncryptedPropertyShape: 10420, "10420": "InvalidEncryptedPropertyShape",
7452
7607
  });
7453
7608
 
7609
+ /**
7610
+ * Consensus error codes emitted by the `generatedFrom` check, which runs
7611
+ * from protocol version 14 onward wherever a document is validated, on every
7612
+ * create and replace included.
7613
+ *
7614
+ * Branch on an error's `code` against this instead of matching its message:
7615
+ *
7616
+ * ```js
7617
+ * try {
7618
+ * await sdk.documents.create({ document, identityKey, signer });
7619
+ * } catch (e) {
7620
+ * if (e.code === DocumentGeneratedFromErrorCode.DocumentPropertyNotGenerated) {
7621
+ * // a generated property was sent with a value other than what its
7622
+ * // function generates, or without its params; leaving it out lets
7623
+ * // the platform generate it
7624
+ * }
7625
+ * }
7626
+ * ```
7627
+ * @enum {10424}
7628
+ */
7629
+ export const DocumentGeneratedFromErrorCode = Object.freeze({
7630
+ /**
7631
+ * A `generatedFrom` string property holds a value other than what its
7632
+ * function generates from its params, or is present while a param is
7633
+ * absent.
7634
+ */
7635
+ DocumentPropertyNotGenerated: 10424, "10424": "DocumentPropertyNotGenerated",
7636
+ });
7637
+
7454
7638
  /**
7455
7639
  * Consensus error codes emitted by the immutable-property check on document
7456
7640
  * replaces (`immutable` / `immutableAllowSetting`, protocol version 14+).
@@ -7526,7 +7710,7 @@ export const DocumentMaxBytesErrorCode = Object.freeze({
7526
7710
  export const DocumentPropertyConstraintErrorCode = Object.freeze({
7527
7711
  /**
7528
7712
  * The written document breaks a rule of its document type's
7529
- * `propertyConstraints`: the comparison does not hold, or evaluating it
7713
+ * `propertyConstraints`: the rule does not hold, or evaluating it
7530
7714
  * overflowed, divided by zero, raised to a negative power or read a value
7531
7715
  * that is not an integer.
7532
7716
  */
@@ -7681,12 +7865,12 @@ if (Symbol.dispose) DocumentPurchaseTransition.prototype[Symbol.dispose] = Docum
7681
7865
  * }
7682
7866
  * }
7683
7867
  * ```
7684
- * @enum {40120 | 40121 | 40122 | 40123 | 40124 | 40125 | 40131 | 40135 | 40136 | 40137 | 40138}
7868
+ * @enum {40120 | 40121 | 40122 | 40123 | 40124 | 40125 | 40131 | 40135 | 40136 | 40137 | 40138 | 40142 | 10423}
7685
7869
  */
7686
7870
  export const DocumentReferenceErrorCode = Object.freeze({
7687
7871
  /**
7688
7872
  * The referenced identity, contract, token or document (permanent or
7689
- * deletable) does not exist, or a `listElement` value is not an element
7873
+ * deletable) does not exist, or a value with `inList` is not an element
7690
7874
  * of the list it must be in (or was set while the property finding the
7691
7875
  * list's document was not).
7692
7876
  */
@@ -7740,15 +7924,15 @@ export const DocumentReferenceErrorCode = Object.freeze({
7740
7924
  */
7741
7925
  ReferencedIdentityKeyRequirementNotMet: 40136, "40136": "ReferencedIdentityKeyRequirementNotMet",
7742
7926
  /**
7743
- * A `refersTo` lookup into a document type of another contract cannot
7744
- * resolve there, reported at contract registration: the named index is
7745
- * missing or not unique, the keys do not cover it exactly, or a source
7746
- * holds a different kind of value than its index property. (A lookup into
7747
- * the declaring contract is refused by the contract parse instead.)
7927
+ * A `refersTo` `findBy` into a document type of another contract cannot
7928
+ * resolve there, reported at contract registration: no unique index is
7929
+ * over exactly the properties it names, or a source holds a different
7930
+ * kind of value than the property it fills. (A `findBy` into the
7931
+ * declaring contract is refused by the contract parse instead.)
7748
7932
  */
7749
7933
  ReferencedDocumentLookupInvalid: 40137, "40137": "ReferencedDocumentLookupInvalid",
7750
7934
  /**
7751
- * A `refersTo: listElement` whose list lives in a document type of
7935
+ * A `refersTo` with `inList` whose list lives in a document type of
7752
7936
  * another contract cannot be served by it, reported at contract
7753
7937
  * registration: that type's documents can be deleted, the list is not a
7754
7938
  * stored typed array of identifiers of it, or a replace could change the
@@ -7756,6 +7940,19 @@ export const DocumentReferenceErrorCode = Object.freeze({
7756
7940
  * instead.)
7757
7941
  */
7758
7942
  ReferencedDocumentListInvalid: 40138, "40138": "ReferencedDocumentListInvalid",
7943
+ /**
7944
+ * The document a `refersTo` `findBy` function found, the commitment the
7945
+ * create reveals, exists but does not meet the reference's
7946
+ * `minimumAgeBlocks`: it was created too recently, in the same block
7947
+ * with a minimum of 1. Retry in a later block.
7948
+ */
7949
+ ReferencedDocumentRequirementNotMet: 40142, "40142": "ReferencedDocumentRequirementNotMet",
7950
+ /**
7951
+ * A create cannot reveal the preimage of a `refersTo` `findBy`
7952
+ * function: a value a param reads is absent, or a variable-length
7953
+ * value holds the one-byte separator that follows it in the preimage.
7954
+ */
7955
+ DocumentReferencePreimageInvalid: 10423, "10423": "DocumentReferencePreimageInvalid",
7759
7956
  });
7760
7957
 
7761
7958
  export class DocumentReplaceTransition {
@@ -18868,7 +19065,7 @@ export class TimeBasedDistribution {
18868
19065
  * @returns {bigint}
18869
19066
  */
18870
19067
  get interval() {
18871
- const ret = wasm.__wbg_get_blockbaseddistribution_interval(this.__wbg_ptr);
19068
+ const ret = wasm.__wbg_get_timebaseddistribution_interval(this.__wbg_ptr);
18872
19069
  return BigInt.asUintN(64, ret);
18873
19070
  }
18874
19071
  /**
@@ -25084,7 +25281,7 @@ export class VerifiedNextDistribution {
25084
25281
  * @returns {Vote}
25085
25282
  */
25086
25283
  get vote() {
25087
- const ret = wasm.__wbg_get_verifiedmasternodevote_vote(this.__wbg_ptr);
25284
+ const ret = wasm.__wbg_get_verifiednextdistribution_vote(this.__wbg_ptr);
25088
25285
  return Vote.__wrap(ret);
25089
25286
  }
25090
25287
  /**
@@ -27642,10 +27839,18 @@ function __wbg_get_imports() {
27642
27839
  const ret = arg0.call(arg1, arg2);
27643
27840
  return ret;
27644
27841
  }, arguments); },
27842
+ __wbg_consensuserror_new: function(arg0) {
27843
+ const ret = ConsensusError.__wrap(arg0);
27844
+ return ret;
27845
+ },
27645
27846
  __wbg_crypto_86f2631e91b51511: function(arg0) {
27646
27847
  const ret = arg0.crypto;
27647
27848
  return ret;
27648
27849
  },
27850
+ __wbg_defineProperty_14b96efb5b2243dc: function() { return handleError(function (arg0, arg1, arg2) {
27851
+ const ret = Reflect.defineProperty(arg0, arg1, arg2);
27852
+ return ret;
27853
+ }, arguments); },
27649
27854
  __wbg_distributionexponential_new: function(arg0) {
27650
27855
  const ret = DistributionExponential.__wrap(arg0);
27651
27856
  return ret;
@@ -27709,7 +27914,7 @@ function __wbg_get_imports() {
27709
27914
  const a = state0.a;
27710
27915
  state0.a = 0;
27711
27916
  try {
27712
- return wasm_bindgen_208f8721039e7b97___convert__closures_____invoke___wasm_bindgen_208f8721039e7b97___JsValue__wasm_bindgen_208f8721039e7b97___JsValue_____(a, state0.b, arg0, arg1);
27917
+ return wasm_bindgen_65e1d5bd0ee58ce___convert__closures_____invoke___wasm_bindgen_65e1d5bd0ee58ce___JsValue__wasm_bindgen_65e1d5bd0ee58ce___JsValue_____(a, state0.b, arg0, arg1);
27713
27918
  } finally {
27714
27919
  state0.a = a;
27715
27920
  }
@@ -27723,6 +27928,9 @@ function __wbg_get_imports() {
27723
27928
  const ret = Array.from(arg0);
27724
27929
  return ret;
27725
27930
  },
27931
+ __wbg_getRandomValues_1c61fac11405ffdc: function() { return handleError(function (arg0, arg1) {
27932
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
27933
+ }, arguments); },
27726
27934
  __wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
27727
27935
  arg0.getRandomValues(arg1);
27728
27936
  }, arguments); },
@@ -27880,6 +28088,10 @@ function __wbg_get_imports() {
27880
28088
  const ret = arg0.node;
27881
28089
  return ret;
27882
28090
  },
28091
+ __wbg_now_a3af9a2f4bbaa4d1: function() {
28092
+ const ret = Date.now();
28093
+ return ret;
28094
+ },
27883
28095
  __wbg_platformaddressinput_new: function(arg0) {
27884
28096
  const ret = PlatformAddressInput.__wrap(arg0);
27885
28097
  return ret;
@@ -28106,8 +28318,8 @@ function __wbg_get_imports() {
28106
28318
  };
28107
28319
  }
28108
28320
 
28109
- function wasm_bindgen_208f8721039e7b97___convert__closures_____invoke___wasm_bindgen_208f8721039e7b97___JsValue__wasm_bindgen_208f8721039e7b97___JsValue_____(arg0, arg1, arg2, arg3) {
28110
- wasm.wasm_bindgen_208f8721039e7b97___convert__closures_____invoke___wasm_bindgen_208f8721039e7b97___JsValue__wasm_bindgen_208f8721039e7b97___JsValue_____(arg0, arg1, arg2, arg3);
28321
+ function wasm_bindgen_65e1d5bd0ee58ce___convert__closures_____invoke___wasm_bindgen_65e1d5bd0ee58ce___JsValue__wasm_bindgen_65e1d5bd0ee58ce___JsValue_____(arg0, arg1, arg2, arg3) {
28322
+ wasm.wasm_bindgen_65e1d5bd0ee58ce___convert__closures_____invoke___wasm_bindgen_65e1d5bd0ee58ce___JsValue__wasm_bindgen_65e1d5bd0ee58ce___JsValue_____(arg0, arg1, arg2, arg3);
28111
28323
  }
28112
28324
 
28113
28325
  const ActionTakerFinalization = (typeof FinalizationRegistry === 'undefined')