Skip to content

Commit

Permalink
return value for counter
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-neon committed Jun 5, 2024
1 parent 23d713a commit b0c63c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM solanalabs/rust:1.73.0 AS builder
RUN rustup toolchain install nightly
RUN rustup component add clippy --toolchain nightly
FROM solanalabs/rust:1.75.0 AS builder
RUN rustup toolchain install 1.75.0
RUN rustup component add clippy --toolchain 1.75.0
WORKDIR /opt
RUN sh -c "$(curl -sSfL https://release.solana.com/beta/install)" && \
/root/.local/share/solana/install/active_release/bin/sdk/sbf/scripts/install.sh
ENV PATH=/root/.local/share/solana/install/active_release/bin:/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN solana-install init 1.18.14
RUN rustup update

COPY . /opt
Expand All @@ -25,4 +26,4 @@ FROM ubuntu:20.04
COPY --from=builder /opt/test-invoke-program/neon-test-invoke-program.sh /opt/deploy/test_invoke_program/
COPY --from=builder /root/.local/share/solana/install/active_release/bin/solana /opt/solana/bin/
COPY --from=builder /root/.local/share/solana/install/active_release/bin/solana-keygen /opt/solana/bin/
COPY --from=builder /opt/deploy /opt/deploy
COPY --from=builder /opt/deploy /opt/deploy
5 changes: 3 additions & 2 deletions counter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use solana_program::{
msg,
program_error::ProgramError,
pubkey::Pubkey,
program::set_return_data
};

mod state;
Expand All @@ -31,7 +32,7 @@ pub fn process_instruction(
process_increment_counter(accounts, instruction_data_inner)?;
}
_ => {
msg!("Error: unknown instruction {}", instruction_discriminant[0])
msg!("Error: unknown instruction {}", instruction_discriminant[0]);

}
}
Expand All @@ -53,7 +54,7 @@ pub fn process_increment_counter(
let mut counter = Counter::try_from_slice(&counter_account.try_borrow_mut_data()?)?;
counter.count += 1;
counter.serialize(&mut *counter_account.data.borrow_mut())?;

set_return_data(&counter.count.to_le_bytes());
msg!("Counter state incremented to {:?}", counter.count);
Ok(())
}

0 comments on commit b0c63c4

Please sign in to comment.