Skip to content

Commit

Permalink
make everything pub
Browse files Browse the repository at this point in the history
  • Loading branch information
billythedummy committed Jul 29, 2023
1 parent 509c15f commit e5128fa
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- document `--program-id` default values in `--help`
- all internal modules are now `pub` to allow people to use the library

## [0.2.0] - 2023-07-30

Expand Down
2 changes: 1 addition & 1 deletion solores/src/idl_format/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ The main `IdlFormat` trait defines
- how to deserialize the IDL file
- how to generate rust code from the deserialized struct

Currently each IDL format is completely isolated from each other in its own folder with no common code shared between them. This allows for independent evolution of each format at the cost of (a lot of) duplicated code. Might refactor this in the future.
Currently each IDL format is completely isolated from each other in its own folder with minimum common code shared between them. This allows for independent evolution of each format at the cost of (a lot of) duplicated code. Might refactor this in the future.
4 changes: 2 additions & 2 deletions solores/src/idl_format/anchor/typedefs/typedef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ impl ToTokens for EnumVariant {
}
}

const PUBKEY_TOKEN: &str = "Pubkey";
pub const PUBKEY_TOKEN: &str = "Pubkey";

fn primitive_or_pubkey_to_token(s: &str) -> String {
pub fn primitive_or_pubkey_to_token(s: &str) -> String {
if s == "publicKey" {
PUBKEY_TOKEN.to_owned()
} else if s == "string" {
Expand Down
4 changes: 2 additions & 2 deletions solores/src/idl_format/shank/typedefs/typedef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ impl ToTokens for EnumVariant {
}
}

const PUBKEY_TOKEN: &str = "Pubkey";
pub const PUBKEY_TOKEN: &str = "Pubkey";

fn primitive_or_pubkey_to_token(s: &str) -> String {
pub fn primitive_or_pubkey_to_token(s: &str) -> String {
if s == "publicKey" {
PUBKEY_TOKEN.to_owned()
} else if s == "string" {
Expand Down
12 changes: 7 additions & 5 deletions solores/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ use idl_format::IdlFormat;

use crate::idl_format::{anchor::AnchorIdl, shank::ShankIdl};

mod idl_format;
mod utils;
mod write_cargotoml;
mod write_gitignore;
mod write_src;
// Just make all mods pub to allow ppl to use the lib

pub mod idl_format;
pub mod utils;
pub mod write_cargotoml;
pub mod write_gitignore;
pub mod write_src;

use write_cargotoml::write_cargotoml;
use write_gitignore::write_gitignore;
Expand Down
10 changes: 5 additions & 5 deletions solores/src/write_cargotoml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn write_cargotoml(args: &Args, idl: &dyn IdlFormat) -> std::io::Result<()>
}

#[derive(Serialize)]
struct CargoToml<'a> {
pub struct CargoToml<'a> {
package: Package<'a>,
dependencies: GeneratedCrateDependencies<'a>,
}
Expand Down Expand Up @@ -50,14 +50,14 @@ impl<'a> CargoToml<'a> {
}

#[derive(Serialize)]
struct Package<'a> {
pub struct Package<'a> {
name: &'a str,
version: &'a str,
edition: &'a str,
}

#[derive(Serialize)]
struct GeneratedCrateDependencies<'a> {
pub struct GeneratedCrateDependencies<'a> {
borsh: DependencyValue<'a>,

#[serde(rename = "solana-program")]
Expand All @@ -74,7 +74,7 @@ struct GeneratedCrateDependencies<'a> {
num_traits: Option<DependencyValue<'a>>,
}

struct DependencyValue<'a>(&'a str);
pub struct DependencyValue<'a>(&'a str);

impl Serialize for DependencyValue<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
Expand All @@ -88,7 +88,7 @@ impl Serialize for DependencyValue<'_> {
}
}

struct OptionalDependencyValue<'a>(&'a str);
pub struct OptionalDependencyValue<'a>(&'a str);

impl Serialize for OptionalDependencyValue<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
Expand Down

0 comments on commit e5128fa

Please sign in to comment.