forked from stellar/rs-soroban-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue stellar#1406: Update lib.rs to see the expected output when…
… deploying the Increment contract
- Loading branch information
Yoshihiro Kawamoto
authored and
Yoshihiro Kawamoto
committed
Dec 13, 2024
1 parent
13f16d4
commit 71a5ec6
Showing
1 changed file
with
31 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#![no_std] | ||
// use soroban_sdk::{contract, contractimpl, vec, Env, String, Vec}; | ||
use soroban_sdk::{contract, contractimpl, log, symbol_short, Env, Symbol}; | ||
|
||
// const COUNTER: Symbol = Symbol::new("counter"); | ||
const COUNTER: Symbol = symbol_short!("COUNTER"); | ||
|
||
#[contract] | ||
pub struct Contract; | ||
|
||
#[contractimpl] | ||
impl Contract { | ||
// pub fn hello(env: Env, to: String) -> Vec<String> { | ||
// vec![&env, String::from_str(&env, "Hello"), to] | ||
|
||
pub fn increment(env: Env) -> u32 { | ||
let mut count: u32 = env.storage().instance().get(&COUNTER).unwrap_or(0); | ||
|
||
count += 1; | ||
|
||
log!(&env, "count: {}", count); | ||
|
||
env.storage().instance().set(&COUNTER, &count); | ||
|
||
env.storage().instance().extend_ttl(100, 100); | ||
|
||
count | ||
} | ||
} | ||
|
||
mod test; |