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

Extract decode-error from solana-program #1813

Merged
merged 4 commits into from
Jul 17, 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
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ members = [
"sdk/atomic-u64",
"sdk/cargo-build-sbf",
"sdk/cargo-test-sbf",
"sdk/decode-error",
"sdk/gen-headers",
"sdk/macro",
"sdk/package-metadata-macro",
Expand Down Expand Up @@ -350,6 +351,7 @@ solana-connection-cache = { path = "connection-cache", version = "=2.1.0", defau
solana-core = { path = "core", version = "=2.1.0" }
solana-cost-model = { path = "cost-model", version = "=2.1.0" }
solana-curve25519 = { path = "curves/curve25519", version = "=2.1.0" }
solana-decode-error = { path = "sdk/decode-error", version = "=2.1.0" }
solana-define-syscall = { path = "define-syscall", version = "=2.1.0" }
solana-download-utils = { path = "download-utils", version = "=2.1.0" }
solana-entry = { path = "entry", version = "=2.1.0" }
Expand Down
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ solana-client = { workspace = true }
solana-compute-budget = { workspace = true }
solana-config-program = { workspace = true }
solana-connection-cache = { workspace = true }
solana-decode-error = { workspace = true }
solana-loader-v4-program = { workspace = true }
solana-logger = { workspace = true }
solana-program-runtime = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use {
display::println_name_value, CliSignature, CliValidatorsSortOrder, OutputFormat,
},
solana_client::connection_cache::ConnectionCache,
solana_decode_error::DecodeError,
solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_rpc_client::rpc_client::RpcClient,
solana_rpc_client_api::{
Expand All @@ -23,7 +24,6 @@ use {
solana_sdk::{
clock::{Epoch, Slot},
commitment_config::CommitmentConfig,
decode_error::DecodeError,
hash::Hash,
instruction::InstructionError,
offchain_message::OffchainMessage,
Expand Down
10 changes: 10 additions & 0 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions programs/sbf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ solana-bpf-loader-program = { path = "../bpf_loader", version = "=2.1.0" }
solana-cli-output = { path = "../../cli-output", version = "=2.1.0" }
solana-compute-budget = { path = "../../compute-budget", version = "=2.1.0" }
solana-curve25519 = { path = "../../curves/curve25519", version = "=2.1.0" }
solana-decode-error = { path = "../../sdk/decode-error", version = "=2.1.0" }
solana-ledger = { path = "../../ledger", version = "=2.1.0" }
solana-log-collector = { path = "../../log-collector", version = "=2.1.0" }
solana-logger = { path = "../../logger", version = "=2.1.0" }
Expand Down
1 change: 1 addition & 0 deletions programs/sbf/rust/error_handling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ edition = { workspace = true }
[dependencies]
num-derive = { workspace = true }
num-traits = { workspace = true }
solana-decode-error = { workspace = true }
solana-program = { workspace = true }
thiserror = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion programs/sbf/rust/error_handling/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ extern crate solana_program;
use {
num_derive::FromPrimitive,
num_traits::FromPrimitive,
solana_decode_error::DecodeError,
solana_program::{
account_info::AccountInfo,
decode_error::DecodeError,
entrypoint::ProgramResult,
msg,
program_error::{PrintProgramError, ProgramError},
Expand Down
1 change: 1 addition & 0 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ serde_with = { workspace = true, features = ["macros"] }
sha2 = { workspace = true }
sha3 = { workspace = true, optional = true }
siphasher = { workspace = true }
solana-decode-error = { workspace = true }
solana-frozen-abi = { workspace = true, optional = true }
solana-frozen-abi-macro = { workspace = true, optional = true }
solana-program = { workspace = true }
Expand Down
16 changes: 16 additions & 0 deletions sdk/decode-error/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "solana-decode-error"
description = "Solana DecodeError Trait"
documentation = "https://docs.rs/solana-decode-error"
version = { workspace = true }
authors = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
edition = { workspace = true }

[dependencies]
num-traits = { workspace = true }

[dev-dependencies]
num-derive = { workspace = true }
File renamed without changes.
1 change: 1 addition & 0 deletions sdk/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ serde_derive = { workspace = true }
sha2 = { workspace = true }
sha3 = { workspace = true }
solana-atomic-u64 = { workspace = true }
solana-decode-error = { workspace = true }
solana-frozen-abi = { workspace = true, optional = true }
solana-frozen-abi-macro = { workspace = true, optional = true }
solana-sanitize = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion sdk/program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,6 @@ pub mod bpf_loader_upgradeable;
pub mod clock;
pub mod compute_units;
pub mod debug_account_data;
pub mod decode_error;
pub mod ed25519_program;
pub mod entrypoint;
pub mod entrypoint_deprecated;
Expand Down Expand Up @@ -592,6 +591,8 @@ pub mod sdk_ids {
}
}

#[deprecated(since = "2.1.0", note = "Use `solana-decode-error` crate instead")]
pub use solana_decode_error as decode_error;
/// Same as [`declare_id`] except that it reports that this ID has been deprecated.
pub use solana_sdk_macro::program_declare_deprecated_id as declare_deprecated_id;
/// Convenience macro to declare a static public key and functions to interact with it.
Expand Down
3 changes: 2 additions & 1 deletion sdk/program/src/program_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#[cfg(feature = "borsh")]
use borsh::io::Error as BorshIoError;
use {
crate::{decode_error::DecodeError, instruction::InstructionError, msg, pubkey::PubkeyError},
crate::{instruction::InstructionError, msg, pubkey::PubkeyError},
num_traits::{FromPrimitive, ToPrimitive},
solana_decode_error::DecodeError,
std::convert::TryFrom,
thiserror::Error,
};
Expand Down
3 changes: 2 additions & 1 deletion sdk/program/src/pubkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ use arbitrary::Arbitrary;
#[cfg(feature = "borsh")]
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use {
crate::{decode_error::DecodeError, hash::hashv},
crate::hash::hashv,
bytemuck_derive::{Pod, Zeroable},
num_derive::{FromPrimitive, ToPrimitive},
solana_decode_error::DecodeError,
std::{
convert::{Infallible, TryFrom},
fmt, mem,
Expand Down
2 changes: 1 addition & 1 deletion sdk/program/src/stake/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::stake::config;
use {
crate::{
clock::{Epoch, UnixTimestamp},
decode_error::DecodeError,
instruction::{AccountMeta, Instruction},
program_error::ProgramError,
pubkey::Pubkey,
Expand All @@ -16,6 +15,7 @@ use {
log::*,
num_derive::{FromPrimitive, ToPrimitive},
serde_derive::{Deserialize, Serialize},
solana_decode_error::DecodeError,
thiserror::Error,
};

Expand Down
2 changes: 1 addition & 1 deletion sdk/program/src/system_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
#[allow(deprecated)]
use {
crate::{
decode_error::DecodeError,
instruction::{AccountMeta, Instruction},
nonce,
pubkey::Pubkey,
system_program,
sysvar::{recent_blockhashes, rent},
},
num_derive::{FromPrimitive, ToPrimitive},
solana_decode_error::DecodeError,
thiserror::Error,
};

Expand Down
2 changes: 1 addition & 1 deletion sdk/program/src/vote/error.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Vote program errors

use {
crate::decode_error::DecodeError,
num_derive::{FromPrimitive, ToPrimitive},
solana_decode_error::DecodeError,
thiserror::Error,
};

Expand Down
9 changes: 5 additions & 4 deletions sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,15 @@ pub use solana_program::{
account_info, address_lookup_table, alt_bn128, big_mod_exp, blake3, bpf_loader,
bpf_loader_deprecated, bpf_loader_upgradeable, clock, config, custom_heap_default,
custom_panic_default, debug_account_data, declare_deprecated_sysvar_id, declare_sysvar_id,
decode_error, ed25519_program, epoch_rewards, epoch_schedule, fee_calculator, impl_sysvar_get,
incinerator, instruction, keccak, lamports, loader_instruction, loader_upgradeable_instruction,
loader_v4, loader_v4_instruction, message, msg, native_token, nonce, program, program_error,
ed25519_program, epoch_rewards, epoch_schedule, fee_calculator, impl_sysvar_get, incinerator,
instruction, keccak, lamports, loader_instruction, loader_upgradeable_instruction, loader_v4,
loader_v4_instruction, message, msg, native_token, nonce, program, program_error,
program_memory, program_option, program_pack, rent, secp256k1_program, serde_varint,
serialize_utils, short_vec, slot_hashes, slot_history, stable_layout, stake, stake_history,
syscalls, system_instruction, system_program, sysvar, unchecked_div_by_const, vote,
};
#[cfg(feature = "borsh")]
pub use solana_program::{borsh, borsh0_10, borsh1};

pub mod account;
pub mod account_utils;
pub mod client;
Expand Down Expand Up @@ -110,6 +109,8 @@ pub mod transaction_context;
pub mod transport;
pub mod wasm;

#[deprecated(since = "2.1.0", note = "Use `solana-decode-error` crate instead")]
pub use solana_decode_error as decode_error;
#[deprecated(since = "2.1.0", note = "Use `solana-sanitize` crate instead")]
pub use solana_sanitize as sanitize;
/// Same as `declare_id` except report that this id has been deprecated.
Expand Down
6 changes: 2 additions & 4 deletions sdk/src/precompiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
#![cfg(feature = "full")]

use {
crate::{
decode_error::DecodeError, feature_set::FeatureSet, instruction::CompiledInstruction,
pubkey::Pubkey,
},
crate::{feature_set::FeatureSet, instruction::CompiledInstruction, pubkey::Pubkey},
lazy_static::lazy_static,
solana_decode_error::DecodeError,
thiserror::Error,
};

Expand Down