Skip to content

Commit

Permalink
Feat/all assets (#23)
Browse files Browse the repository at this point in the history
* Update error definitions

* Add missing assets and adjust max value lengths

* Normalice error definitions

* Remove duplicated asses
  • Loading branch information
neithanmo authored Jan 9, 2025
1 parent 18f5c9b commit 9ff3fc5
Show file tree
Hide file tree
Showing 5 changed files with 400 additions and 110 deletions.
52 changes: 30 additions & 22 deletions app/rust/src/parser/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,44 @@ use nom::error::ErrorKind;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum ParserError {
Ok = 0,

// Generic errors
NoData,
InitContextEmpty, // Added
InitContextEmpty,
DisplayIdxOutOfRange,
DisplayPageOutOfRange,
UnexpectedError,

// Method/Version related
UnexpectedMethod, // Added
UnexpectedVersion, // Added
UnexpectedCharacters, // Added
UnexpectedMethod,
UnexpectedVersion,
UnexpectedCharacters,

// Field related
DuplicatedField, // Added
MissingField, // Added
DuplicatedField,
MissingField,
UnexpectedField,

// Transaction related
UnknownTransaction, // Added
UnknownTransaction,
InvalidTransactionType,

// Plan related
SpendPlanError, // Added
OutputPlanError, // Added
DelegatePlanError, // Added
UndelegatePlanError, // Added
Ics20WithdrawalPlanError, // Added
SwapPlanError, // Added
ParameterHashError, // Added
EffectHashError, // Added
UndelegateClaimPlanError, // Added
SpendPlanError,
OutputPlanError,
DelegatePlanError,
UndelegatePlanError,
Ics20WithdrawalPlanError,
SwapPlanError,
ParameterHashError,
EffectHashError,
UndelegateClaimPlanError,

// Chain related
InvalidChainId,
UnexpectedChain, // Added
// Other existing variants remain unchanged
UnexpectedChain,

// Cryptographic and key-related errors
InvalidHashMode,
InvalidSignature,
InvalidPubkeyEncoding,
Expand Down Expand Up @@ -86,12 +93,13 @@ pub enum ParserError {
PrecisionTooLarge,
ClueCreationFailed,
InvalidAssetId,
// Additional variants from C enum
DetectionDataOverflow, // Added
ActionsOverflow, // Added
InvalidMetadata, // Added
DetectionDataOverflow,
ActionsOverflow,
InvalidMetadata,
InvalidSignatureLen,
Overflow,
NonIntegral,
UnexpectedValue,
}

impl From<ErrorKind> for ParserError {
Expand Down
106 changes: 62 additions & 44 deletions app/src/common/parser_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,69 +41,87 @@ extern "C" {
} while (0)

typedef enum {
// Generic errors
// Success
parser_ok = 0,

// Generic errors
parser_no_data,
parser_init_context_empty,
parser_display_idx_out_of_range,
parser_display_page_out_of_range,
parser_unexpected_error,
// Additional variants from Rust enum
parser_invalid_hash_mode, // Added
parser_invalid_signature, // Added
parser_invalid_pubkey_encoding, // Added
parser_invalid_address_version, // Added
parser_invalid_address_length, // Added
parser_invalid_type_id, // Added
parser_invalid_codec, // Added
parser_invalid_threshold, // Added
parser_invalid_network_id, // Added
parser_invalid_chain_id, // Added
parser_invalid_ascii_value, // Added
parser_invalid_timestamp, // Added
parser_invalid_staking_amount, // Added
parser_operation_overflows, // Added
parser_invalid_path, // Added
parser_invalid_length, // Added
parser_too_many_outputs, // Added
parser_unexpected_data, // Added
parser_invalid_clue_key, // Added
parser_invalid_tx_key, // Added
parser_invalid_fq, // Added
parser_invalid_detection_key, // Added
parser_invalid_fvk, // Added
parser_invalid_ivk, // Added
parser_invalid_key_len, // Added
parser_invalid_action_type, // Added
parser_invalid_precision, // Added
parser_precision_too_large, // Added
parser_clue_creation_failed, // Added
parser_invalid_asset_id, // Added
// Existing C enum variants
parser_unexpected_type,

// Method/Version related
parser_unexpected_method,
parser_unexpected_buffer_end,
parser_unexpected_value,
parser_unexpected_number_items,
parser_unexpected_version,
parser_unexpected_characters,
parser_unexpected_field,

// Field related
parser_duplicated_field,
parser_value_out_of_range,
parser_invalid_address,
parser_unexpected_chain,
parser_missing_field,
paser_unknown_transaction,
parser_detection_data_overflow,
parser_actions_overflow,
parser_unexpected_field,

// Transaction related
parser_unknown_transaction,
parser_invalid_transaction_type,

// Plan related
parser_spend_plan_error,
parser_output_plan_error,
parser_delegate_plan_error,
parser_undelegate_plan_error,
parser_ics20_withdrawal_plan_error,
parser_swap_plan_error,
parser_parameter_hash_error,
parser_effect_hash_error,
parser_undelegate_claim_plan_error,

// Chain related
parser_invalid_chain_id,
parser_unexpected_chain,

// Cryptographic and key-related errors
parser_invalid_hash_mode,
parser_invalid_signature,
parser_invalid_pubkey_encoding,
parser_invalid_address_version,
parser_invalid_address_length,
parser_invalid_type_id,
parser_invalid_codec,
parser_invalid_threshold,
parser_invalid_network_id,
parser_invalid_ascii_value,
parser_invalid_timestamp,
parser_invalid_staking_amount,
parser_unexpected_type,
parser_operation_overflows,
parser_unexpected_buffer_end,
parser_unexpected_number_items,
parser_value_out_of_range,
parser_invalid_address,
parser_invalid_path,
parser_invalid_length,
parser_too_many_outputs,
parser_unexpected_data,
parser_invalid_clue_key,
parser_invalid_tx_key,
parser_invalid_fq,
parser_invalid_detection_key,
parser_invalid_fvk,
parser_invalid_ivk,
parser_invalid_key_len,
parser_invalid_action_type,
parser_invalid_precision,
parser_precision_too_large,
parser_clue_creation_failed,
parser_invalid_asset_id,
parser_detection_data_overflow,
parser_actions_overflow,
parser_invalid_metadata,
parser_invalid_signature_len,
parser_overflow,
parser_non_integral,
parser_unexpected_value,
} parser_error_t;

typedef struct {
Expand Down
Loading

0 comments on commit 9ff3fc5

Please sign in to comment.