stylus_cache_sdk/
lib.rs

1extern crate alloc;
2
3/// Returns whether a contract is cacheable.
4/// This function can be imported and used directly in other contracts.
5pub fn is_contract_cacheable() -> bool {
6    true
7}
8
9/// To emit the `AutoCacheOptIn` event in your contract, include the following event definition:
10///
11/// ```rust
12/// use alloy_sol_types::sol;
13///
14/// sol! {
15///     event AutoCacheOptIn(address indexed contract_addr);
16/// }
17/// ```
18///
19/// Then, in your contract methods, emit the event using `stylus-sdk`'s event emission mechanism.
20/// For example (syntax may vary based on `stylus-sdk`):
21///
22/// ```rust
23/// #[public]
24/// impl YourContract {
25///     pub fn opt_in(&mut self) {
26///         // Emit the event with the contract's address
27///         self.emit(AutoCacheOptIn { contract_addr: self.address() });
28///     }
29/// }
30/// ```
31///
32/// Make sure to include `alloy-sol-types` as a dependency in your `Cargo.toml`:
33/// ```toml
34/// [dependencies]
35/// alloy-sol-types = "0.7.7"
36/// stylus-sdk = "0.4.3"
37/// ```
38#[cfg(test)]
39mod tests {
40    use super::*;
41
42    #[test]
43    fn test_is_contract_cacheable() {
44        assert!(is_contract_cacheable());
45    }
46}