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 starknet_addDeclareTransaction JSON-RPC endpoint #318

Merged
merged 9 commits into from
Jun 2, 2022

Conversation

kkovaacs
Copy link
Contributor

@kkovaacs kkovaacs commented Jun 1, 2022

This JSON-RPC endpoint is a proxy that forwards data received to the Starknet sequencer, just like other write API methods we have.

This PR also adds some missing fields to the sequencer::reply::transaction::Transaction type that are required so that we can parse the new DECLARE transaction JSON.

Comment on lines +13 to +16
/// The hash of a StarkNet class.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, PartialOrd, Ord)]
pub struct ClassHash(pub StarkHash);

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is the same as ContractHash? We should consider renaming things to be align with the new class concepts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it's the same (conceptually).

According to the documentation the contract hash contains the constructor arguments, which classes won't have.

Copy link
Contributor

Choose a reason for hiding this comment

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

constructor arguments

Where do you see this? Entry point is not an argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, you're right, I probably misread that... So should we call this a ContractHash or a ClassHash (which seems to be a name Starkware uses both in the documentation and in the OpenRPC specs)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They seem to have just renamed contract hash to class hash...

The contract_hash cairo function has been renamed to class_hash.

Copy link
Contributor

Choose a reason for hiding this comment

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

This PR is already 10 files so I'd go with type alias or something, with a todo to rename all...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, renaming ContractHash will be an extensive change, I can do that in a new PR.

Copy link
Member

@CHr15F0x CHr15F0x left a comment

Choose a reason for hiding this comment

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

Would be nice to have an example added too

crates/pathfinder/src/core.rs Outdated Show resolved Hide resolved
@kkovaacs
Copy link
Contributor Author

kkovaacs commented Jun 1, 2022

Would be nice to have an example added too

I've added an example. (Note that it's not working yet since the testnet sequencer doesn't support declare transactions at the moment.)

@kkovaacs kkovaacs marked this pull request as ready for review June 2, 2022 07:28
@kkovaacs kkovaacs merged commit e6489eb into main Jun 2, 2022
@kkovaacs kkovaacs deleted the krisztian/pathfinder-0.9-rpc-update branch June 2, 2022 08:09
@kkovaacs kkovaacs mentioned this pull request Jun 8, 2022
5 tasks
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.

4 participants