-
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
Update TypedData in line with SNIP-12 #428
Merged
Merged
Conversation
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
- Add `revision`, `domainObjectName` helper fields to `TypedData` - Add new restrictions on types introduced in SNIP-12 - Move versioned `reservedTypes` to companion object
- All fields handled as JsonPrimitives - Allow `chainId` and `chain_id` (should be verified if `chain_id` is valid for revision 0)
- Add type specific references, arrays - Add `extractEnumTypes` helper - Adjust tests to not have any dangling types
- Add `MerkleHashFunction` enum - `MerkleTree` now accepts `hashFunction` as an optinal argument - (breaking) `MerkleTree.hash` now requires `hashFunction` to be specified
- Rename `domainObjectName` to `domainSeparatorName` - Format `referencedTypes` logic for better readability
- Remove @JsonNames from `TypedData.Domain` - Fix `TD_SESSION` test case in `TypedDataTest` - Use `chainId` instead of `chain_id` in `typed_data_session_example.json`
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #428 +/- ##
==========================================
+ Coverage 70.55% 71.11% +0.55%
==========================================
Files 75 75
Lines 3186 3337 +151
Branches 316 366 +50
==========================================
+ Hits 2248 2373 +125
- Misses 789 797 +8
- Partials 149 167 +18 ☔ View full report in Codecov by Sentry. |
- Move to package com.swmansion.starknet.crypto - Implement using abstract function instead of stored lambda
- Add revision-based `hashMethod`, `hashArray()` - Use `hashArray()` for hasing arrays - Instantiate `MerkleTree` with `hashMethod`
- Support REV1 enum types - Support getting dep from contains for merkletree (this should probably be verified) - Refactor logic
- Support revision 0 type named enum
DelevoXDG
commented
Mar 13, 2024
THenry14
reviewed
Mar 15, 2024
…parentheses from both sidews - Only `(example_name)` is not allowed, `(example_name` and `example_name)` are now considered valid
This was referenced Mar 18, 2024
THenry14
approved these changes
Mar 18, 2024
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.
💪
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Describe your changes
This PR is part of the stack:
-- Update TypedData in line with SNIP-12 (#428)
-- Use sealed classes for basic and preset types (#440)
-- Add separate methods for primitives (#442)
-- Nest TypedData-related test cases (#434)
TypedData Revision 0 and Revision 1
bool
basic typeDomain
class; Use it fordomain
instead ofJsonObject
Revision
enumraw
basic type; Don't allowmerkletree
withraw
leaves typeTypeBase
->Type
Type
->StandardType
TypedData Revision 1
enum
,string
(long string),u128
,i128
,ContractAddress
,ClassHash
,timestamp
,shortstring
EnumType
TokenAddress
,NtfId
,u256
RenameAddtypes
->customTypes
; Addtypes
to handlecustomTypes
+presetTypes
allTypes
to handletypes
+presetTypes
Other
HashMethod
enum to hash multiple elementsLinked issues
Closes #423
Breaking changes
TypedData.domain
is now of typeTypedData.Domain
instead ofJsonObject
TypedData.Type
->TypedData.StandardType
,TypedData.TypeBase
->TypedData.Type
raw
basic typeReferences
(might come in handy for reviews)