Repository navigation
feat: native state-transition deserialization, plus document/put/ContractBounds fixes #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
939b111
fix: handle ContractBounds in IdentityPublicKey CBOR serialization
HashEngineering 77d311d
chore: exclude 32-bit libs which crash
HashEngineering 5e98ab6
fix: carry document type on native documents and stop panicking on ba…
HashEngineering c745301
feat: expose native state-transition deserialization (bincode)
HashEngineering 1239393
feat: add Kotlin wrapper for native state-transition deserialization
HashEngineering 45068b0
feat: include identity-update details in state-transition deserializa…
HashEngineering c34f40a
refactor: map state-transition Result via base.Result and regenerate …
HashEngineering 731f774
fix: sync dash-sdk-android fermented.rs with the state-transition exp…
HashEngineering c990d21
tests: update TxMetaDataTests
HashEngineering 2183700
fix: require truly unbound key in ContactRequests encryption-key fall…
HashEngineering d614e48
fix: require document type on native Document construction
HashEngineering File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18,424 changes: 10,341 additions & 8,083 deletions
18,424
dash-sdk-android/src/main/rust/src/fermented.rs
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // Typemaps for the native state-transition deserialization API (platform-mobile/src/state_transition.rs). | ||
| // identity_update_public_keys_to_add returns Result<Vec<IdentityPublicKey>>; map it to | ||
| // Result<List<IdentityPublicKey>> (the Vec<IdentityPublicKey> item typemap and clone already exist | ||
| // via identity_public_key.i / the generated clone.h). The _ctor/_destroy %ignore directives for | ||
| // these types are generated into ignore.i by ignore.py. | ||
|
|
||
| DEFINE_RESULT( | ||
| platform_mobile_state_transition_StateTransitionInfo, | ||
| String, | ||
| Result_ok_platform_mobile_state_transition_StateTransitionInfo_err_String, | ||
| clone | ||
| ); | ||
|
|
||
| DEFINE_LIST_RESULT( | ||
| IdentityPublicKey, | ||
| String, | ||
| Result_ok_Vec_dpp_identity_identity_public_key_IdentityPublicKey_err_String, | ||
| dpp_identity_identity_public_key_IdentityPublicKey | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
dpp/src/main/java/org/dashj/platform/dpp/statetransition/NativeStateTransition.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /** | ||
| * Copyright (c) 2018-present, Dash Core Team | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * COPYING file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| package org.dashj.platform.dpp.statetransition | ||
|
|
||
| import org.dashj.platform.dpp.identifier.Identifier | ||
| import org.dashj.platform.dpp.identity.IdentityPublicKey | ||
| import org.dashj.platform.sdk.dashsdk | ||
|
|
||
| /** | ||
| * A summary of a state transition, produced by natively deserializing its bincode-serialized | ||
| * bytes. Unlike [StateTransitionFactory] (CBOR-only, and lacking IdentityUpdate support) this | ||
| * works for any modern transition. The identity-update fields ([revision], [identityNonce], | ||
| * [addPublicKeys]) are populated only when [type] is IdentityUpdate (5). | ||
| */ | ||
| data class StateTransitionInfo( | ||
| /** The transition type discriminant (e.g. 5 = IdentityUpdate). */ | ||
| val type: Int, | ||
| /** Human-readable transition name. */ | ||
| val name: String, | ||
| /** The owner/identity id, or null when the transition has no owner. */ | ||
| val ownerId: Identifier?, | ||
| /** Identity-update: the new identity revision (0 otherwise). */ | ||
| val revision: Long, | ||
| /** Identity-update: the identity nonce (0 otherwise). */ | ||
| val identityNonce: Long, | ||
| /** Identity-update: the public keys being added (empty otherwise). */ | ||
| val addPublicKeys: List<IdentityPublicKey> | ||
| ) | ||
|
|
||
| /** Native (bincode) deserialization of platform state transitions. */ | ||
| object NativeStateTransition { | ||
|
|
||
| /** | ||
| * Deserializes a bincode-serialized state transition and returns a [StateTransitionInfo], | ||
| * including the public keys added when the transition is an identity update. | ||
| * | ||
| * @throws Exception if the bytes are not a valid state transition (surfaced from the SDK). | ||
| */ | ||
| @JvmStatic | ||
| fun deserialize(bytes: ByteArray): StateTransitionInfo { | ||
| // base.Result.unwrap() returns a Java-owned StateTransitionInfo (or throws on error). | ||
| val info = dashsdk.platformMobileStateTransitionDeserializeStateTransition(bytes).unwrap() | ||
|
|
||
| val ownerBytes = dashsdk.platformMobileStateTransitionStateTransitionInfoGetOwnerId(info) | ||
| val ownerId = if (ownerBytes != null && ownerBytes.isNotEmpty()) Identifier.from(ownerBytes) else null | ||
|
|
||
| val addPublicKeys = dashsdk.platformMobileStateTransitionIdentityUpdatePublicKeysToAdd(bytes) | ||
| .unwrap() | ||
| .map { IdentityPublicKey.from(it) } | ||
|
|
||
| return StateTransitionInfo( | ||
| type = dashsdk.platformMobileStateTransitionStateTransitionInfoGetTransitionType(info).toInt(), | ||
| name = dashsdk.platformMobileStateTransitionStateTransitionInfoGetName(info), | ||
| ownerId = ownerId, | ||
| revision = dashsdk.platformMobileStateTransitionStateTransitionInfoGetRevision(info).toLong(), | ||
| identityNonce = dashsdk.platformMobileStateTransitionStateTransitionInfoGetIdentityNonce(info).toLong(), | ||
| addPublicKeys = addPublicKeys | ||
| ) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.