-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
292 additions
and
447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,14 @@ | ||
# Website | ||
# Documentation | ||
|
||
This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator. | ||
Welcome to the documentation for the Cartridge Account SDK. | ||
|
||
### Installation | ||
## New Guides | ||
|
||
``` | ||
$ pnpm i | ||
``` | ||
- [Using the Controller in Rust](docs/controller/using_controller_rust.md) | ||
- [Using the Controller in TypeScript](docs/controller/using_controller_typescript.md) | ||
- [Sessions and Configuration](docs/controller/sessions_and_configuration.md) | ||
- [Examples](docs/controller/examples.md) | ||
|
||
### Local Development | ||
## Contributing | ||
|
||
``` | ||
$ pnpm book start | ||
``` | ||
|
||
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. | ||
|
||
### Build | ||
|
||
``` | ||
$ pnpm book build | ||
``` | ||
|
||
This command generates static content into the `build` directory and can be served using any static contents hosting service. | ||
|
||
### Deployment | ||
|
||
Using SSH: | ||
|
||
``` | ||
$ USE_SSH=true pnpm book deploy | ||
``` | ||
|
||
Not using SSH: | ||
|
||
``` | ||
$ GIT_USER=<Your GitHub username> pnpm book deploy | ||
``` | ||
|
||
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. | ||
We welcome contributions! Please refer to the [contribution guidelines](CONTRIBUTING.md). |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
* * * | ||
|
||
title: Using Controller in Rust | ||
|
||
## sidebar_position: 2 | ||
|
||
## Using Controller in Rust | ||
|
||
### Installation | ||
|
||
Add the `account_sdk` crate to your `Cargo.toml`: | ||
|
||
```toml | ||
[dependencies] | ||
account_sdk = { git = "https://github.com/cartridge-gg/controller", package = "account_sdk" } | ||
starknet = "0.10" # Make sure to use a compatible version | ||
``` | ||
|
||
### Importing Necessary Modules | ||
|
||
```rust | ||
use account_sdk::{ | ||
controller::Controller, | ||
signers::Signer, | ||
}; | ||
use starknet::{ | ||
accounts::Account, | ||
providers::Provider, | ||
signers::SigningKey, | ||
core::types::FieldElement, | ||
}; | ||
``` | ||
|
||
### Setting Up the Controller | ||
|
||
Initialize the controller with necessary parameters: | ||
|
||
```rust | ||
#[tokio::main] | ||
async fn main() { | ||
// Create a signer (replace with your own private key) | ||
let owner = Signer::Starknet(SigningKey::from_secret_scalar(FieldElement::from_hex_be("0xYourPrivateKey").unwrap())); | ||
// Initialize the provider (replace with your RPC URL) | ||
let provider = Provider::try_from("https://api.cartridge.gg/x/starknet/sepolia").unwrap(); | ||
let chain_id = provider.chain_id().await.unwrap(); | ||
|
||
// Create a new Controller instance | ||
let username = "testuser".to_string(); | ||
let controller = Controller::new( | ||
"your_app_id".to_string(), | ||
username.clone(), | ||
FieldElement::from_hex_be("0xYourClassHash").unwrap(), // Class hash | ||
"https://api.cartridge.gg/x/starknet/sepolia".parse().unwrap(), // RPC URL | ||
owner.clone(), | ||
FieldElement::from_hex_be("0xYourControllerAddress").unwrap(), // Controller address | ||
chain_id, | ||
); | ||
|
||
// Deploy the controller | ||
controller.deploy().await.unwrap(); | ||
|
||
// Interact with the controller | ||
// For example, execute a transaction | ||
let call = your_function_call(); // Define your function call | ||
controller.execute(vec![call], None).await.unwrap(); | ||
} | ||
``` | ||
|
||
### Performing Transactions | ||
|
||
Define function calls and execute them: | ||
|
||
```rust | ||
fn your_function_call() -> starknet::core::types::FunctionCall { | ||
starknet::core::types::FunctionCall { | ||
contract_address: FieldElement::from_hex_be("0xYourContractAddress").unwrap(), | ||
entry_point_selector: starknet::core::utils::get_selector_from_name("yourEntryPoint").unwrap(), | ||
calldata: vec![FieldElement::from(123)], // Replace with your calldata | ||
} | ||
} | ||
``` | ||
|
||
Execute the function call using the controller: | ||
|
||
```rust | ||
controller.execute(vec![your_function_call()], None).await.unwrap(); | ||
``` |
4 changes: 2 additions & 2 deletions
4
docs/docs/controller/starknet-react.md → docs/docs/examples/starknet-react.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.