Skip to content

Commit

Permalink
Fix issue stellar#1406: Update lib.rs to see the expected output when…
Browse files Browse the repository at this point in the history
… 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.
31 changes: 31 additions & 0 deletions soroban-hello-world/contracts/increment/src/lib.rs
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;

0 comments on commit 71a5ec6

Please sign in to comment.