Skip to content

Commit

Permalink
Added missing error codes for InvalidDeploy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Zajkowski committed Dec 18, 2024
1 parent 069bdaf commit 402948c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions binary_port/src/error_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,12 @@ pub enum ErrorCode {
/// Pricing mode not supported
#[error("Pricing mode not supported")]
PricingModeNotSupported = 104,
/// Gas limit not supported
#[error("Gas limit not supported")]
InvalidDeployGasLimitNotSupported = 105,
/// Invalid runtime for Transaction::Deploy
#[error("Invalid runtime for Transaction::Deploy")]
InvalidDeployInvalidRuntime = 106,
}

impl TryFrom<u16> for ErrorCode {
Expand Down Expand Up @@ -443,6 +449,8 @@ impl TryFrom<u16> for ErrorCode {
102 => Ok(ErrorCode::InvalidTransactionExpectedBytesArguments),
103 => Ok(ErrorCode::InvalidTransactionMissingSeed),
104 => Ok(ErrorCode::PricingModeNotSupported),
105 => Ok(ErrorCode::InvalidDeployGasLimitNotSupported),
106 => Ok(ErrorCode::InvalidDeployInvalidRuntime),
_ => Err(UnknownErrorCode),
}
}
Expand Down Expand Up @@ -514,6 +522,8 @@ impl From<InvalidDeploy> for ErrorCode {
ErrorCode::InvalidDeployUnableToCalculateGasCost
}
InvalidDeploy::GasPriceToleranceTooLow { .. } => ErrorCode::GasPriceToleranceTooLow,
InvalidDeploy::GasLimitNotSupported => ErrorCode::InvalidDeployGasLimitNotSupported,
InvalidDeploy::InvalidRuntime => ErrorCode::InvalidDeployInvalidRuntime,
_ => ErrorCode::InvalidDeployUnspecified,
}
}
Expand Down
2 changes: 1 addition & 1 deletion node/src/types/transaction/meta_transaction/meta_deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl MetaDeploy {
} else {
// Seems like chainspec didn't have any wasm lanes configured
Err(InvalidTransaction::Deploy(
InvalidDeploy::InvalidChainspecConfiguration,
InvalidDeploy::ChainspecHasNoWasmLanesDefined,
))
}
}
Expand Down
6 changes: 3 additions & 3 deletions types/src/transaction/deploy/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub enum InvalidDeploy {
InvalidRuntime,

//Invalida chainspec configuration - seems that chainspec has no wasm lanes defined
InvalidChainspecConfiguration,
ChainspecHasNoWasmLanesDefined,
}

impl Display for InvalidDeploy {
Expand Down Expand Up @@ -269,7 +269,7 @@ impl Display for InvalidDeploy {
InvalidDeploy::InvalidRuntime => {
write!(formatter, "invalid runtime",)
}
InvalidDeploy::InvalidChainspecConfiguration => write!(formatter, "chainspec didnt have any wasm lanes defined which is required for wasm based deploys",),
InvalidDeploy::ChainspecHasNoWasmLanesDefined => write!(formatter, "chainspec didnt have any wasm lanes defined which is required for wasm based deploys",),
}
}
}
Expand Down Expand Up @@ -307,7 +307,7 @@ impl StdError for InvalidDeploy {
| InvalidDeploy::UnableToCalculateGasCost
| InvalidDeploy::GasPriceToleranceTooLow { .. }
| InvalidDeploy::InvalidRuntime
| InvalidDeploy::InvalidChainspecConfiguration => None,
| InvalidDeploy::ChainspecHasNoWasmLanesDefined => None,
}
}
}
Expand Down

0 comments on commit 402948c

Please sign in to comment.