Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

feat: Declare V0 RPC call #1617

Merged
merged 30 commits into from
Jun 20, 2024
Merged

feat: Declare V0 RPC call #1617

merged 30 commits into from
Jun 20, 2024

Conversation

ocdbytes
Copy link
Contributor

@ocdbytes ocdbytes commented May 31, 2024

Added a RPC method to declare a V0 contract using the program and declare transaction using the 0x1 account.

Pull Request type

Feature

What is the current behaviour?

Declaring V0 using the 0x1 account is not possible from empty state in madara

What is the new behaviour?

RPC call is introduced for declaring the V0 contract using the program and declare call. Syntax is as follows :

/// Broadcasted declare contract transaction v0.
#[derive(Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BroadcastedDeclareTransactionV0 {
    /// The address of the account contract sending the declaration transaction
    pub sender_address: FieldElement,
    /// The maximal fee that can be charged for including the transaction
    pub max_fee: FieldElement,
    /// Signature
    pub signature: Vec<FieldElement>,
    /// The class to be declared
    pub contract_class: Arc<CompressedLegacyContractClass>,
    /// If set to `true`, uses a query-only transaction version that's invalid for execution
    pub is_query: bool,
}

let contract_abi_artifact: CompressedLegacyContractClass = serde_json::from_reader(
                std::fs::File::open(env!("CARGO_MANIFEST_DIR").to_owned() + "/" + &artifact_path).unwrap(),
            ).unwrap();

let params: BroadcastedDeclareTransactionV0 = BroadcastedDeclareTransactionV0 {
    sender_address: FieldElement::from_hex_be("0x1").unwrap(),
    max_fee: FieldElement::from(482250u128),
    signature: Vec::new(),
    contract_class: Arc::new(contract_abi_artifact),
    is_query: false,
};

let json_body = &json!({
    "jsonrpc": "2.0",
    "method": "madara_addDeclareTransactionV0",
    "params": [params],
    "id": 4
});

let req_client = reqwest::Client::new();
let raw_txn_rpc = req_client.post(url).json(json_body).send().await;

Does this introduce a breaking change?

No

@ocdbytes ocdbytes changed the title Feature : Declare V0 RPC call feat : Declare V0 RPC call May 31, 2024
@ocdbytes ocdbytes changed the title feat : Declare V0 RPC call feat: Declare V0 RPC call May 31, 2024
.gitignore Outdated Show resolved Hide resolved
crates/client/l1-gas-price/src/worker.rs Outdated Show resolved Hide resolved
crates/client/rpc-core/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc-core/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc-core/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc/src/lib.rs Outdated Show resolved Hide resolved
crates/pallets/starknet/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc-core/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc-core/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc-core/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc-core/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc/src/types.rs Outdated Show resolved Hide resolved
crates/pallets/starknet/src/lib.rs Outdated Show resolved Hide resolved
@tdelabro tdelabro self-requested a review June 17, 2024 20:07
crates/client/rpc-core/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc-core/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc-core/src/lib.rs Outdated Show resolved Hide resolved
crates/client/rpc/src/types.rs Outdated Show resolved Hide resolved
@tdelabro
Copy link
Collaborator

hey @ocdbytes, can you review this: ocdbytes#2
and then merge it into your branch please
It implements the rpc in a more coherent way, in regard to the rest of the codebase

crates/client/rpc-core/src/lib.rs Show resolved Hide resolved
crates/client/rpc/Cargo.toml Outdated Show resolved Hide resolved
crates/pallets/starknet/src/lib.rs Show resolved Hide resolved
starknet-rpc-test/Cargo.toml Outdated Show resolved Hide resolved
@tdelabro tdelabro merged commit f5dce7e into keep-starknet-strange:main Jun 20, 2024
15 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants