@dashevo/wasm-dpp 1.8.0 → 2.0.0-rc.1

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 (95) hide show
  1. package/.eslintrc +3 -0
  2. package/Cargo.toml +10 -6
  3. package/README.md +1 -1
  4. package/dist/wasm/wasm_dpp.d.ts +2045 -1114
  5. package/dist/wasm/wasm_dpp.js +740 -222
  6. package/dist/wasm/wasm_dpp_bg.js +1 -1
  7. package/lib/test/fixtures/getIdentityCreditTransferTransitionFixture.js +1 -1
  8. package/lib/test/fixtures/getIdentityFixture.js +1 -1
  9. package/lib/wasm/wasm_dpp.d.ts +2045 -1114
  10. package/package.json +6 -6
  11. package/scripts/build-wasm.sh +1 -1
  12. package/src/data_contract/data_contract.rs +17 -24
  13. package/src/data_contract/mod.rs +1 -0
  14. package/src/data_contract/state_transition/data_contract_create_transition/mod.rs +21 -0
  15. package/src/data_contract/state_transition/data_contract_update_transition/mod.rs +25 -0
  16. package/src/data_contract/tokens.rs +60 -0
  17. package/src/data_contract_factory/mod.rs +1 -1
  18. package/src/document/document_facade.rs +3 -3
  19. package/src/document/errors/document_already_exists_error.rs +1 -1
  20. package/src/document/errors/document_not_provided_error.rs +1 -1
  21. package/src/document/errors/invalid_document_action_error.rs +2 -2
  22. package/src/document/extended_document.rs +3 -5
  23. package/src/document/factory.rs +25 -10
  24. package/src/document/mod.rs +6 -8
  25. package/src/document/state_transition/batch_transition/batched_transition/mod.rs +18 -0
  26. package/src/document/state_transition/{document_batch_transition → batch_transition}/document_transition/document_create_transition.rs +45 -3
  27. package/src/document/state_transition/{document_batch_transition → batch_transition}/document_transition/document_delete_transition.rs +23 -4
  28. package/src/document/state_transition/{document_batch_transition → batch_transition}/document_transition/document_replace_transition.rs +24 -5
  29. package/src/document/state_transition/{document_batch_transition → batch_transition}/document_transition/mod.rs +97 -14
  30. package/src/document/state_transition/{document_batch_transition → batch_transition}/mod.rs +44 -29
  31. package/src/document/state_transition/batch_transition/token_transition/burn.rs +12 -0
  32. package/src/document/state_transition/batch_transition/token_transition/claim.rs +12 -0
  33. package/src/document/state_transition/batch_transition/token_transition/config.rs +12 -0
  34. package/src/document/state_transition/batch_transition/token_transition/destroy.rs +22 -0
  35. package/src/document/state_transition/batch_transition/token_transition/direct_purchase.rs +12 -0
  36. package/src/document/state_transition/batch_transition/token_transition/emergency_action.rs +12 -0
  37. package/src/document/state_transition/batch_transition/token_transition/freeze.rs +22 -0
  38. package/src/document/state_transition/batch_transition/token_transition/mint.rs +31 -0
  39. package/src/document/state_transition/batch_transition/token_transition/mod.rs +154 -0
  40. package/src/document/state_transition/batch_transition/token_transition/set_price_for_direct_purchase.rs +14 -0
  41. package/src/document/state_transition/batch_transition/token_transition/transfer.rs +22 -0
  42. package/src/document/state_transition/batch_transition/token_transition/unfreeze.rs +22 -0
  43. package/src/document/state_transition/mod.rs +1 -1
  44. package/src/errors/consensus/basic/identity/identity_insufficient_balance_error.rs +2 -2
  45. package/src/errors/consensus/basic/state_transition/missing_state_transition_type_error.rs +6 -0
  46. package/src/errors/consensus/consensus_error.rs +212 -1
  47. package/src/errors/consensus/fee/balance_is_not_enough_error.rs +4 -4
  48. package/src/errors/consensus/state/identity/invalid_identity_contract_nonce_error.rs +1 -1
  49. package/src/errors/value_error.rs +1 -0
  50. package/src/identity/identity.rs +14 -14
  51. package/src/identity/mod.rs +1 -0
  52. package/src/identity/state_transition/identity_create_transition/mod.rs +2 -2
  53. package/src/identity/state_transition/identity_create_transition/{identity_create_transition.rs → transition.rs} +10 -0
  54. package/src/identity/state_transition/identity_credit_transfer_transition/transition.rs +31 -6
  55. package/src/identity/state_transition/identity_credit_withdrawal_transition/transition.rs +15 -0
  56. package/src/identity/state_transition/identity_public_key_transitions.rs +2 -2
  57. package/src/identity/state_transition/identity_topup_transition/mod.rs +2 -2
  58. package/src/identity/state_transition/identity_topup_transition/{identity_topup_transition.rs → transition.rs} +10 -0
  59. package/src/identity/state_transition/identity_update_transition/mod.rs +2 -2
  60. package/src/identity/state_transition/identity_update_transition/to_object.rs +2 -2
  61. package/src/identity/state_transition/identity_update_transition/{identity_update_transition.rs → transition.rs} +29 -4
  62. package/src/identity/state_transition/transition_types.rs +1 -1
  63. package/src/metadata.rs +16 -27
  64. package/src/state_transition/state_transition_factory.rs +2 -4
  65. package/src/utils.rs +4 -2
  66. package/src/voting/state_transition/masternode_vote_transition/mod.rs +75 -50
  67. package/src/voting/state_transition/masternode_vote_transition/to_object.rs +1 -0
  68. package/test/integration/document/Document.spec.js +2 -7
  69. package/test/integration/document/DocumentFacade.spec.js +4 -4
  70. package/test/integration/identity/IdentityFacade.spec.js +5 -10
  71. package/test/integration/identity/stateTransition/IdentityUpdateTransition/validation/state/validateIdentityUpdateTransitionStateFactory.spec.js +4 -4
  72. package/test/integration/identity/stateTransition/assetLockProof/chain/validateChainAssetLockProofStructureFactory.spec.js +3 -3
  73. package/test/integration/identity/stateTransition/assetLockProof/fetchAssetLockTransactionOutputFactory.spec.js +1 -1
  74. package/test/integration/stateTransition/StateTransitionFacade.spec.js +3 -3
  75. package/test/unit/Metadata.spec.js +8 -23
  76. package/test/unit/dataContract/DataContract.spec.js +1 -18
  77. package/test/unit/dataContract/stateTransition/DataContractCreateTransition/DataContractCreateTransition.spec.js +1 -1
  78. package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js +1 -1
  79. package/test/unit/document/Document.spec.js +4 -7
  80. package/test/unit/document/DocumentFactory.spec.js +2 -2
  81. package/test/unit/identity/Identity.spec.js +15 -35
  82. package/test/unit/identity/IdentityFactory.spec.js +3 -3
  83. package/test/unit/identity/stateTransition/IdentityUpdateTransition/IdentityUpdateTransition.spec.js +2 -2
  84. package/test/unit/identity/stateTransition/identityCreditTransferTransition/identityCreditTransferTransition.spec.js +1 -1
  85. /package/src/data_contract_factory/{data_contract_factory.rs → factory.rs} +0 -0
  86. /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/basic/find_duplicates_by_id.rs +0 -0
  87. /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/basic/find_duplicates_by_indices.rs +0 -0
  88. /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/basic/mod.rs +0 -0
  89. /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/basic/validate_documents_batch_transition_basic.rs +0 -0
  90. /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/basic/validate_partial_compound_indices.rs +0 -0
  91. /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/mod.rs +0 -0
  92. /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/state/fetch_extended_documents.rs +0 -0
  93. /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/state/mod.rs +0 -0
  94. /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/state/validate_documents_batch_transitions_state.rs +0 -0
  95. /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/state/validate_documents_uniqueness_by_indices.rs +0 -0
