Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return value for counter #4

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(())
}
Loading