Skip to content
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

Add StarknetMerkleTree and merkletree support in StarknetTypedData #167

Merged
merged 69 commits into from
Apr 8, 2024

Conversation

DelevoXDG
Copy link
Collaborator

@DelevoXDG DelevoXDG commented Mar 27, 2024

Stack

Describe your changes

Add StarknetMerkleTree and support for merkletree basic type in StarknetTypedData

StarknetMerkleTree

  • Add StarknetHashMethod.hash() for two elements;
  • Make StarknetHashMethod public
  • Add StraknetMerkleTree

StarknetTypedData

  • Add MerkleTreeType, StandardType; Convert TypeDeclaration to protocol
  • Add TypeDeclarationWrapper
  • Change types type from [String: [TypeDeclaration]] to [String: [TypeDeclarationWrapper]]
  • Other
    • Move Data/StarknetTypedData.swift to Data/TypedData/StarknetTypedData.swift
    • Move TypeDeclaration related extensions to Data/TypeDeclaration.swift

Linked issues

Closes

Breaking changes

  • This issue contains breaking changes
  • StarknetTypedData.TypeDeclaration is now a protocol; Use StarknetTypedData.StandardType instead
  • StarknetTypedData.types is now of type [String: [TypeDeclarationWrapper]] instead of [String: [TypeDeclaration]]

- Add `dataAvailability` to `StarknetExecutionResources`; Add `StarknetDataAvailability
  - Add `executionResources` to tx traces
- Add `StarknetComputationResources`
  - Add `computationResources` to `StarknetFunctionInvocation`
- Add `StarknetResources` protocol with common fields
- Prefund account with `5_000_000_000_000_000`->`5_000_000_000_000_000_000`
- Change max fee in declare methods to `1_000_000_000_000_000`->`10_000_000_000_000_000`
- Add `dataGasConsumed`, `dataGasPrice` fields to `StarknetFeeEstimate`
- Update `.toResourceBounds()` extension
  - Update overheads
  - Use new logic
… and `StarknetExecutionResources`

- Adjust tests
- Add `StarknetTypedData.Domain`, `StarknetTypedData.Revision`
- Change `domain` type: `[String: Element] -> Domain`
  - Update initializer
- Add `getStructHash(typeName: String, data: Data)`
- Add `getStructHash(domain: Domain)`
- Use correct escape chars for rev 1
- Rename test files `typed_data_[..].json`-> `typed_data_rev_0_[..].json`
- Add `typed_data_rev_1_example.json`
- Update `TypedDataTests`
  - Move old td cases to `CasesRev0`
  - Add `CasesRev1`
…otocol

- Add `TypeDeclarationWrapper`
- Change `types` type from `[String: [TypeDeclaration]]` to `[String: [TypeDeclarationWrapper]]`
Base automatically changed from feat/159-snip-12 to main April 5, 2024 13:57
@DelevoXDG DelevoXDG changed the title Add MerkleTree and merkletree support in StarknetTypedData Add StarknetMerkleTree and merkletree support in StarknetTypedData Apr 8, 2024
@DelevoXDG DelevoXDG merged commit edfd28c into main Apr 8, 2024
1 check passed
@DelevoXDG DelevoXDG deleted the feat/159-2-merkletree branch April 8, 2024 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants