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

RPC 0.6.0 cleanup #381

Merged
merged 66 commits into from
Feb 7, 2024
Merged

RPC 0.6.0 cleanup #381

merged 66 commits into from
Feb 7, 2024

Conversation

DelevoXDG
Copy link
Contributor

@DelevoXDG DelevoXDG commented Dec 27, 2023

Describe your changes

Refactoring and cleanup post #358. Includes missing transaction v3 functionalities, more streamlined interface, bug fixes and tests covering Starknet 0.13 features.

  • Account, StandardAccount
    • all methods that have v1, v2 and v3 variants now have V1, V2, V3 postfixes respectively
    • estimateFeeV(1|3) no longer accepts Set<SimulationFlagForEstimateFee>, instead takes skipValidate: Bool
    • Add missing estimateFeeV3(Call)
    • executeV3 estimates incorrect fee #396
  • Deployer, StandardDeployer: Add deployContractV3 methods ; rename deployContract ->deployContractV1
  • Rename ExecutionParamsV3 -> InvokeParamsV3
  • Restrict usage of v3 fields
    • TransactionPayload: make primary constructor private; add custom constructor with hardcoded values
    • TransactionFactory: don't accept v3 transaction params
  • Add DeprecatedTransaction and TransactionV3 interfaces
  • Unify JsonRpcErrors #393
  • Fix declare v3 payload for fee estimate
  • StarknetChainId: Rename SEPOLIA_TESTNET->SEPOLIA, renamed SEPOLIA_INTEGRATOIN->INTEGATION_SEPOLIA (should we remove enum altogether?)
  • Add missing RPC 0.6.0 tests
    • TransactionHashCalculator: test v3s; add missing declare v1/v2 tests
    • Rename FeltTests -> NumAsHexBaseTests ; test all numbers; nest Felt-specific tests; add Uint256 tets
    • StandardAccountTest
      • Nest test cases: add DeclareEstimateTest, DeclareTests, DeployAccountEstimateTest, DeployAccountTest, DeployAccountEstimateTest
      • Add missing v3 tests (simulateTransactions, estimateFee)
      • Add estimate fee with SKIP_VALIDATE test
    • StandardDeployerTest: test deploy v3
      • Remove contract_with_constructor.cairo (no longer used in tests)

Linked issues

Closes #402
Closes #372
Closes #393
Closes #395
Closes #396
Closes #374

Breaking changes

  • This issue contains breaking changes
  • Account, StandardAccount: all methods that have v1, v2 and v3 variants now have V1, V2, V3 postfixes respectively
  • Deployer, StandardDeployer: deployContract split into deployContractV1 and deployContractV3
  • estimateFeeV(1|3) no longer accepts Set<SimulationFlagForEstimateFee>, instead takes skipValidate: Bool
  • Removed transaction v3 parameters (tip, paymasterData, accountDeploymentData, nonceDataAvailabilityMode, feeDataAvailabilityMode) from TransactionPayload constructors
  • Removed transaction v3 parameters (tip, paymasterData, accountDeploymentData, nonceDataAvailabilityMode, feeDataAvailabilityMode) from TransactionFactory methods
  • Renamed ExecutionParamsV3 -> InvokeParamsV3
  • StarknetChainId: Renamed SEPOLIA_TESTNET->SEPOLIA, renamed SEPOLIA_INTEGRATOIN->INTEGATION_SEPOLIA,

@DelevoXDG DelevoXDG closed this Dec 27, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jan 23, 2024

Codecov Report

Attention: 19 lines in your changes are missing coverage. Please review.

Comparison is base (dffff47) 67.64% compared to head (2616060) 69.29%.

Files Patch % Lines
.../com/swmansion/starknet/account/StandardAccount.kt 69.69% 9 Missing and 1 partial ⚠️
...on/starknet/data/types/transactions/Transaction.kt 78.26% 5 Missing ⚠️
...knet/data/types/transactions/TransactionPayload.kt 92.50% 2 Missing and 1 partial ⚠️
...n/kotlin/com/swmansion/starknet/account/Account.kt 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #381      +/-   ##
==========================================
+ Coverage   67.64%   69.29%   +1.65%     
==========================================
  Files          72       72              
  Lines        3171     3127      -44     
  Branches      322      315       -7     
==========================================
+ Hits         2145     2167      +22     
+ Misses        863      810      -53     
+ Partials      163      150      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@DelevoXDG DelevoXDG mentioned this pull request Jan 31, 2024
1 task
Comment on lines -213 to -217
tip = tip,
paymasterData = paymasterData,
accountDeploymentData = accountDeploymentData,
nonceDataAvailabilityMode = nonceDataAvailabilityMode,
feeDataAvailabilityMode = feeDataAvailabilityMode,
Copy link
Contributor Author

@DelevoXDG DelevoXDG Jan 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also make primary constructor private similarly to TransactionPayload, v3 params and so on, and create constructor with hardcoded fields? I decided to not do it for now:

  1. to not further clutter the PR
  2. because there were previously some non-rpc fields and we didn't hardcode anything
  3. we mainly use TransactionFactory to correctly create Transaction objects anyway

This would be easily solved with #394, but we decided to do it separately.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need, I suppose

@DelevoXDG DelevoXDG marked this pull request as ready for review January 31, 2024 13:21
Copy link
Member

@THenry14 THenry14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

glanced through tests
let's remember about carefully describing this changes in changelog, when new version is released

@@ -146,21 +170,6 @@ data class InvokeTransactionV1(
version = version,
)
}

companion object {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this no longer needed?

Copy link
Contributor Author

@DelevoXDG DelevoXDG Feb 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use it anywhere, I'm not sure if we ever did use it. I couldn't find it being used in #197 (PR where it was added). Since this is an internal method and we don't use it anywhere internally, I don't think we need it.

Comment on lines -213 to -217
tip = tip,
paymasterData = paymasterData,
accountDeploymentData = accountDeploymentData,
nonceDataAvailabilityMode = nonceDataAvailabilityMode,
feeDataAvailabilityMode = feeDataAvailabilityMode,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need, I suppose

Comment on lines -39 to +36
@Serializable(with = JsonRpcStandardErrorSerializer::class)
internal data class JsonRpcStandardError(
@SerialName("code")
override val code: Int,

@SerialName("message")
override val message: String,

@SerialName("data")
override val data: String? = null,
) : JsonRpcError()

@Serializable
internal data class JsonRpcContractError(
@SerialName("code")
override val code: Int,

@SerialName("message")
override val message: String,

@SerialName("data")
override val data: JsonRpcContractErrorData,
) : JsonRpcError()

@Serializable
internal data class JsonRpcContractErrorData(
@SerialName("revert_error")
val revertError: String,
) {
override fun toString(): String {
return revertError
}
}
val data: String? = null,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this change related to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unification of JsonRpcErrors (#393)

Initial approach (#373) was to add dataclasses for the new RPC 0.6.0 errors, but we decided to unify those and accept any data as a String instead

Copy link
Member

@THenry14 THenry14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, I guess 😅

@DelevoXDG DelevoXDG merged commit b824ce7 into main Feb 7, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants