@dashevo/wasm-dpp 1.8.0 → 2.0.0-dev.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.
- package/.eslintrc +3 -0
- package/Cargo.toml +3 -2
- package/dist/wasm/wasm_dpp.d.ts +1824 -1070
- package/dist/wasm/wasm_dpp.js +597 -168
- package/dist/wasm/wasm_dpp_bg.js +1 -1
- package/lib/test/fixtures/getIdentityCreditTransferTransitionFixture.js +1 -1
- package/lib/test/fixtures/getIdentityFixture.js +1 -1
- package/lib/wasm/wasm_dpp.d.ts +1824 -1070
- package/package.json +6 -6
- package/scripts/build-wasm.sh +1 -1
- package/src/data_contract/data_contract.rs +17 -22
- package/src/data_contract/mod.rs +1 -0
- package/src/data_contract/state_transition/data_contract_create_transition/mod.rs +21 -0
- package/src/data_contract/state_transition/data_contract_update_transition/mod.rs +25 -0
- package/src/data_contract/tokens.rs +60 -0
- package/src/document/document_facade.rs +3 -3
- package/src/document/errors/document_already_exists_error.rs +1 -1
- package/src/document/errors/document_not_provided_error.rs +1 -1
- package/src/document/errors/invalid_document_action_error.rs +2 -2
- package/src/document/extended_document.rs +3 -5
- package/src/document/factory.rs +14 -8
- package/src/document/mod.rs +3 -5
- package/src/document/state_transition/batch_transition/batched_transition/mod.rs +18 -0
- package/src/document/state_transition/{document_batch_transition → batch_transition}/document_transition/document_create_transition.rs +45 -3
- package/src/document/state_transition/{document_batch_transition → batch_transition}/document_transition/document_delete_transition.rs +23 -4
- package/src/document/state_transition/{document_batch_transition → batch_transition}/document_transition/document_replace_transition.rs +24 -5
- package/src/document/state_transition/{document_batch_transition → batch_transition}/document_transition/mod.rs +99 -14
- package/src/document/state_transition/{document_batch_transition → batch_transition}/mod.rs +45 -29
- package/src/document/state_transition/batch_transition/token_transition/burn.rs +12 -0
- package/src/document/state_transition/batch_transition/token_transition/claim.rs +12 -0
- package/src/document/state_transition/batch_transition/token_transition/config.rs +12 -0
- package/src/document/state_transition/batch_transition/token_transition/destroy.rs +22 -0
- package/src/document/state_transition/batch_transition/token_transition/emergency_action.rs +12 -0
- package/src/document/state_transition/batch_transition/token_transition/freeze.rs +22 -0
- package/src/document/state_transition/batch_transition/token_transition/mint.rs +31 -0
- package/src/document/state_transition/batch_transition/token_transition/mod.rs +147 -0
- package/src/document/state_transition/batch_transition/token_transition/transfer.rs +22 -0
- package/src/document/state_transition/batch_transition/token_transition/unfreeze.rs +22 -0
- package/src/document/state_transition/mod.rs +1 -1
- package/src/errors/consensus/basic/identity/identity_insufficient_balance_error.rs +2 -2
- package/src/errors/consensus/consensus_error.rs +167 -1
- package/src/errors/consensus/fee/balance_is_not_enough_error.rs +4 -4
- package/src/identity/identity.rs +14 -14
- package/src/identity/state_transition/identity_create_transition/identity_create_transition.rs +10 -0
- package/src/identity/state_transition/identity_credit_transfer_transition/transition.rs +31 -6
- package/src/identity/state_transition/identity_credit_withdrawal_transition/transition.rs +15 -0
- package/src/identity/state_transition/identity_topup_transition/identity_topup_transition.rs +10 -0
- package/src/identity/state_transition/identity_update_transition/identity_update_transition.rs +29 -4
- package/src/identity/state_transition/identity_update_transition/to_object.rs +2 -2
- package/src/identity/state_transition/transition_types.rs +1 -1
- package/src/metadata.rs +16 -27
- package/src/state_transition/state_transition_factory.rs +2 -4
- package/src/voting/state_transition/masternode_vote_transition/mod.rs +75 -50
- package/test/integration/document/Document.spec.js +2 -7
- package/test/integration/document/DocumentFacade.spec.js +4 -4
- package/test/integration/identity/IdentityFacade.spec.js +5 -10
- package/test/integration/identity/stateTransition/IdentityUpdateTransition/validation/state/validateIdentityUpdateTransitionStateFactory.spec.js +4 -4
- package/test/integration/identity/stateTransition/assetLockProof/chain/validateChainAssetLockProofStructureFactory.spec.js +3 -3
- package/test/integration/identity/stateTransition/assetLockProof/fetchAssetLockTransactionOutputFactory.spec.js +1 -1
- package/test/integration/stateTransition/StateTransitionFacade.spec.js +3 -3
- package/test/unit/Metadata.spec.js +8 -23
- package/test/unit/dataContract/DataContract.spec.js +1 -18
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/DataContractCreateTransition.spec.js +1 -1
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js +1 -1
- package/test/unit/document/Document.spec.js +4 -7
- package/test/unit/document/DocumentFactory.spec.js +2 -2
- package/test/unit/identity/Identity.spec.js +15 -35
- package/test/unit/identity/IdentityFactory.spec.js +3 -3
- package/test/unit/identity/stateTransition/IdentityUpdateTransition/IdentityUpdateTransition.spec.js +2 -2
- package/test/unit/identity/stateTransition/identityCreditTransferTransition/identityCreditTransferTransition.spec.js +1 -1
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/basic/find_duplicates_by_id.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/basic/find_duplicates_by_indices.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/basic/mod.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/basic/validate_documents_batch_transition_basic.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/basic/validate_partial_compound_indices.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/mod.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/state/fetch_extended_documents.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/state/mod.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/state/validate_documents_batch_transitions_state.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/state/validate_documents_uniqueness_by_indices.rs +0 -0
|
@@ -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() as u16
|
|
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) =>
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
.
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
.
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
)
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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.clone(),
|
|
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
|
|
|
@@ -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
|
-
|
|
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
|
|
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(
|
|
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
|
-
|
|
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(
|
|
67
|
+
expect(deserialized).to.be.an.instanceOf(Identity);
|
|
73
68
|
|
|
74
|
-
expect(
|
|
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
|
-
|
|
14
|
-
|
|
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
|
-
|
|
30
|
-
|
|
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,
|
|
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(
|
|
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(
|
|
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
|
});
|
|
@@ -22,21 +22,11 @@ describe('Identity', () => {
|
|
|
22
22
|
|
|
23
23
|
rawIdentity = identity.toObject();
|
|
24
24
|
|
|
25
|
-
metadataFixture = new Metadata(
|
|
26
|
-
blockHeight: 42,
|
|
27
|
-
coreChainLockedHeight: 0,
|
|
28
|
-
timeMs: 100,
|
|
29
|
-
protocolVersion: 2,
|
|
30
|
-
});
|
|
25
|
+
metadataFixture = new Metadata(BigInt(42), 1, BigInt(100), 2);
|
|
31
26
|
|
|
32
27
|
identity.setMetadata(metadataFixture);
|
|
33
28
|
|
|
34
|
-
metadataFixture = new Metadata(
|
|
35
|
-
blockHeight: 42,
|
|
36
|
-
coreChainLockedHeight: 0,
|
|
37
|
-
timeMs: 100,
|
|
38
|
-
protocolVersion: 2,
|
|
39
|
-
});
|
|
29
|
+
metadataFixture = new Metadata(BigInt(42), 1, BigInt(100), 2);
|
|
40
30
|
});
|
|
41
31
|
|
|
42
32
|
describe('#constructor', () => {
|
|
@@ -173,52 +163,42 @@ describe('Identity', () => {
|
|
|
173
163
|
|
|
174
164
|
describe('#getBalance', () => {
|
|
175
165
|
it('should return set identity balance', () => {
|
|
176
|
-
identity.setBalance(42);
|
|
177
|
-
expect(identity.getBalance()).to.equal(42);
|
|
166
|
+
identity.setBalance(BigInt(42));
|
|
167
|
+
expect(identity.getBalance()).to.equal(BigInt(42));
|
|
178
168
|
});
|
|
179
169
|
});
|
|
180
170
|
|
|
181
171
|
describe('#setBalance', () => {
|
|
182
172
|
it('should set identity balance', () => {
|
|
183
|
-
identity.setBalance(42);
|
|
184
|
-
expect(identity.getBalance()).to.equal(42);
|
|
173
|
+
identity.setBalance(BigInt(42));
|
|
174
|
+
expect(identity.getBalance()).to.equal(BigInt(42));
|
|
185
175
|
});
|
|
186
176
|
});
|
|
187
177
|
|
|
188
178
|
describe('#increaseBalance', () => {
|
|
189
179
|
it('should increase identity balance', () => {
|
|
190
|
-
const result = identity.increaseBalance(42);
|
|
180
|
+
const result = identity.increaseBalance(BigInt(42));
|
|
191
181
|
|
|
192
|
-
expect(result).to.equal(42);
|
|
193
|
-
expect(identity.getBalance()).to.equal(42);
|
|
182
|
+
expect(result).to.equal(BigInt(42));
|
|
183
|
+
expect(identity.getBalance()).to.equal(BigInt(42));
|
|
194
184
|
});
|
|
195
185
|
});
|
|
196
186
|
|
|
197
187
|
describe('#reduceBalance', () => {
|
|
198
188
|
it('should reduce identity balance', () => {
|
|
199
|
-
identity.setBalance(42);
|
|
189
|
+
identity.setBalance(BigInt(42));
|
|
200
190
|
|
|
201
|
-
const result = identity.reduceBalance(2);
|
|
191
|
+
const result = identity.reduceBalance(BigInt(2));
|
|
202
192
|
|
|
203
|
-
expect(result).to.equal(40);
|
|
204
|
-
expect(identity.getBalance()).to.equal(40);
|
|
193
|
+
expect(result).to.equal(BigInt(40));
|
|
194
|
+
expect(identity.getBalance()).to.equal(BigInt(40));
|
|
205
195
|
});
|
|
206
196
|
});
|
|
207
197
|
|
|
208
198
|
describe('#setMetadata', () => {
|
|
209
199
|
it('should set metadata', () => {
|
|
210
|
-
const otherMetadata = new Metadata(
|
|
211
|
-
|
|
212
|
-
coreChainLockedHeight: 1,
|
|
213
|
-
timeMs: 100,
|
|
214
|
-
protocolVersion: 2,
|
|
215
|
-
});
|
|
216
|
-
const expectedMetadata = new Metadata({
|
|
217
|
-
blockHeight: 43,
|
|
218
|
-
coreChainLockedHeight: 1,
|
|
219
|
-
timeMs: 100,
|
|
220
|
-
protocolVersion: 2,
|
|
221
|
-
});
|
|
200
|
+
const otherMetadata = new Metadata(BigInt(43), 1, BigInt(100), 2);
|
|
201
|
+
const expectedMetadata = new Metadata(BigInt(43), 1, BigInt(100), 2);
|
|
222
202
|
|
|
223
203
|
identity.setMetadata(otherMetadata);
|
|
224
204
|
|
|
@@ -29,7 +29,7 @@ describe('IdentityFactory', () => {
|
|
|
29
29
|
factory = new IdentityFactory(3);
|
|
30
30
|
|
|
31
31
|
identity = await getIdentityFixture(instantAssetLockProof.createIdentifier());
|
|
32
|
-
identity.setBalance(0);
|
|
32
|
+
identity.setBalance(BigInt(0));
|
|
33
33
|
|
|
34
34
|
fakeTime = this.sinon.useFakeTimers(new Date());
|
|
35
35
|
});
|
|
@@ -179,7 +179,7 @@ describe('IdentityFactory', () => {
|
|
|
179
179
|
describe('createChainAssetLockProof', () => {
|
|
180
180
|
it('should create IdentityCreateTransition from Identity model', async () => {
|
|
181
181
|
identity = await getIdentityFixture(chainAssetLockProof.createIdentifier());
|
|
182
|
-
identity.setBalance(0);
|
|
182
|
+
identity.setBalance(BigInt(0));
|
|
183
183
|
|
|
184
184
|
const stateTransition = factory.createIdentityCreateTransition(
|
|
185
185
|
identity,
|
|
@@ -226,7 +226,7 @@ describe('IdentityFactory', () => {
|
|
|
226
226
|
|
|
227
227
|
describe('createIdentityUpdateTransition', () => {
|
|
228
228
|
it('should create IdentityUpdateTransition', () => {
|
|
229
|
-
const revision = 1;
|
|
229
|
+
const revision = BigInt(1);
|
|
230
230
|
const disablePublicKeys = [identity.getPublicKeyById(0)];
|
|
231
231
|
const key = new IdentityPublicKeyWithWitness(1);
|
|
232
232
|
key.setData(Buffer.from('AuryIuMtRrl/VviQuyLD1l4nmxi9ogPzC9LT7tdpo0di', 'base64'));
|
package/test/unit/identity/stateTransition/IdentityUpdateTransition/IdentityUpdateTransition.spec.js
CHANGED
|
@@ -45,9 +45,9 @@ describe('IdentityUpdateTransition', () => {
|
|
|
45
45
|
|
|
46
46
|
describe('#setRevision', () => {
|
|
47
47
|
it('should set revision', () => {
|
|
48
|
-
stateTransition.setRevision(42);
|
|
48
|
+
stateTransition.setRevision(BigInt(42));
|
|
49
49
|
|
|
50
|
-
expect(stateTransition.getRevision()).to.equal(42);
|
|
50
|
+
expect(stateTransition.getRevision()).to.equal(BigInt(42));
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
53
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|