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

Lack of Support for Logging Messages from console.log to msg! in Poseidon #26

Open
ritikbhatt20 opened this issue Oct 28, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ritikbhatt20
Copy link

  • Currently, there is no support for logging msgs in Solana Programs from Poseidon.

  • When transpiling Poseidon code to Anchor, the logging functionality provided by console.log! calls is not preserved and not converted to msg! in Anchor.

Example Poseidon code -

import { Account, Pubkey, Result, u32 } from "@solanaturbine/poseidon";

export default class ProcessingInstructionsProgram {
  static PROGRAM_ID = new Pubkey(
    "DgoL5J44aspizyUs9fcnpGEUJjWTLJRCfx8eYtUMYczf"
  );

  go_to_park(height: u32, name: String): Result {
    // Display a welcome message
    console.log("Welcome to the park,", name);
    // Check if the height is above the threshold
    if (Number(height) > 5) {
      console.log("You are tall enough to ride this ride. Congratulations.");
    } else {
      console.log("You are NOT tall enough to ride this ride. Sorry mate.");
    }
  }
}

and the transpiled Anchor code:

use anchor_lang::prelude::*;
declare_id!("DgoL5J44aspizyUs9fcnpGEUJjWTLJRCfx8eYtUMYczf");
#[program]
pub mod processing_instructions_program {
    use super::*;
    pub fn go_to_park(
        ctx: Context<GoToParkContext>,
        height: u32,
        name: String,
    ) -> Result<()> {
        Ok(())
    }
}
#[derive(Accounts)]
pub struct GoToParkContext<'info> {}

Adding this msg! logging feature can be particularly useful for displaying informational messages, such as whether a user meets certain conditions.

@ritikbhatt20 ritikbhatt20 changed the title Lack of Support for Logging Messages Using msg! in Poseidon Lack of Support for Logging Messages from console.log to msg! in Poseidon Oct 28, 2024
@ShrinathNR ShrinathNR added enhancement New feature or request good first issue Good for newcomers labels Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants