Skip to content

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

@ritikbhatt20

Description

@ritikbhatt20
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions