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
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
aa8745c
feat : added declare v0
May 26, 2024
ecf3596
feat : added declare common function
May 27, 2024
8a05ffd
feat : fixed mismatch types
May 28, 2024
d77d90a
feat : added declare v0 deps and testing done
May 31, 2024
9342f36
removed setup dir
May 31, 2024
69f2ee0
feat : removed uneccessary logs
May 31, 2024
2a7f977
added pr title in changelog
May 31, 2024
a6c9126
fix : fixed prettier issues
May 31, 2024
0d1185f
feat : added requested changes
May 31, 2024
205151f
feat : added requested changes 2
Jun 1, 2024
73a0f05
feat : added requested changes 2
Jun 1, 2024
e848d97
Merge branch 'main' into main
ocdbytes Jun 1, 2024
3c2f7ef
lint test fix
Jun 1, 2024
d8df267
lint test fix
Jun 1, 2024
3767dbb
feat : added new requested changes : formatting and redundant code re…
Jun 3, 2024
6b9615f
Merge pull request #1 from ocdbytes/declareV0/feat
ocdbytes Jun 3, 2024
840f38b
lint issue fixed
Jun 3, 2024
62b6cd9
feat : rpc test fix & declare v0 rpc test added
Jun 3, 2024
bd5dec7
feat : fixed lint issues
Jun 3, 2024
90951ee
fix declare V0 test
Jun 3, 2024
e73623e
feat : fix lint issues
Jun 3, 2024
90c7620
feat : fix lint issues
Jun 3, 2024
f7d0f59
fix : added rpc test fixes
Jun 3, 2024
96c529c
feat : refactoring and comments added
Jun 17, 2024
f68fd03
Merge branch 'main' into main
ocdbytes Jun 17, 2024
0fb2574
refactor : changed program_vec to program_bytes
Jun 19, 2024
c0e504a
add_declare_transaction_v0 e2e
tdelabro Jun 19, 2024
ee50d2d
Merge pull request #2 from tdelabro/add-declare-transaction-v0
ocdbytes Jun 19, 2024
ea34185
fix : lint
Jun 19, 2024
54033cf
feat : refactor and removed unused deps
Jun 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions crates/client/rpc-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ pub struct DeclareV0Result {
pub class_hash: ClassHash,
}

/// CustomDeclareV0Transaction
/// This will be given as an input to the rpc body
///
/// **declare_transaction** : DeclareTransactionV0V1 struct constructed before calling.
///
/// **program_vec** : Program vector is program from `ClassInfo` struct converted into Vector.
tdelabro marked this conversation as resolved.
Show resolved Hide resolved
///
/// **entrypoints** : Entrypoints are taken from `ClassInfo` struct.
///
/// **abi_length** : ABI length calculated from abi in `LegacyContractClass`.
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
tdelabro marked this conversation as resolved.
Show resolved Hide resolved
pub struct CustomDeclareV0Transaction {
pub declare_transaction: DeclareTransactionV0V1,
Expand Down
4 changes: 2 additions & 2 deletions crates/client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ where
G: GenesisProvider + Send + Sync + 'static,
H: HasherT + Send + Sync + 'static,
{
fn _get_txn_hash(&self, transaction: DeclareTransactionV0V1) -> TransactionHash {
fn get_txn_hash(&self, transaction: DeclareTransactionV0V1) -> TransactionHash {
let txn = starknet_api::transaction::DeclareTransaction::V0(transaction);
txn.compute_hash(Felt252Wrapper::from(self.chain_id().unwrap().0), false)
}
Expand Down Expand Up @@ -314,7 +314,7 @@ where
}

async fn declare_v0_contract(&self, params: mc_rpc_core::CustomDeclareV0Transaction) -> RpcResult<DeclareV0Result> {
let txn_hash: TransactionHash = self._get_txn_hash(params.declare_transaction.clone());
let txn_hash: TransactionHash = self.get_txn_hash(params.declare_transaction.clone());

let program_decoded = Program::decode_all(&mut params.program_vec.as_slice()).map_err(|e| {
log::debug!("error: {:?}", e);
Expand Down
10 changes: 10 additions & 0 deletions crates/client/rpc/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ pub enum ParseTokenError {
ParseFailed(ParseIntError),
}

/// CustomDeclareV0Transaction
/// This will be given as an input to the rpc body
///
/// **declare_transaction** : DeclareTransactionV0V1 struct constructed before calling.
///
/// **program_vec** : Program vector is program from `ClassInfo` struct converted into Vector.
///
/// **entrypoints** : Entrypoints are taken from `ClassInfo` struct.
///
/// **abi_length** : ABI length calculated from abi in `LegacyContractClass`.
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
pub struct CustomDeclareV0Transaction {
pub declare_transaction: DeclareTransactionV0V1,
Expand Down
17 changes: 0 additions & 17 deletions crates/pallets/starknet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,23 +568,6 @@ pub mod pallet {
// This ensures that the function can only be called via unsigned transaction.
ensure_none(origin)?;

// Check class hash is not already declared
ensure!(
!ContractClasses::<T>::contains_key(transaction.tx().class_hash().0),
Error::<T>::ClassHashAlreadyDeclared
);

let tx_version = transaction.tx().version();

// Avoiding account checks for V0 declares as they don't need to originate from an existing account
if tx_version != TransactionVersion::ZERO {
// Check if contract is deployed
ensure!(
ContractClassHashes::<T>::contains_key(transaction.tx().sender_address()),
Error::<T>::AccountNotDeployed
);
}

let mut state = BlockifierStateAdapter::<T>::default();
let charge_fee = !<T as Config>::DisableTransactionFee::get();

Expand Down
Loading