Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
194 commits
Select commit Hold shift + click to select a range
27d10e7
initial identity work
QuantumExplorer Dec 5, 2022
49fd378
more work
QuantumExplorer Dec 5, 2022
7253fdb
various fixes
QuantumExplorer Dec 13, 2022
e42c6a3
added is_disabled
QuantumExplorer Dec 13, 2022
5b15c32
more work
QuantumExplorer Dec 13, 2022
1f8cee4
more work on identity v2
QuantumExplorer Dec 16, 2022
c7ef453
identity v2 compiling
QuantumExplorer Dec 16, 2022
399b8e2
much work on identity v2
QuantumExplorer Dec 16, 2022
0e4a04b
fixed a lot of stuff
QuantumExplorer Dec 18, 2022
5845160
more work
QuantumExplorer Dec 19, 2022
3378df9
more work
QuantumExplorer Dec 19, 2022
5056371
more work
QuantumExplorer Dec 19, 2022
bebfd58
work on fixing key serialization
QuantumExplorer Dec 20, 2022
e0c6028
all tests passing
QuantumExplorer Dec 20, 2022
3a2434b
all tests passing
QuantumExplorer Dec 20, 2022
e0cdbf0
more work
QuantumExplorer Dec 20, 2022
eaf9ad7
all tests passing
QuantumExplorer Dec 20, 2022
9ab0405
Merge branch 'v0.24-dev' into feat/identityV3
QuantumExplorer Dec 20, 2022
59ebe82
fixes
QuantumExplorer Dec 20, 2022
18dd006
style: fixes
QuantumExplorer Dec 20, 2022
1def771
worked on js bindings
QuantumExplorer Dec 20, 2022
07fc726
more work
QuantumExplorer Dec 20, 2022
0497723
more work
QuantumExplorer Dec 21, 2022
8bf393f
more work
QuantumExplorer Dec 21, 2022
065247e
fixed issue
QuantumExplorer Dec 21, 2022
97684cb
small fixes
QuantumExplorer Dec 21, 2022
898a993
small fix
QuantumExplorer Dec 21, 2022
6625c9f
refactoring of keys
QuantumExplorer Dec 21, 2022
ade9b5a
more work
QuantumExplorer Dec 22, 2022
61fb1ff
more work
QuantumExplorer Dec 23, 2022
e4681b9
chore: continue
shumkov Dec 23, 2022
7e22cc6
Merge branch 'v0.24-dev' into identity-v5
QuantumExplorer Dec 23, 2022
5e16997
more merge
QuantumExplorer Dec 23, 2022
72347de
more merge
QuantumExplorer Dec 23, 2022
a02be6a
fixes
QuantumExplorer Dec 23, 2022
beb52a8
fixes
QuantumExplorer Dec 23, 2022
d483738
refactor: identity public key fetch
shumkov Dec 23, 2022
ed0ec20
Merge remote-tracking branch 'origin/identity-v5' into identity-v5
shumkov Dec 23, 2022
8202158
refactor: small fixes
shumkov Dec 23, 2022
d4e284d
full identity with costs
QuantumExplorer Dec 23, 2022
30858f5
fmt
QuantumExplorer Dec 23, 2022
4a5b300
more work
QuantumExplorer Dec 23, 2022
59859d1
more work
QuantumExplorer Dec 24, 2022
b3e5c05
fix: bindings compilation errors and fetch full non exiting identity
shumkov Dec 26, 2022
7c923ba
refactor: remove unnecessary if using upper level match
shumkov Dec 26, 2022
26ce3a4
refactor: getting crazy with match
shumkov Dec 26, 2022
1c5a300
feat: disable identity keys
shumkov Dec 27, 2022
33f5b3e
chore: continuation
shumkov Dec 27, 2022
e0d2e7b
chore: make JS DPP work with new Identity methods
shumkov Dec 28, 2022
a4d6d91
chore: update JS Drive
shumkov Dec 28, 2022
1c8351a
chore: update JS Drive continuation
shumkov Dec 28, 2022
7d4acb6
chore: update JS Drive continuation pt2
shumkov Dec 29, 2022
774d1ce
Merge branch 'v0.24-dev' into feat/IdentityV4
shumkov Dec 29, 2022
014ce4a
Merge branch 'feat/IdentityV4' into identity-v5
shumkov Dec 29, 2022
e166671
Merge branch 'v0.24-dev' into identity-v5
QuantumExplorer Jan 2, 2023
4e30faa
a lot of work on tree structure
QuantumExplorer Jan 3, 2023
d90b1a4
added a lot of batching fixes
QuantumExplorer Jan 3, 2023
a397b28
fixed root structure
QuantumExplorer Jan 3, 2023
8e00b05
fixes for abci
QuantumExplorer Jan 3, 2023
5ba38ed
temp
QuantumExplorer Jan 3, 2023
8f6c7a0
more work on non unique keys
QuantumExplorer Jan 4, 2023
e83f2bb
another fix
QuantumExplorer Jan 4, 2023
c10b9a8
more fixes
QuantumExplorer Jan 4, 2023
6e52249
more work on sum trees
QuantumExplorer Jan 4, 2023
f8a2e61
more work
QuantumExplorer Jan 5, 2023
455b72b
more work
QuantumExplorer Jan 5, 2023
acc1fb0
temp work
QuantumExplorer Jan 5, 2023
ef5ef2b
fix: fix for merk caching in contract caching (irony)
QuantumExplorer Jan 5, 2023
8bd4e91
more fixes
QuantumExplorer Jan 5, 2023
81abd16
small fmt
QuantumExplorer Jan 5, 2023
40371ac
Merge branch 'v0.24-dev' into fix/deterministicContractCache
QuantumExplorer Jan 5, 2023
475b7a1
test: fix test and small refactoring (#711)
shumkov Jan 6, 2023
43e9046
test: additional test to prove the fix
shumkov Jan 6, 2023
9e0bbb7
style: remove unused imports
shumkov Jan 6, 2023
e5aabc2
test: additional test to prove the fix (#714)
shumkov Jan 7, 2023
7071b08
test: do not pass epoch on user call
shumkov Jan 7, 2023
a886812
test: do not pass epoch on user call
shumkov Jan 7, 2023
2c88e31
update
QuantumExplorer Jan 9, 2023
4601544
merge
QuantumExplorer Jan 9, 2023
d523716
merge
QuantumExplorer Jan 9, 2023
2dac534
more work
QuantumExplorer Jan 9, 2023
5edacc6
temp
QuantumExplorer Jan 9, 2023
c9692b0
more test
QuantumExplorer Jan 9, 2023
8536d09
merge
QuantumExplorer Jan 10, 2023
1ecffa6
more work
QuantumExplorer Jan 10, 2023
75b0110
using cow for storage flags
QuantumExplorer Jan 10, 2023
a0764e1
more work
QuantumExplorer Jan 10, 2023
3cbb8c3
more work
QuantumExplorer Jan 11, 2023
e69db98
added in logic for contract information for an identity
QuantumExplorer Jan 11, 2023
cea8589
fmt
QuantumExplorer Jan 11, 2023
a67b381
a lot of fixes
QuantumExplorer Jan 11, 2023
11d88b7
more tests
QuantumExplorer Jan 11, 2023
7a078d4
more tests around sum trees
QuantumExplorer Jan 11, 2023
2ad0df4
fix pool distribution
QuantumExplorer Jan 12, 2023
77e38b7
started deletion
QuantumExplorer Jan 12, 2023
a77c1f2
started deletion
QuantumExplorer Jan 12, 2023
9e2be8f
deletion test
QuantumExplorer Jan 12, 2023
b27e676
update
QuantumExplorer Jan 12, 2023
3d410a2
Identity v7 (#726)
shumkov Jan 12, 2023
967948a
much more work
QuantumExplorer Jan 12, 2023
f68d49b
estimated costs
QuantumExplorer Jan 13, 2023
5e42197
estimated costs for identity insert
QuantumExplorer Jan 13, 2023
330f3c8
fix: negative balance is ignored on balance update
shumkov Jan 13, 2023
532185e
fix: change balance should refund all identities
shumkov Jan 13, 2023
1e26f56
fix: add to balance crash if debt is bigger
shumkov Jan 13, 2023
7310028
refactor: rename update balance to replace
shumkov Jan 14, 2023
64e03d1
fix: `add_to_identity_balance` dry run fails
shumkov Jan 14, 2023
2584731
fix: undefined functions
shumkov Jan 14, 2023
b8f7d54
fix: debt related issues
shumkov Jan 14, 2023
8b7ff01
test: correct path ot contract fixture
shumkov Jan 14, 2023
2d69813
changes
QuantumExplorer Jan 15, 2023
a8f68c6
changes
QuantumExplorer Jan 15, 2023
b51e6ea
Identity v8 fixes (#731)
QuantumExplorer Jan 15, 2023
563f3f0
fix: refunds
shumkov Jan 15, 2023
62b31ab
Changes by samuelw
QuantumExplorer Jan 15, 2023
5901266
more work
QuantumExplorer Jan 15, 2023
9a65190
much progress
QuantumExplorer Jan 16, 2023
f98c4e6
tests passing
QuantumExplorer Jan 16, 2023
b628f9b
a lot of fixes
QuantumExplorer Jan 16, 2023
0c4798f
clean up
QuantumExplorer Jan 16, 2023
edbd34c
Identity v9 (#732)
QuantumExplorer Jan 16, 2023
ff2b512
refactor: remove redundant code
shumkov Jan 16, 2023
3b3ef62
fix: extra epoch with 0 after refunds subtraction
shumkov Jan 16, 2023
393677c
style: fix warnings
shumkov Jan 16, 2023
c216a82
test: rename spec
shumkov Jan 16, 2023
6d79deb
Identity v8 (#728)
QuantumExplorer Jan 16, 2023
784cad4
refactor(drive): rename pending updates (#733)
shumkov Jan 16, 2023
f2d4d9b
a few more fixes
QuantumExplorer Jan 16, 2023
bd0c3bf
another fix
QuantumExplorer Jan 16, 2023
e3a0372
more fixed tests
QuantumExplorer Jan 16, 2023
9d9f039
all tests passing
QuantumExplorer Jan 17, 2023
93eef0b
Merge branch 'v0.24-dev' into identity-v6
QuantumExplorer Jan 17, 2023
4ff0670
feat(drive): ignore dust refunds (#734)
shumkov Jan 17, 2023
ee04368
test: fix add_distribute_storage_fee_to_epochs_operations
shumkov Jan 17, 2023
3061237
added some more functions
QuantumExplorer Jan 17, 2023
4ab5c41
test: fix incorrect document epoch in strategy test
shumkov Jan 17, 2023
f9aded3
fix: negative epoch storage pool value on update
shumkov Jan 17, 2023
8c455ad
Merge branch 'identity-v6' into identity-v10
shumkov Jan 17, 2023
40abf94
refactor: revert leftovers return
shumkov Jan 17, 2023
6bb0144
feat: integrate apply balance function (wip)
shumkov Jan 17, 2023
6ed9004
docs: add todos
shumkov Jan 18, 2023
1033fb0
feat: extra needed methods and better costs per epoch (#739)
QuantumExplorer Jan 18, 2023
6756e89
Merge branch 'identity-v6' into identity-v10
shumkov Jan 18, 2023
2fdc42c
fixed 2 issues
QuantumExplorer Jan 18, 2023
b3e9fb0
added another test
QuantumExplorer Jan 18, 2023
e21c671
added a test for full identity
QuantumExplorer Jan 18, 2023
70ffc22
fixed estimated costs for disabling keys
QuantumExplorer Jan 18, 2023
e20b6b8
more tests
QuantumExplorer Jan 18, 2023
2064f82
added test for proved full identities
QuantumExplorer Jan 18, 2023
cc4695f
added test for proved full identities
QuantumExplorer Jan 18, 2023
c3bd3a1
added in test for 10 proved full identities
QuantumExplorer Jan 18, 2023
fbda801
all tests passing
QuantumExplorer Jan 18, 2023
cf04506
last test passing
QuantumExplorer Jan 18, 2023
b9756a8
Merge branch 'identity-v6' into identity-v10
shumkov Jan 18, 2023
3e338c5
chore: update JS Drive (wip)
shumkov Jan 18, 2023
dea8bca
feat: implement bindings for required methods (wip)
shumkov Jan 18, 2023
81f70bf
feat: implement bindings for required methods (wip)
shumkov Jan 19, 2023
0ccdc00
feat: implement bindings for js_fetch_many_identities_by_public_key_h…
shumkov Jan 19, 2023
26dba7e
feat: implement bindings for fetchIdentitiesByPublicKeyHashes
shumkov Jan 19, 2023
b80afa8
added proof verification
QuantumExplorer Jan 19, 2023
41f437b
more work on tests
QuantumExplorer Jan 19, 2023
834fe90
Merge remote-tracking branch 'origin/identity-v10-sam-changes' into i…
shumkov Jan 19, 2023
49cadcc
more work
QuantumExplorer Jan 19, 2023
bee3249
chore: fixes and tests
shumkov Jan 19, 2023
917e4ca
Merge remote-tracking branch 'origin/identity-v10-sam-changes' into i…
shumkov Jan 19, 2023
d6a7151
fix more tests
shumkov Jan 19, 2023
388427b
updated to new grovedb
QuantumExplorer Jan 20, 2023
5c80bed
updated tests
QuantumExplorer Jan 24, 2023
08a0c9f
all tests passing
QuantumExplorer Jan 24, 2023
b1e2379
merge
QuantumExplorer Jan 24, 2023
e84b0cf
merge
QuantumExplorer Jan 24, 2023
9f857bc
fix more tests
shumkov Jan 24, 2023
a95eefd
feat(dashmate): update Core to 18.2.0 (#735)
Jan 16, 2023
8d02122
merge
QuantumExplorer Jan 25, 2023
8110696
chore: fixes and tests
shumkov Jan 25, 2023
47516ce
Merge branch 'v0.24-dev' into v10merge
QuantumExplorer Jan 26, 2023
da6afe3
fmt
QuantumExplorer Jan 26, 2023
90119bf
updates
QuantumExplorer Jan 27, 2023
b64505c
more work
QuantumExplorer Jan 27, 2023
706b255
merge
QuantumExplorer Jan 27, 2023
71921a2
hash updates
QuantumExplorer Jan 27, 2023
eedbf5f
added some bindings
QuantumExplorer Jan 27, 2023
94a21c7
some bindings
QuantumExplorer Jan 27, 2023
fd301ec
chore: tests and bugs
shumkov Jan 27, 2023
1d0ed63
chore: enable dry run
shumkov Jan 27, 2023
c75abcf
style: fix linting issues
shumkov Jan 27, 2023
cfab473
grovedb fixes for v10
QuantumExplorer Jan 30, 2023
3c550d1
updated grovedb
QuantumExplorer Jan 30, 2023
8dffa3f
changes to include fees
QuantumExplorer Jan 30, 2023
30d4bad
chore: update grovedb version
QuantumExplorer Jan 30, 2023
1a19f99
fix(drive): wrong signatures of fetch balance methods
shumkov Jan 30, 2023
5d82bdf
perf: fetch balance instead of entire identity
shumkov Jan 30, 2023
6eb79e1
Merge branch 'v0.24-dev' into identity-v10
shumkov Jan 30, 2023
b54b16f
style: fix linter warnings
shumkov Jan 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 120 additions & 86 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 0 additions & 18 deletions packages/dapi/lib/externalApis/drive/DriveClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,24 +154,6 @@ class DriveClient {
);
}

/**
* Fetch serialized identity ids by it's public key hashes
*
* @param {Buffer[]} publicKeyHashes
* @param {boolean} prove - include proofs into the response
*
* @return {Promise<Buffer[]>}
*/
async fetchIdentityIdsByPublicKeyHashes(publicKeyHashes, prove) {
return this.request(
'/identities/by-public-key-hash/id',
{
publicKeyHashes,
},
prove,
);
}

/**
* Fetch proofs by ids
*
Expand Down
28 changes: 0 additions & 28 deletions packages/dapi/test/unit/externalApis/drive/DriveClient.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const cbor = require('cbor');
const chaiAsPromised = require('chai-as-promised');
const dirtyChai = require('dirty-chai');

const generateRandomIdentifier = require('@dashevo/dpp/lib/test/utils/generateRandomIdentifier');
const getIdentityFixture = require('@dashevo/dpp/lib/test/fixtures/getIdentityFixture');
const InvalidArgumentGrpcError = require('@dashevo/grpc-common/lib/server/error/InvalidArgumentGrpcError');
const GrpcErrorCodes = require('@dashevo/grpc-common/lib/server/error/GrpcErrorCodes');
Expand Down Expand Up @@ -191,33 +190,6 @@ describe('DriveClient', () => {
});
});

describe('#fetchIdentityIdsByPublicKeyHashes', () => {
it('Should call \'fetchIdentityIdsByPublicKeyHashes\' RPC with the given parameters', async () => {
const drive = new DriveClient({ host: '127.0.0.1', port: 3000 });

const identityId = generateRandomIdentifier();
const publicKeyHashes = [Buffer.alloc(1)];
const proof = Buffer.from('proof');
const buffer = cbor.encode({ data: [identityId], proof });

sinon.stub(drive.client, 'request')
.resolves({
result: {
response: { code: 0, value: buffer },
},
});

const result = await drive.fetchIdentityIdsByPublicKeyHashes(publicKeyHashes, true);

expect(drive.client.request).to.have.been.calledOnceWithExactly('abci_query', {
path: '/identities/by-public-key-hash/id',
data: cbor.encode({ publicKeyHashes }).toString('hex'),
prove: true,
});
expect(result).to.be.deep.equal(buffer);
});
});

describe('#fetchProofs', () => {
it('should call \'fetchProofs\' RPC with the given parameters', async () => {
const drive = new DriveClient({ host: '127.0.0.1', port: 3000 });
Expand Down
122 changes: 84 additions & 38 deletions packages/js-dpp/lib/StateRepositoryInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @method
* @name StateRepository#fetchDataContract
* @param {Identifier} id
* @param {StateTransitionExecutionContext} [StateTransitionExecutionContext]
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<DataContract|null>}
*/

Expand All @@ -21,7 +21,7 @@
* @method
* @name StateRepository#createDataContract
* @param {DataContract} dataContract
* @param {StateTransitionExecutionContext} [StateTransitionExecutionContext]
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<void>}
*/

Expand All @@ -32,7 +32,7 @@
* @method
* @name StateRepository#updateDataContract
* @param {DataContract} dataContract
* @param {StateTransitionExecutionContext} [StateTransitionExecutionContext]
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<void>}
*/

Expand All @@ -45,7 +45,7 @@
* @param {Identifier} contractId
* @param {string} type
* @param {{ where: Object }} options
* @param {StateTransitionExecutionContext} [StateTransitionExecutionContext]
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<Document[]>}
*/

Expand All @@ -56,7 +56,7 @@
* @method
* @name StateRepository#createDocument
* @param {Document} document
* @param {StateTransitionExecutionContext} [StateTransitionExecutionContext]
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<void>}
*/

Expand All @@ -67,7 +67,7 @@
* @method
* @name StateRepository#updateDocument
* @param {Document} document
* @param {StateTransitionExecutionContext} [StateTransitionExecutionContext]
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<void>}
*/

Expand All @@ -80,7 +80,7 @@
* @param {DataContract} dataContract
* @param {string} type
* @param {Identifier} id
* @param {StateTransitionExecutionContext} [StateTransitionExecutionContext]
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<void>}
*/

Expand All @@ -91,7 +91,7 @@
* @method
* @name StateRepository#fetchTransaction
* @param {string} id
* @param {StateTransitionExecutionContext} [StateTransitionExecutionContext]
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<Object|null>}
*/

Expand All @@ -102,53 +102,110 @@
* @method
* @name StateRepository#fetchIdentity
* @param {Identifier} id
* @param {StateTransitionExecutionContext} [StateTransitionExecutionContext]
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<Identity|null>}
*/

/**
* Store identity
* Create identity
*
* @async
* @method
* @name StateRepository#createIdentity
* @param {Identity} identity
* @param {StateTransitionExecutionContext} [StateTransitionExecutionContext]
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<void>}
*/

/**
* Store identity
* Add keys to identity
*
* @async
* @method
* @name StateRepository#updateIdentity
* @param {Identity} identity
* @param {StateTransitionExecutionContext} [StateTransitionExecutionContext]
* @name StateRepository#addKeysToIdentity
* @param {Identifier} identityId
* @param {IdentityPublicKey[]} keys
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<void>}
*/

/**
* Disable identity keys
*
* @async
* @method
* @name StateRepository#disableIdentityKeys
* @param {Identifier} identityId
* @param {number[]} keyIds
* @param {number} disableAt
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<void>}
*/

/**
* Store public keys hashes and identity id pair
* Update identity revision
*
* @async
* @method
* @name StateRepository#updateIdentityRevision
* @param {Identifier} identityId
* @param {number} revision
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<void>}
*/

/**
* Fetch identity balance by identity ID
*
* @async
* @method
* @name StateRepository#fetchIdentityBalance
* @param {Identifier} id
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<number|null>}
*/

/**
* Fetch identity balance including debt by identity ID
*
* @async
* @method
* @name StateRepository#fetchIdentityBalanceWithDebt
* @param {Identifier} id
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<number|null>} - Balance can be negative in case of debt present
*/

/**
* Add to identity balance
*
* @async
* @method
* @name StateRepository#storeIdentityPublicKeyHashes
* @name StateRepository#addToIdentityBalance
* @param {Identifier} identityId
* @param {Buffer[]} publicKeyHashes
* @param {StateTransitionExecutionContext} [StateTransitionExecutionContext]
* @param {number} amount
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<void>}
*/

/**
* Fetch identity ids by public keys hashes
* Add to system credits
*
* @async
* @method
* @name StateRepository#fetchIdentityIdsByPublicKeyHashes
* @param {Buffer[]} publicKeyHashes
* @param {StateTransitionExecutionContext} [StateTransitionExecutionContext]
* @returns {Promise<Array<Identifier|null>>}
* @name StateRepository#addToSystemCredits
* @param {number} amount
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<void>}
*/

/**
* Fetch the latest platform block time
*
* @async
* @method
* @name StateRepository#fetchLatestPlatformBlockTime
* @returns {Promise<protobuf.Timestamp>}
*/

/**
Expand Down Expand Up @@ -176,7 +233,7 @@
* @method
* @name StateRepository#verifyInstantLock
* @param {InstantLock} instantLock
* @param {StateTransitionExecutionContext} [StateTransitionExecutionContext]
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<boolean>}
*/

Expand All @@ -187,7 +244,7 @@
* @method
* @name StateRepository#isAssetLockTransactionOutPointAlreadyUsed
* @param {Buffer} outPointBuffer
* @param {StateTransitionExecutionContext} [StateTransitionExecutionContext]
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<boolean>}
*/

Expand All @@ -198,7 +255,7 @@
* @method
* @name StateRepository#markAssetLockTransactionOutPointAsUsed
* @param {Buffer} outPointBuffer
* @param {StateTransitionExecutionContext} [StateTransitionExecutionContext]
* @param {StateTransitionExecutionContext} [executionContext]
* @returns {Promise<void>}
*/

Expand All @@ -219,14 +276,3 @@
* @name StateRepository#fetchLatestPlatformBlockTime
* @returns {Promise<number>}
*/

/**
* Calculates storage fee to epochs distribution amount and leftovers
*
* @async
* @method
* @name StateRepository#calculateStorageFeeDistributionAmountAndLeftovers
* @param {number} storageFee
* @param {number} startEpochIndex
* @returns {Promise<[number, number]>}
*/
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ async function createContactRequestDataTrigger(documentTransition, context) {
}

// toUserId identity exists
const identity = await stateRepository.fetchIdentity(
const balance = await stateRepository.fetchIdentityBalance(
toUserId,
context.getStateTransitionExecutionContext(),
);

if (!isDryRun && identity === null) {
if (!isDryRun && balance === null) {
const error = new DataTriggerConditionError(
context.getDataContract()
.getId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,7 @@ function applyIdentityCreateTransitionFactory(

await stateRepository.createIdentity(identity, executionContext);

const publicKeyHashes = identity
.getPublicKeys()
.map((publicKey) => publicKey.hash());

await stateRepository.storeIdentityPublicKeyHashes(
identity.getId(),
publicKeyHashes,
executionContext,
);
await stateRepository.addToSystemCredits(creditsAmount, executionContext);

const outPoint = stateTransition.getAssetLockProof().getOutPoint();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ function validateIdentityCreateTransitionStateFactory(
// Check if identity with such id already exists
const executionContext = stateTransition.getExecutionContext();
const identityId = stateTransition.getIdentityId();
const identity = await stateRepository.fetchIdentity(identityId, executionContext);

const balance = await stateRepository.fetchIdentityBalance(identityId, executionContext);

if (executionContext.isDryRun()) {
return result;
}

if (identity) {
if (balance !== null) {
result.addError(
new IdentityAlreadyExistsError(identityId.toBuffer()),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { convertSatoshiToCredits } = require('../../creditsConverter');
const getBiggestPossibleIdentity = require('../../getBiggestPossibleIdentity');

/**
* @param {StateRepository} stateRepository
Expand Down Expand Up @@ -34,15 +33,9 @@ function applyIdentityTopUpTransitionFactory(

const identityId = stateTransition.getIdentityId();

let identity = await stateRepository.fetchIdentity(identityId, executionContext);
await stateRepository.addToIdentityBalance(identityId, creditsAmount, executionContext);

if (executionContext.isDryRun()) {
identity = getBiggestPossibleIdentity();
}

identity.increaseBalance(creditsAmount);

await stateRepository.updateIdentity(identity, executionContext);
await stateRepository.addToSystemCredits(creditsAmount, executionContext);

await stateRepository.markAssetLockTransactionOutPointAsUsed(outPoint, executionContext);
}
Expand Down
Loading