package/src/metadata.rs CHANGED
@@ -3,10 +3,8 @@
3
3
  pub use serde::Serialize;
4
4
  use wasm_bindgen::prelude::*;
5
5
 
6
- use crate::utils::ToSerdeJSONExt;
7
6
  use dpp::metadata::Metadata;
8
7
  use dpp::util::deserializer::ProtocolVersion;
9
- use dpp::util::json_value::JsonValueExt;
10
8
 
11
9
  #[wasm_bindgen(js_name=Metadata)]
12
10
  #[derive(Clone, Debug)]
@@ -34,25 +32,16 @@ impl Into<Metadata> for MetadataWasm {
34
32
  #[wasm_bindgen(js_class=Metadata)]
35
33
  impl MetadataWasm {
36
34
  #[wasm_bindgen(constructor)]
37
- pub fn new(options: JsValue) -> Result<MetadataWasm, JsValue> {
38
- let metadata_options = options.with_serde_to_json_value()?;
39
- let block_height = metadata_options
40
- .get_f64("blockHeight")
41
- .map_err(|e| JsError::new(&e.to_string()))?;
42
- let core_chain_locked_height = metadata_options
43
- .get_f64("coreChainLockedHeight")
44
- .map_err(|e| JsError::new(&e.to_string()))?;
45
- let time_ms = metadata_options
46
- .get_f64("timeMs")
47
- .map_err(|e| JsError::new(&e.to_string()))?;
48
- let protocol_version = metadata_options
49
- .get_f64("protocolVersion")
50
- .map_err(|e| JsError::new(&e.to_string()))?;
51
-
35
+ pub fn new(
36
+ block_height: u64,
37
+ core_chain_locked_height: u32,
38
+ time_ms: u64,
39
+ protocol_version: u32,
40
+ ) -> Result<MetadataWasm, JsValue> {
52
41
  let inner = Metadata {
53
- block_height: block_height as u64,
42
+ block_height,
54
43
  core_chain_locked_height: core_chain_locked_height as u64,
55
- time_ms: time_ms as u64,
44
+ time_ms,
56
45
  protocol_version: protocol_version as u64 as ProtocolVersion,
57
46
  };
58
47
  Ok(inner.into())
@@ -77,22 +66,22 @@ impl MetadataWasm {
77
66
  }
78
67
 
79
68
  #[wasm_bindgen(js_name=getBlockHeight)]
80
- pub fn block_height(&self) -> f64 {
81
- self.0.block_height as f64
69
+ pub fn block_height(&self) -> u64 {
70
+ self.0.block_height
82
71
  }
83
72
 
84
73
  #[wasm_bindgen(js_name=getCoreChainLockedHeight)]
85
- pub fn core_chain_locked_height(&self) -> f64 {
86
- self.0.core_chain_locked_height as f64
74
+ pub fn core_chain_locked_height(&self) -> u32 {
75
+ self.0.core_chain_locked_height as u32
87
76
  }
88
77
 
89
78
  #[wasm_bindgen(js_name=getTimeMs)]
90
- pub fn time_ms(&self) -> f64 {
91
- self.0.time_ms as f64
79
+ pub fn time_ms(&self) -> u64 {
80
+ self.0.time_ms
92
81
  }
93
82
 
94
83
  #[wasm_bindgen(js_name=getProtocolVersion)]
95
- pub fn protocol_version(&self) -> f64 {
96
- self.0.protocol_version as f64
84
+ pub fn protocol_version(&self) -> u32 {
85
+ self.0.protocol_version
97
86
  }
98
87
  }
@@ -1,5 +1,5 @@
1
+ use crate::batch_transition::BatchTransitionWasm;
1
2
  use crate::data_contract::{DataContractCreateTransitionWasm, DataContractUpdateTransitionWasm};
2
- use crate::document_batch_transition::DocumentsBatchTransitionWasm;
3
3
  use crate::errors::from_dpp_err;
4
4
  use crate::identity::state_transition::{
5
5
  IdentityCreateTransitionWasm, IdentityCreditTransferTransitionWasm,
@@ -56,9 +56,7 @@ impl StateTransitionFactoryWasm {
56
56
  StateTransition::IdentityCreditWithdrawal(st) => {
57
57
  Ok(IdentityCreditWithdrawalTransitionWasm::from(st).into())
58
58
  }
59
- StateTransition::DocumentsBatch(st) => {
60
- Ok(DocumentsBatchTransitionWasm::from(st).into())
61
- }
59
+ StateTransition::Batch(st) => Ok(BatchTransitionWasm::from(st).into()),
62
60
  StateTransition::MasternodeVote(st) => {
63
61
  Ok(MasternodeVoteTransitionWasm::from(st).into())
64
62
  }
package/src/utils.rs CHANGED
@@ -22,9 +22,9 @@ pub trait ToSerdeJSONExt {
22
22
  /// Converts the `JsValue` into `platform::Value`. It's an expensive conversion,
23
23
  /// as `JsValue` must be stringified first
24
24
  fn with_serde_to_platform_value_map(&self) -> Result<BTreeMap<String, Value>, JsValue>;
25
- fn with_serde_into<D: DeserializeOwned>(&self) -> Result<D, JsValue>
25
+ fn with_serde_into<D>(&self) -> Result<D, JsValue>
26
26
  where
27
- D: for<'de> serde::de::Deserialize<'de> + 'static;
27
+ D: DeserializeOwned + for<'de> serde::de::Deserialize<'de> + 'static;
28
28
  }
29
29
 
30
30
  impl ToSerdeJSONExt for JsValue {
@@ -284,8 +284,10 @@ pub fn convert_number_to_u64(js_number: js_sys::Number) -> Result<u64, anyhow::E
284
284
  pub(crate) trait Inner {
285
285
  type InnerItem;
286
286
 
287
+ #[allow(dead_code)]
287
288
  fn into_inner(self) -> Self::InnerItem;
288
289
  fn inner(&self) -> &Self::InnerItem;
290
+ #[allow(dead_code)]
289
291
  fn inner_mut(&mut self) -> &mut Self::InnerItem;
290
292
  }
291
293
 
@@ -220,60 +220,85 @@ impl MasternodeVoteTransitionWasm {
220
220
  self.0.is_voting_state_transition()
221
221
  }
222
222
 
223
+ #[wasm_bindgen(js_name=getUserFeeIncrease)]
224
+ pub fn get_user_fee_increase(&self) -> u16 {
225
+ self.0.user_fee_increase()
226
+ }
227
+
228
+ #[wasm_bindgen(js_name=setUserFeeIncrease)]
229
+ pub fn set_user_fee_increase(&mut self, user_fee_increase: u16) {
230
+ self.0.set_user_fee_increase(user_fee_increase);
231
+ }
232
+
233
+ #[wasm_bindgen(js_name=getIdentityContractNonce)]
234
+ pub fn get_identity_nonce(&self) -> u64 {
235
+ self.0.nonce()
236
+ }
237
+
223
238
  #[wasm_bindgen(js_name=getContestedDocumentResourceVotePoll)]
224
239
  pub fn contested_document_resource_vote_poll(&self) -> Option<Object> {
225
240
  match self.0.vote() {
226
- Vote::ResourceVote(vote) => match vote.vote_poll() {
227
- VotePoll::ContestedDocumentResourceVotePoll(
228
- contested_document_resource_vote_poll,
229
- ) => {
230
- let js_object = Object::new();
231
-
232
- let contract_id = IdentifierWrapper::from(
233
- contested_document_resource_vote_poll.contract_id.clone(),
234
- );
235
-
236
- Reflect::set(&js_object, &"contractId".into(), &contract_id.into()).unwrap();
237
- Reflect::set(
238
- &js_object,
239
- &"documentTypeName".into(),
240
- &contested_document_resource_vote_poll
241
- .document_type_name
242
- .clone()
243
- .into(),
244
- )
245
- .unwrap();
246
- Reflect::set(
247
- &js_object,
248
- &"indexName".into(),
249
- &contested_document_resource_vote_poll
250
- .index_name
251
- .clone()
252
- .into(),
253
- )
254
- .unwrap();
255
-
256
- let config = bincode::config::standard()
257
- .with_big_endian()
258
- .with_no_limit();
259
-
260
- let serialized_index_values = contested_document_resource_vote_poll
261
- .index_values
262
- .iter()
263
- .map(|value| {
264
- JsValue::from(Buffer::from_bytes_owned(
265
- bincode::encode_to_vec(value, config)
266
- .expect("expected to encode value in path"),
267
- ))
268
- });
269
-
270
- let js_array = Array::from_iter(serialized_index_values);
271
-
272
- Reflect::set(&js_object, &"indexValues".into(), &js_array.into()).unwrap();
273
-
274
- Some(js_object)
241
+ Vote::ResourceVote(vote) => {
242
+ let js_object = Object::new();
243
+
244
+ Reflect::set(
245
+ &js_object,
246
+ &"choice".into(),
247
+ &vote.resource_vote_choice().clone().to_string().into(),
248
+ )
249
+ .unwrap();
250
+
251
+ match vote.vote_poll() {
252
+ VotePoll::ContestedDocumentResourceVotePoll(
253
+ contested_document_resource_vote_poll,
254
+ ) => {
255
+ let contract_id = IdentifierWrapper::from(
256
+ contested_document_resource_vote_poll.contract_id,
257
+ );
258
+
259
+ Reflect::set(&js_object, &"contractId".into(), &contract_id.into())
260
+ .unwrap();
261
+ Reflect::set(
262
+ &js_object,
263
+ &"documentTypeName".into(),
264
+ &contested_document_resource_vote_poll
265
+ .document_type_name
266
+ .clone()
267
+ .into(),
268
+ )
269
+ .unwrap();
270
+ Reflect::set(
271
+ &js_object,
272
+ &"indexName".into(),
273
+ &contested_document_resource_vote_poll
274
+ .index_name
275
+ .clone()
276
+ .into(),
277
+ )
278
+ .unwrap();
279
+
280
+ let config = bincode::config::standard()
281
+ .with_big_endian()
282
+ .with_no_limit();
283
+
284
+ let serialized_index_values = contested_document_resource_vote_poll
285
+ .index_values
286
+ .iter()
287
+ .map(|value| {
288
+ JsValue::from(Buffer::from_bytes_owned(
289
+ bincode::encode_to_vec(value, config)
290
+ .expect("expected to encode value in path"),
291
+ ))
292
+ });
293
+
294
+ let js_array = Array::from_iter(serialized_index_values);
295
+
296
+ Reflect::set(&js_object, &"indexValues".into(), &js_array.into()).unwrap();
297
+
298
+ Some(js_object)
299
+ }
275
300
  }
276
- },
301
+ }
277
302
  }
278
303
  }
279
304
 
@@ -18,6 +18,7 @@ pub struct ToObjectOptions {
18
18
  pub struct ToObject {
19
19
  pub transition_type: u8,
20
20
  pub pro_tx_hash: Identifier,
21
+ #[allow(dead_code)]
21
22
  pub vote: Vote,
22
23
  pub signature: Option<Vec<u8>>,
23
24
  pub signature_public_key_id: Option<KeyID>,
@@ -85,7 +85,7 @@ describe('ExtendedDocument', () => {
85
85
  expect(result.$id.toBuffer()).to.deep.equal(document.getId().toBuffer());
86
86
  expect(result.$ownerId.toBuffer()).to.deep.equal(document.getOwnerId().toBuffer());
87
87
  expect(result.identifierField.toBuffer()).to.deep.equal(document.get('identifierField').toBuffer());
88
- expect(result.$revision).to.deep.equal(document.getRevision());
88
+ expect(BigInt(result.$revision)).to.deep.equal(document.getRevision());
89
89
  expect(result.$type).to.deep.equal(document.getType());
90
90
  expect(result.byteArrayField).to.deep.equal(document.get('byteArrayField'));
91
91
  });
@@ -93,12 +93,7 @@ describe('ExtendedDocument', () => {
93
93
 
94
94
  describe('#setMetadata', () => {
95
95
  it('should set metadata - Rust', () => {
96
- const otherMetadata = new Metadata({
97
- blockHeight: 43,
98
- coreChainLockedHeight: 1,
99
- timeMs: 100,
100
- protocolVersion: 2,
101
- });
96
+ const otherMetadata = new Metadata(BigInt(43), 1, BigInt(100), 2);
102
97
  document.setMetadata(otherMetadata);
103
98
 
104
99
  expect(document.getMetadata().toObject()).to.deep.equal(otherMetadata.toObject());
@@ -8,7 +8,7 @@ const {
8
8
  ExtendedDocument,
9
9
  DataContract,
10
10
  ValidationResult,
11
- DocumentsBatchTransition,
11
+ BatchTransition,
12
12
  DashPlatformProtocol,
13
13
  DataContractNotPresentError,
14
14
  } = require('../../..');
@@ -95,7 +95,7 @@ describe('DocumentFacade', () => {
95
95
  });
96
96
 
97
97
  describe('createStateTransition', () => {
98
- it('should create DocumentsBatchTransition with passed documents - Rust', () => {
98
+ it('should create BatchTransition with passed documents - Rust', () => {
99
99
  const identityId = documents[0].getOwnerId();
100
100
  const contractId = documents[0].getDataContractId();
101
101
 
@@ -103,11 +103,11 @@ describe('DocumentFacade', () => {
103
103
  create: documents,
104
104
  }, {
105
105
  [identityId.toString()]: {
106
- [contractId.toString()]: 1,
106
+ [contractId.toString()]: '1',
107
107
  },
108
108
  });
109
109
 
110
- expect(result).to.be.instanceOf(DocumentsBatchTransition);
110
+ expect(result).to.be.instanceOf(BatchTransition);
111
111
  // expect(result.getTransitions().map((t) => t.toObject()))
112
112
  // .has.deep.members(getDocumentTransitionsFixture({
113
113
  // create: documentsJs,
@@ -32,7 +32,7 @@ describe('IdentityFacade', () => {
32
32
  chainAssetLockProof = new ChainAssetLockProof(chainAssetLockProofJS.toObject());
33
33
 
34
34
  identity = await getIdentityFixture(instantAssetLockProof.createIdentifier());
35
- identity.setBalance(0);
35
+ identity.setBalance(BigInt(0));
36
36
  });
37
37
 
38
38
  describe('#create', () => {
@@ -62,16 +62,11 @@ describe('IdentityFacade', () => {
62
62
 
63
63
  describe('#createFromBuffer', () => {
64
64
  it('should create Identity from a Buffer', () => {
65
- let result;
66
- try {
67
- result = dpp.identity.createFromBuffer(identity.toBuffer());
68
- } catch (e) {
69
- console.dir(e.getErrors()[0].toString());
70
- }
65
+ const deserialized = dpp.identity.createFromBuffer(identity.toBuffer());
71
66
 
72
- expect(result).to.be.an.instanceOf(Identity);
67
+ expect(deserialized).to.be.an.instanceOf(Identity);
73
68
 
74
- expect(result.toObject()).to.deep.equal(identity.toObject());
69
+ expect(deserialized.toObject()).to.deep.equal(identity.toObject());
75
70
  });
76
71
  });
77
72
 
@@ -186,7 +181,7 @@ describe('IdentityFacade', () => {
186
181
  expect(stateTransition.getIdentityId().toBuffer())
187
182
  .to.be.deep.equal(identity.getId().toBuffer());
188
183
  expect(stateTransition.getRevision()).to.equal(
189
- identity.getRevision() + 1,
184
+ identity.getRevision() + BigInt(1),
190
185
  );
191
186
  expect(
192
187
  stateTransition.getPublicKeysToAdd().map((pk) => pk.toObject()),
@@ -124,7 +124,7 @@ describe.skip('validateIdentityUpdateTransitionStateFactory', () => {
124
124
  expect(error.getId()).to.equal(3);
125
125
  });
126
126
 
127
- it('should pass when disabling public key', async function () {
127
+ it('should pass when disabling public key', async function it() {
128
128
  stateTransition.setPublicKeyIdsToDisable([1]);
129
129
  stateTransition.setPublicKeysToAdd(undefined);
130
130
 
@@ -143,7 +143,7 @@ describe.skip('validateIdentityUpdateTransitionStateFactory', () => {
143
143
  .to.be.calledOnce();
144
144
  });
145
145
 
146
- it('should pass when adding public key', async function () {
146
+ it('should pass when adding public key', async function it() {
147
147
  stateTransition.setPublicKeyIdsToDisable(undefined);
148
148
 
149
149
  const result = await validateIdentityUpdateTransitionState(stateTransition);
@@ -161,7 +161,7 @@ describe.skip('validateIdentityUpdateTransitionStateFactory', () => {
161
161
  .to.not.be.called();
162
162
  });
163
163
 
164
- it('should pass when both adding and disabling public keys', async function () {
164
+ it('should pass when both adding and disabling public keys', async function it() {
165
165
  stateTransition.setPublicKeyIdsToDisable([1]);
166
166
 
167
167
  const result = await validateIdentityUpdateTransitionState(stateTransition);
@@ -227,7 +227,7 @@ describe.skip('validateIdentityUpdateTransitionStateFactory', () => {
227
227
  // );
228
228
  });
229
229
 
230
- it('should return valid result on dry run', async function () {
230
+ it('should return valid result on dry run', async function it() {
231
231
  stateTransition.setPublicKeyIdsToDisable([3]);
232
232
 
233
233
  // Make code that executes after dry run check to fail
@@ -307,7 +307,7 @@ describe.skip('validateChainAssetLockProofStructureFactory', () => {
307
307
  expect(stateRepositoryMock.fetchLatestPlatformCoreChainLockedHeight).to.not.be.called();
308
308
  });
309
309
 
310
- it('should point to existing transaction', async function () {
310
+ it('should point to existing transaction', async function it() {
311
311
  stateRepositoryMock.fetchTransaction.resolves(null);
312
312
 
313
313
  const result = await validateChainAssetLockProofStructure(
@@ -353,7 +353,7 @@ describe.skip('validateChainAssetLockProofStructureFactory', () => {
353
353
  );
354
354
  });
355
355
 
356
- it('should point to transaction from block lower than core chain locked height', async function () {
356
+ it('should point to transaction from block lower than core chain locked height', async function it() {
357
357
  rawProof.coreChainLockedHeight = 41;
358
358
  stateRepositoryMock.fetchLatestPlatformCoreChainLockedHeight.resolves(41);
359
359
 
@@ -378,7 +378,7 @@ describe.skip('validateChainAssetLockProofStructureFactory', () => {
378
378
  });
379
379
  });
380
380
 
381
- it('should return valid result', async function () {
381
+ it('should return valid result', async function it() {
382
382
  const result = await validateChainAssetLockProofStructure(
383
383
  rawProof,
384
384
  executionContext,
@@ -89,7 +89,7 @@ describe.skip('fetchAssetLockTransactionOutputFactory', () => {
89
89
  ([output] = transaction.outputs);
90
90
  });
91
91
 
92
- it('should fetch output from state repository', async function () {
92
+ it('should fetch output from state repository', async function it() {
93
93
  const assetLockTransactionOutput = await fetchAssetLockTransactionOutput(
94
94
  assetLockProofFixture,
95
95
  executionContext,
@@ -102,14 +102,14 @@ describe('StateTransitionFacade', () => {
102
102
  create: documents,
103
103
  }, {
104
104
  [documents[0].getOwnerId().toString()]: {
105
- [documents[0].getDataContractId().toString()]: 0,
105
+ [documents[0].getDataContractId().toString()]: '0',
106
106
  },
107
107
  });
108
108
  await documentsBatchTransition.sign(identityPublicKey, privateKey);
109
109
 
110
110
  identity = await getIdentityFixture();
111
111
  identity.setId(await generateRandomIdentifierAsync());
112
- identity.setBalance(10000000);
112
+ identity.setBalance(BigInt(10000000));
113
113
  identity.setPublicKeys([identityPublicKey]);
114
114
 
115
115
  dpp = new DashPlatformProtocol(
@@ -171,7 +171,7 @@ describe('StateTransitionFacade', () => {
171
171
  });
172
172
 
173
173
  it('should return invalid result if not enough balance to pay fee for State Transition', async () => {
174
- identity.setBalance(0);
174
+ identity.setBalance(BigInt(0));
175
175
  stateRepositoryMock.fetchIdentityBalance.resolves(0);
176
176
  const result = await dpp.stateTransition.validate(
177
177
  dataContractCreateTransition,
@@ -9,41 +9,26 @@ describe('Metadata', () => {
9
9
 
10
10
  describe('#constructor', () => {
11
11
  it('should set height and core chain-locked height', () => {
12
- const result = new Metadata({
13
- blockHeight: 42,
14
- coreChainLockedHeight: 1,
15
- timeMs: 100,
16
- protocolVersion: 2,
17
- });
18
-
19
- expect(result.getBlockHeight()).to.equal(42);
12
+ const result = new Metadata(BigInt(42), 1, BigInt(100), 2);
13
+
14
+ expect(result.getBlockHeight()).to.equal(BigInt(42));
20
15
  expect(result.getCoreChainLockedHeight()).to.equal(1);
21
- expect(result.getTimeMs()).to.equal(100);
16
+ expect(result.getTimeMs()).to.equal(BigInt(100));
22
17
  expect(result.getProtocolVersion()).to.equal(2);
23
18
  });
24
19
  });
25
20
 
26
21
  describe('#getBlockHeight', () => {
27
22
  it('should get block height', () => {
28
- const result = new Metadata({
29
- blockHeight: 42,
30
- coreChainLockedHeight: 1,
31
- timeMs: 100,
32
- protocolVersion: 2,
33
- });
34
-
35
- expect(result.getBlockHeight()).to.equal(42);
23
+ const result = new Metadata(BigInt(42), 1, BigInt(100), 2);
24
+
25
+ expect(result.getBlockHeight()).to.equal(BigInt(42));
36
26
  });
37
27
  });
38
28
 
39
29
  describe('#getCoreChainLockedHeight', () => {
40
30
  it('should get core chain-locked height', () => {
41
- const result = new Metadata({
42
- blockHeight: 1,
43
- coreChainLockedHeight: 42,
44
- timeMs: 100,
45
- protocolVersion: 2,
46
- });
31
+ const result = new Metadata(BigInt(1), 42, BigInt(100), 2);
47
32
 
48
33
  expect(result.getCoreChainLockedHeight()).to.equal(42);
49
34
  });
@@ -16,11 +16,10 @@ describe('DataContract', () => {
16
16
 
17
17
  let DataContract;
18
18
  let Identifier;
19
- let Metadata;
20
19
 
21
20
  before(async () => {
22
21
  ({
23
- DataContract, Identifier, Metadata,
22
+ DataContract, Identifier,
24
23
  } = await loadWasmDpp());
25
24
  });
26
25
 
@@ -298,22 +297,6 @@ describe('DataContract', () => {
298
297
  });
299
298
  });
300
299
 
301
- describe('#setMetadata', () => {
302
- it('should set metadata', () => {
303
- const otherMetadata = new Metadata({
304
- blockHeight: 43,
305
- coreChainLockedHeight: 1,
306
- timeMs: 100,
307
- protocolVersion: 2,
308
- });
309
- const otherMetadataToObject = otherMetadata.toObject();
310
-
311
- dataContract.setMetadata(otherMetadata);
312
-
313
- expect(dataContract.getMetadata().toObject()).to.deep.equal(otherMetadataToObject);
314
- });
315
- });
316
-
317
300
  describe.skip('#setConfig', () => {
318
301
  it('should set config', () => {
319
302
  const config = {
@@ -66,7 +66,7 @@ describe('DataContractCreateTransition', () => {
66
66
  it('should return serialized State Transition', () => {
67
67
  const result = stateTransition.toBuffer();
68
68
  expect(result).to.be.instanceOf(Buffer);
69
- expect(result).to.have.lengthOf(2359);
69
+ expect(result).to.have.lengthOf(2360);
70
70
  });
71
71
 
72
72
  it('should be able to restore contract config from bytes', () => {
@@ -65,7 +65,7 @@ describe('DataContractUpdateTransition', () => {
65
65
  it('should return serialized State Transition', () => {
66
66
  const result = stateTransition.toBuffer();
67
67
  expect(result).to.be.instanceOf(Buffer);
68
- expect(result).to.have.lengthOf(2359);
68
+ expect(result).to.have.lengthOf(2360);
69
69
  });
70
70
 
71
71
  it('should be able to restore contract config from bytes', () => {
@@ -1,5 +1,3 @@
1
- const crypto = require('crypto');
2
-
3
1
  const generateRandomIdentifierAsync = require('../../../lib/test/utils/generateRandomIdentifierAsync');
4
2
  const { default: loadWasmDpp, DocumentCreateTransition } = require('../../..');
5
3
  const { getLatestProtocolVersion } = require('../../..');
@@ -29,7 +27,6 @@ describe('Document', () => {
29
27
  const ownerId = await generateRandomIdentifierAsync();
30
28
  const dataContractFactory = new DataContractFactory(
31
29
  1,
32
- { generate: () => crypto.randomBytes(32) },
33
30
  );
34
31
 
35
32
  const rawDataContract = {
@@ -83,7 +80,7 @@ describe('Document', () => {
83
80
  $type: 'test',
84
81
  $dataContractId: dataContract.getId(),
85
82
  $ownerId: ownerId,
86
- $revision: DocumentCreateTransition.INITIAL_REVISION,
83
+ $revision: Number(DocumentCreateTransition.INITIAL_REVISION.toString()),
87
84
  $createdAt: now,
88
85
  $createdAtBlockHeight: 1,
89
86
  $createdAtCoreBlockHeight: 1,
@@ -101,7 +98,7 @@ describe('Document', () => {
101
98
  $type: 'test',
102
99
  $dataContractId: dataContract.getId().toBuffer(),
103
100
  $ownerId: ownerId.toBuffer(),
104
- $revision: DocumentCreateTransition.INITIAL_REVISION,
101
+ $revision: Number(DocumentCreateTransition.INITIAL_REVISION.toString()),
105
102
  $createdAt: now,
106
103
  $createdAtBlockHeight: 1,
107
104
  $createdAtCoreBlockHeight: 1,
@@ -261,7 +258,7 @@ describe('Document', () => {
261
258
 
262
259
  document = new ExtendedDocument(rawDocument, dataContract);
263
260
 
264
- expect(document.getRevision()).to.equal(rawDocument.$revision);
261
+ expect(document.getRevision()).to.equal(BigInt(rawDocument.$revision));
265
262
  });
266
263
 
267
264
  it('should create Document with $createdAt and data if present', async () => {
@@ -342,7 +339,7 @@ describe('Document', () => {
342
339
 
343
340
  describe('#setRevision/#getRevision', () => {
344
341
  it('should set $revision and get $revision', () => {
345
- const revision = 5;
342
+ const revision = BigInt(5);
346
343
 
347
344
  document.setRevision(revision);
348
345
 
@@ -294,7 +294,7 @@ describe('DocumentFactory', () => {
294
294
  replace: [newDocument],
295
295
  }, {
296
296
  [identityId.toString()]: {
297
- [dataContract.getId().toString()]: 1,
297
+ [dataContract.getId().toString()]: '1',
298
298
  },
299
299
  });
300
300
 
@@ -304,7 +304,7 @@ describe('DocumentFactory', () => {
304
304
  .filter((t) => t.getAction() === 0);
305
305
 
306
306
  expect(replaceDocuments[0].getId()).to.deep.equal(newDocument.getId());
307
- expect(replaceDocuments[0].getRevision()).to.deep.equal(2);
307
+ expect(replaceDocuments[0].getRevision()).to.deep.equal(BigInt(2));
308
308
  expect(createDocuments).to.have.lengthOf(documents.length);
309
309
  });
310
310
  });