Skip to content

Commit

Permalink
use versioned types
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy committed Jun 26, 2024
1 parent 971edc5 commit 4b9af21
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions crates/rs-macro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ The expansion of the macros generates the following:
.await
.expect("Call to `get_my_struct` failed");
```
- For each **external**, the contract type contains a function with the same arguments. Calling the function return a `starknet::accounts::Execution` type from `starknet-rs`, which allows you to completly customize the fees, doing only a simulation etc... To actually send the transaction, you use the `send()` method on the `Execution` struct. You can find the [associated methods with this struct on starknet-rs repo](https://github.com/xJonathanLEI/starknet-rs/blob/0df9ad3417a5f10d486348737fe75659ca4bcfdc/starknet-accounts/src/account/execution.rs#L118).
- For each **external**, the contract type contains a function with the same arguments. Calling the function return a `starknet::accounts::ExecutionV1` type from `starknet-rs`, which allows you to completly customize the fees, doing only a simulation etc... To actually send the transaction, you use the `send()` method on the `ExecutionV1` struct. You can find the [associated methods with this struct on starknet-rs repo](https://github.com/xJonathanLEI/starknet-rs/blob/0df9ad3417a5f10d486348737fe75659ca4bcfdc/starknet-accounts/src/account/execution.rs#L118).

```rust
let my_struct = MyStruct {
Expand All @@ -135,7 +135,7 @@ The expansion of the macros generates the following:
.expect("Call to `set_my_struct` failed");
```

To support multicall, currently `Execution` type does not expose the `Call`s.
To support multicall, currently `ExecutionV1` type does not expose the `Call`s.
To circumvey this, for each of the external function an other function with `_getcall` suffix is generated:

```rust
Expand Down
8 changes: 4 additions & 4 deletions crates/rs/src/expand/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//! based on it's state mutability found in the ABI itself.
//!
//! * `FCall` - Struct for readonly functions.
//! * `Execution` - Struct from starknet-rs for transaction based functions.
//! * `ExecutionV1` - Struct from starknet-rs for transaction based functions.
use cainome_parser::tokens::{Function, FunctionOutputKind, StateMutability, Token};
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
Expand Down Expand Up @@ -102,7 +102,7 @@ impl CairoFunction {
}
},
StateMutability::External => {
// For now, Execution can't return the list of calls.
// For now, ExecutionV1 can't return the list of calls.
// This would be helpful to easily access the calls
// without having to add `_getcall()` method.
// If starknet-rs provides a way to get the calls,
Expand Down Expand Up @@ -133,7 +133,7 @@ impl CairoFunction {
pub fn #func_name_ident(
&self,
#(#inputs),*
) -> starknet::accounts::Execution<A> {
) -> starknet::accounts::ExecutionV1<A> {
use #ccs::CairoSerde;

let mut __calldata = vec![];
Expand All @@ -145,7 +145,7 @@ impl CairoFunction {
calldata: __calldata,
};

self.account.execute(vec![__call])
self.account.execute_v1(vec![__call])
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/simple_get_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async fn main() {
// the full control from starknet-rs library.
let _tx_res = contract
.account
.execute(vec![set_a_call, set_b_call])
.execute_v1(vec![set_a_call, set_b_call])
.send()
.await
.expect("Multicall failed");
Expand Down

0 comments on commit 4b9af21

Please sign in to comment.