Skip to content

Commit

Permalink
Merge branch 'main' into update-credits
Browse files Browse the repository at this point in the history
  • Loading branch information
broody committed Oct 21, 2024
2 parents b7b6393 + b64d007 commit 32f5711
Show file tree
Hide file tree
Showing 17 changed files with 19,660 additions and 19,376 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ webauthn-authenticator-rs = { git = "https://github.com/cartridge-gg/webauthn-rs
"softpasskey",
] }

cainome = { git = "https://github.com/cartridge-gg/cainome", tag = "v0.4.2", features = [
cainome = { git = "https://github.com/cartridge-gg/cainome", tag = "v0.4.5", features = [
"abigen-rs",
] }

Expand Down
2 changes: 1 addition & 1 deletion Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ alexandria_merkle_tree = { git = "https://github.com/piniom/quaireaux.git", rev
alexandria_data_structures = { git = "https://github.com/piniom/quaireaux.git", rev = "b51ccc3" }
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.27.0" }
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", rev = "a13bae3" }
argent = { git = "https://github.com/cartridge-gg/argent-contracts-starknet.git", rev = "946530f" }
argent = { git = "https://github.com/cartridge-gg/argent-contracts-starknet.git", rev = "1bb7404" }
28 changes: 25 additions & 3 deletions docs/docs/vrf/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,16 @@ In order to execute a transaction that includes a `consume_random` call, you nee

```js
const call = await account.execute([
// Prefix the multicall with the
// Prefix the multicall with the request_random call
{
contractAddress: VRF_PROVIDER_ADDRESS,
entrypoint: 'request_random',
calldata: CallData.compile({
caller: GAME_CONTRACT,
// Using Source::Nonce(address)
source: [0, address],
source: {type: 0, address: account.address},
// Using Source::Salt(felt252)
// source: {type: 1, salt: 0x123}
}),
},
{
Expand All @@ -110,7 +112,27 @@ const call = await account.execute([

**Ensure that you call `consume_random` with the same `Source` as used in `request_random`.**

By following these steps, you can integrate the VRF Provider into your Starknet contract and generate verifiable random numbers for your onchain game or application.
### Important: Adding VRF to Policies

When using the Cartridge Controller with VRF, make sure to add the VRF contract address and the `request_random` method to your policies. This allows the controller to pre-approve VRF-related transactions, ensuring a seamless experience for your users.

Add the following policy to your existing policies:

```typescript
const policies: Policy[] = [
// ... your existing policies ...
{
target: VRF_PROVIDER_ADDRESS,
method: "request_random",
description: "Allows requesting random numbers from the VRF provider",
},
];
```

This ensures that VRF-related transactions can be executed without requiring additional user approval each time.

By following these steps, you can integrate the VRF Provider into your Starknet contract and generate verifiable random
numbers for your onchain game or application.

## Security Assumptions

Expand Down
2 changes: 1 addition & 1 deletion packages/account-wasm/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl CartridgeAccount {

#[wasm_bindgen(js_name = executeFromOutside)]
pub async fn execute_from_outside(
&self,
&mut self,
calls: Vec<JsCall>,
) -> std::result::Result<JsValue, JsControllerError> {
set_panic_hook();
Expand Down
2 changes: 1 addition & 1 deletion packages/account-wasm/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl CartridgeSessionAccount {
execute_after: 0_u64,
execute_before: now + 600,
calls,
nonce: (SigningKey::from_random().secret_scalar(), Felt::ZERO),
nonce: (SigningKey::from_random().secret_scalar(), 1),
};

let signed = self
Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit 32f5711

Please sign in to comment.