Skip to content

Commit

Permalink
bump cainome and slot
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy committed Sep 11, 2024
1 parent 5c02c7f commit b49b5f2
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 38 deletions.
131 changes: 108 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ inherits = "release"
lto = "fat"

[workspace.dependencies]
cainome = { git = "https://github.com/cartridge-gg/cainome", rev = "fb91215", features = [ "abigen-rs" ] }
cainome = { git = "https://github.com/cartridge-gg/cainome", rev = "0d29bb0", features = [ "abigen-rs" ] }
dojo-utils = { path = "crates/dojo-utils" }

# metrics
Expand Down Expand Up @@ -235,7 +235,7 @@ criterion = "0.5.1"
# yet atm. Dojo depends on Slot and Slot depends on Controller, the version of Controller (account_sdk)
# must be the same across all stack as their API are being used against each other.
account_sdk = { git = "https://github.com/cartridge-gg/controller", rev = "0b5c318" }
slot = { git = "https://github.com/cartridge-gg/slot", tag = "v0.9.0" }
slot = { git = "https://github.com/cartridge-gg/slot", tag = "v0.13.0" }

alloy-contract = { version = "0.2", default-features = false }
alloy-json-rpc = { version = "0.2", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions crates/katana/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ anyhow.workspace = true
katana-cairo.workspace = true
katana-provider = { workspace = true, features = [ "test-utils" ] }
katana-rpc-types.workspace = true
num-traits.workspace = true
rstest.workspace = true
rstest_reuse.workspace = true
serde_json.workspace = true
Expand Down
46 changes: 34 additions & 12 deletions crates/katana/executor/tests/fixtures/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ use katana_primitives::genesis::allocation::GenesisAllocation;
use katana_primitives::genesis::constant::DEFAULT_FEE_TOKEN_ADDRESS;
use katana_primitives::genesis::Genesis;
use katana_primitives::transaction::ExecutableTxWithHash;
use katana_primitives::utils::transaction::compute_invoke_v1_tx_hash;
use katana_primitives::FieldElement;
use num_traits::ToPrimitive;
use starknet::accounts::{Account, ExecutionEncoder, ExecutionEncoding, SingleOwnerAccount};
use starknet::core::types::{
BlockId, BlockTag, BroadcastedInvokeTransaction, BroadcastedInvokeTransactionV1, Call,
Expand All @@ -31,8 +33,8 @@ pub fn invoke_executable_tx(
let signer = LocalWallet::from_signing_key(SigningKey::from_secret_scalar(private_key));

let mut account = SingleOwnerAccount::new(
provider,
signer.clone(),
&provider,
&signer,
address.into(),
chain_id.into(),
ExecutionEncoding::New,
Expand All @@ -46,24 +48,44 @@ pub fn invoke_executable_tx(
calldata: vec![felt!("0x1"), felt!("0x99"), felt!("0x0")],
}];

let is_query = false;
let tx = account.execute_v1(calls.clone()).nonce(nonce).max_fee(max_fee).prepared().unwrap();
let hash = tx.transaction_hash(is_query);
let calldata = account.encode_calls(&calls);
let hash = compute_invoke_v1_tx_hash(
account.address(),
&calldata,
max_fee.to_u128().unwrap(),
chain_id.into(),
nonce,
false,
);

let rt = tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap();
let signature = rt.block_on(signer.sign_hash(&hash)).unwrap();
let signature = if signed {
let signature = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
.block_on(signer.sign_hash(&hash))
.unwrap();

vec![signature.r, signature.s]
} else {
vec![]
};

let broadcasted_tx = BroadcastedInvokeTransactionV1 {
let mut starknet_rs_broadcasted_tx = BroadcastedInvokeTransactionV1 {
nonce,
max_fee,
is_query,
calldata,
signature,
is_query: false,
sender_address: account.address(),
calldata: account.encode_calls(&calls),
signature: if signed { vec![signature.r, signature.s] } else { vec![] },
};

if !signed {
starknet_rs_broadcasted_tx.signature = vec![]
}

let tx = katana_rpc_types::transaction::BroadcastedInvokeTx(BroadcastedInvokeTransaction::V1(
broadcasted_tx,
starknet_rs_broadcasted_tx,
))
.into_tx_with_chain_id(chain_id);

Expand Down
2 changes: 1 addition & 1 deletion crates/katana/rpc/rpc/tests/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ async fn deploy_account(
Ok(())
}

abigen_legacy!(Erc20Contract, "crates/katana/rpc/rpc/tests/test_data/erc20.json");
abigen_legacy!(Erc20Contract, "crates/katana/rpc/rpc/tests/test_data/erc20.json", derives(Clone));

#[tokio::test]
async fn estimate_fee() -> Result<()> {
Expand Down

0 comments on commit b49b5f2

Please sign in to comment.