-
Notifications
You must be signed in to change notification settings - Fork 16
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
Support RPC 0.8.0 #530
Draft
franciszekjob
wants to merge
77
commits into
main
Choose a base branch
from
feat/519-rpc-0.8.0
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Support RPC 0.8.0 #530
Changes from all commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
6ff3a2f
Adapt execution resources in data classes and methods
franciszekjob 4c2014d
Update tests
franciszekjob 625aa24
Add failure reason to transaction receipt
franciszekjob b0005b6
Add JSON RPC error data classes
franciszekjob 4587b9d
Add contract execution error
franciszekjob 5a96c51
Add `failureReason` to `GetTransactionStatusResponse`
franciszekjob 3c95565
Merge branch 'feat/519-2-transaction-status-error' into feat/519-3-st…
franciszekjob d547cb7
Fix linting
franciszekjob 25fdf9b
Add `getMessagesStatus` in providers
franciszekjob 74658de
Add todos for `getMessagesStatus` tests
franciszekjob 84f7dc5
Add `getStorageProof` in `Provider`
franciszekjob 5b81467
Add `GetStorageProofPayload`
franciszekjob 07a1f6f
Add `StorageProof`, `MerkleNode`, `ChildrenHashes`, `NodeHashToNodeMa…
franciszekjob 12138c6
Add `ContractStorageKey`
franciszekjob 06a8fd9
Refactor `getStorageProof`
franciszekjob 31f798c
Add `getStorageProof` test with todo
franciszekjob 0842ce5
Fix linting
franciszekjob c77b48b
Remove error-related changes
franciszekjob 6683874
Add missing params in KDoc
franciszekjob ddea038
Update tests
franciszekjob a1358d9
Rename todo; Fix `getMessagesStatus` name
franciszekjob 74f35a2
Rename todos
franciszekjob ff8e36a
Merge branch 'main' into feat/519-rpc-0.8.0
franciszekjob 13d81ad
Fix `NodeHashToNodeMapping`
franciszekjob 9097231
Fix linting
franciszekjob 1384afd
Merge branch 'feat/519-rpc-0.8.0' of https://github.com/software-mans…
franciszekjob 54d16f6
Update `getStorageProof`
franciszekjob bbd417c
Fix linting
franciszekjob b34bb52
Fix typo in `GetMessagesStatusResponse`
franciszekjob 4bf6139
Refactor `getMessagesStatus`
franciszekjob 97796fa
Update todo text
franciszekjob 475a7f7
Fix transaction hash calculator tests
franciszekjob 9a55b18
Update lib/src/main/kotlin/com/swmansion/starknet/data/types/Response…
franciszekjob 836a456
Update lib/src/main/kotlin/com/swmansion/starknet/data/types/Payloads.kt
franciszekjob b734973
Fix `GetMessagesStatusResponse`
franciszekjob c6b4806
Merge branch 'feat/519-rpc-0.8.0' of https://github.com/software-mans…
franciszekjob 2725046
Add `MessageStatusList` data class and serializer
franciszekjob 18ad358
Fix linting
franciszekjob 54d4402
Change return type of `getStorageProof` to `HttpRequest<StorageProof>`
franciszekjob 8688732
Refactor `NodeHashToNodeMappingItem`; Add `BinaryNode` and `EdgeNode`
franciszekjob 797911f
Fix linting
franciszekjob 11d2eaa
Remove unnecessarily added failure reason from tx receipt
franciszekjob 6614380
Refactor passing resource bounds
franciszekjob 303317f
Fix linting
franciszekjob a183504
Update `DeclareParamsV3` and `InvokeParamsV3` constructor params
franciszekjob 635c6a6
Fix resource bounds params in `StandardAccount`
franciszekjob a380e39
Fix linting
franciszekjob 3af0e5c
Add fixes for resource bounds
franciszekjob 63b8bd8
Fix linting
franciszekjob 1e6190b
Rename `computationResources` to executionResources`
franciszekjob a8722bb
Update mock jsons in tests
franciszekjob 5688593
Add `InnerCallExecutionResources`
franciszekjob 8f3061f
Add `DataResources` sealed class
franciszekjob 96dbac3
Fix linting
franciszekjob 25fe29c
Rename `DataResources` to `Resources`
franciszekjob 2b1c478
Restore `JvmName` annotation in `Resources.kt`
franciszekjob 8215452
Remove unnecessary formatting changes
franciszekjob 4ae1582
Add `ResourceBoundsMapping.ZERO`
franciszekjob f5c88a8
Add `MerkleNodeSerializer`
franciszekjob edc9f9f
Fix linting
franciszekjob e675851
Refactor `MerkleNodeSerializer.deserialize`
franciszekjob e3a29c4
Fix linting
franciszekjob 202dc74
Add tests for `getMessageStatus` and `getStorageProof`
franciszekjob 35c7ca8
Fix linting
franciszekjob b297869
Change merkle node serializer to polymorphic
franciszekjob b584d1e
Add `MerkleNodeTest`
franciszekjob 475a068
Fix linting
franciszekjob 1719520
Remove test for `getStorageProof` with invalid merkle nodes
franciszekjob d7ee2ec
Update values in `MerkleNodeTest`
franciszekjob d56d2ae
Fix typo in `contracts_storage_keys`
franciszekjob 20a7ab4
Rename `ContractStorageKey` to `ContractStorageKeys`
franciszekjob f541cf0
Rename file `ContractStorageKey` to `ContractStorageKeys`
franciszekjob 7853259
Rename `key` to `storageKeys`
franciszekjob 0c3a2c1
Make `blockId` optional in `getStorageProof`
franciszekjob 0a36ee7
Make `blockId` optional in `JsonRpcProvider.getStorageProof`
franciszekjob 7518f18
Change `path` type to `NumAsHex`
franciszekjob 1c8a7e0
Revert optional block id changes
franciszekjob 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 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 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
21 changes: 21 additions & 0 deletions
21
...rc/main/kotlin/com/swmansion/starknet/data/serializers/MerkleNodePolymorphicSerializer.kt
This file contains 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,21 @@ | ||
import com.swmansion.starknet.data.types.* | ||
import kotlinx.serialization.DeserializationStrategy | ||
import kotlinx.serialization.descriptors.elementNames | ||
import kotlinx.serialization.json.JsonContentPolymorphicSerializer | ||
import kotlinx.serialization.json.JsonElement | ||
import kotlinx.serialization.json.jsonObject | ||
|
||
internal object MerkleNodePolymorphicSerializer : | ||
JsonContentPolymorphicSerializer<NodeHashToNodeMappingItem.MerkleNode>(NodeHashToNodeMappingItem.MerkleNode::class) { | ||
override fun selectDeserializer(element: JsonElement): DeserializationStrategy<NodeHashToNodeMappingItem.MerkleNode> { | ||
val jsonElement = element.jsonObject | ||
val binaryNodeKeys = NodeHashToNodeMappingItem.BinaryNode.serializer().descriptor.elementNames.toSet() | ||
val edgeNodeKeys = NodeHashToNodeMappingItem.EdgeNode.serializer().descriptor.elementNames.toSet() | ||
|
||
return when (jsonElement.keys) { | ||
binaryNodeKeys -> NodeHashToNodeMappingItem.BinaryNode.serializer() | ||
edgeNodeKeys -> NodeHashToNodeMappingItem.EdgeNode.serializer() | ||
else -> throw IllegalArgumentException("Invalid MerkleNode JSON object: $jsonElement") | ||
} | ||
} | ||
} | ||
27 changes: 27 additions & 0 deletions
27
lib/src/main/kotlin/com/swmansion/starknet/data/serializers/MessageStatusListSerializer.kt
This file contains 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,27 @@ | ||
package com.swmansion.starknet.data.serializers | ||
|
||
import com.swmansion.starknet.data.types.MessageStatus | ||
import com.swmansion.starknet.data.types.MessageStatusList | ||
import kotlinx.serialization.ExperimentalSerializationApi | ||
import kotlinx.serialization.KSerializer | ||
import kotlinx.serialization.builtins.ListSerializer | ||
import kotlinx.serialization.descriptors.SerialDescriptor | ||
import kotlinx.serialization.descriptors.listSerialDescriptor | ||
import kotlinx.serialization.encoding.Decoder | ||
import kotlinx.serialization.encoding.Encoder | ||
|
||
internal object MessageStatusListSerializer : KSerializer<MessageStatusList> { | ||
private val listSerializer = ListSerializer(MessageStatus.serializer()) | ||
|
||
@OptIn(ExperimentalSerializationApi::class) | ||
override val descriptor: SerialDescriptor = listSerialDescriptor<MessageStatus>() | ||
|
||
override fun serialize(encoder: Encoder, value: MessageStatusList) { | ||
encoder.encodeSerializableValue(listSerializer, value.values) | ||
} | ||
|
||
override fun deserialize(decoder: Decoder): MessageStatusList { | ||
val list = decoder.decodeSerializableValue(listSerializer) | ||
return MessageStatusList(list) | ||
} | ||
} |
This file contains 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
13 changes: 13 additions & 0 deletions
13
lib/src/main/kotlin/com/swmansion/starknet/data/types/ContractStorageKeys.kt
This file contains 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,13 @@ | ||
package com.swmansion.starknet.data.types | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ContractStorageKeys( | ||
@SerialName("contract_address") | ||
val contractAddress: Felt, | ||
|
||
@SerialName("storage_keys") | ||
val storageKeys: List<Felt>, | ||
) |
7 changes: 7 additions & 0 deletions
7
lib/src/main/kotlin/com/swmansion/starknet/data/types/MessageStatusList.kt
This file contains 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,7 @@ | ||
package com.swmansion.starknet.data.types | ||
|
||
import com.swmansion.starknet.data.serializers.MessageStatusListSerializer | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable(with = MessageStatusListSerializer::class) | ||
data class MessageStatusList(val values: List<MessageStatus>) : StarknetResponse |
This file contains 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 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: We could potentially give an error with more meaningful message (saying which fields are missing and if it's binary/edge node). However, in case of json with keys that belong both to binary and edge node
e.g.
we can't clearly decide which type it is intended to be (binary/edge). I'm not fully sure if such logic is worth introducing.
A simple improvement would be to display required keys for binary/edge nodes.