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

Support Starknet 0.13 #129

Merged
merged 103 commits into from
Jan 24, 2024
Merged

Support Starknet 0.13 #129

merged 103 commits into from
Jan 24, 2024

Conversation

DelevoXDG
Copy link
Collaborator

@DelevoXDG DelevoXDG commented Jan 10, 2024

Describe your changes

Support RPC 0.6.0 with Starknet 0.13 limitations

  • Update transactions
  • Added support for invoking and deploying v3 transactions
    • Added new StarknetAccount methods: signV3, executeV3, estimateFeeV3, estimateDeployAccountFeeV3
    • Added v1 postfix to StarknetAccount methods related to v1 transactions
    • Added StarknetInvokeParamsV3 and StarknetDeployAccountParamsV3
    • StarknetExecutionParams and StarknetOptionalExecutionParams removed in favor of StarknetInvokeParamsV1, StarknetOptionalInvokeParamsV1 and StarknetDeployAccountV1
    • Provider.addInvokeTransaction now accepts any StarknetExecutableInvokeTransaction
    • Provider.addDeployAccountTransaction now accepts any StarknetExecutableDeployAccountTransaction
  • Added support for estimateFee simulation flags; Currently it's just SKIP_VALIDATE, it can be used by passing skipValidate = true to StarknetAccount fee estimation methods
  • Added new number types: UInt64AsHex, UInt128AsHex; Add clamped constructor to NumAsHexProtocol
  • Updated transaction receipts
    • actualFee is now of type StarknetFeePayment instead of Felt
  • Update StarknetExecutionResources
  • Added StarknetExecutionResources to StarknetFunctionInvocation
  • Added data field to JsonRpcError
  • StarknetAccount.sign(typedData: StarknetTypedData) adjusted for new error
  • Fix posedion hash for lists of 1 and 2 elements
  • Support strk prefund in DevnetClient
  • Bumped devnet on CI

Linked issues

Closes #124
Closes #128
Closes #89

Breaking changes

  • This issue contains breaking changes
  • StarknetAccountProtocol, StarknetAccount. sign, estimateFee, execute, signDeployAccount, estimateDeployFee are now split into two versions, with V1 and V3 postfix for transactions version 1 and 3 respectfully
  • Removed StarknetExecutionParams and StarknetOptionalExecutionParams; Use StarknetInvokeParamsV1, StarknetOptionalInvokeParamsV1 and StarknetDeployAccountV1 instead
  • StarknetProviderProtocol, StarknetProvider: estimateFee and simulateTransactions now only support transactions that conform to StarknetExecutableTransaction
  • StarknetTransactionReceipt: actualFee is now of type StarknetFeePayment instead of `Felt
  • StarknetExecutionResources fields are now of type Int instead of NumAsHex

- Add `StarknetDeprecatedTransaction` (v1, v2)
- Add `StarknetTransactionV3`
- Add `StarknetDeclareTransaction`, `StarknetDeployAccountTransaction`, `StarknetInvokeTransaction`
- Add `StarknetExecutableTransaction` (helpful for #128)
- Add `StarknetExecutableInvokeTransaction`, `StarknetExecutableDeployAccountTransaction`
- Make `value` type `BigUInt`
- Change to lowercase
}

let defaultBlockId = StarknetBlockId.tag(.pending)

let defaultSimulationFlagsForEstimateFee: Set<StarknetSimulationFlagForEstimateFee> = []
Copy link
Collaborator Author

@DelevoXDG DelevoXDG Jan 22, 2024

Choose a reason for hiding this comment

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

In Account estimateFee functions, I think we should (for now) default to passing the .skipValidate flag, since, as I remember, some nodes had problem validating signatures for txs with query versions.

As for Provider.estimateFee, I'm not sure, as Provider methods should probably be more explicit. Might be better to send request with no flags by default, or remove default value for simulation_flags altogether, as in simulateTransactions.

WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

In Account estimateFee functions, I think we should (for now) default to passing the .skipValidate flag, since, as I remember, some nodes had problem validating signatures for txs with query versions.

hmm, that's weird. was this checked with some newer nodes' releases? Do you happen to know if that was by design, or by mistake? Either way, I'm afraid we will set this up and not change it, ever. So (if that's by mistake) let's maybe pass on this idea, and push on nodes maintainers to fix this? If that's by design then you're right, and we can add this.

As for Provider.estimateFee, I'm not sure, as Provider methods should probably be more explicit. Might be better to send request with no flags by default, or remove default value for simulation_flags altogether, as in simulateTransactions.

I'd lean towards sending without flags by default, but up to you really

Copy link
Collaborator Author

@DelevoXDG DelevoXDG Jan 23, 2024

Choose a reason for hiding this comment

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

hmm, that's weird. was this checked with some newer nodes' releases?

Checked this now. Can't test all of it, since we don't have goerli testnet funds, but invoke and deploy account seem to work fine on goerli integraiton and sepolia integration as of now.

Do you happen to know if that was by design, or by mistake?

Query versions should work, so probably by mistake. The problem was also present on devnet and now seems to be resolved.

Considering this, it might be actually reasonable to not skipValidate by default.

- Rename StarknetDeployAccountParams -> StarknetDeployAccountParamsV3
- Rename StarknetInvokeParams -> StarknetInvokeParamsV3
- Split StarknetDeprecatedExecutionParams into StarknetInvokeParamsV1 and StarknetDeployAccountParamsV1
@DelevoXDG DelevoXDG merged commit 8a1040f into main Jan 24, 2024
1 check passed
@DelevoXDG DelevoXDG deleted the feat/124-starknet-0.13.0 branch January 24, 2024 13: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
3 participants