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

Switch some auth errors from Internal to InvalidInput. #976

Merged
merged 2 commits into from
Aug 1, 2023
Merged
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
28 changes: 12 additions & 16 deletions soroban-env-host/src/native_contract/account_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,23 @@ impl AuthorizationContext {
xdr::ContractExecutable::Wasm(wasm_hash) => {
BytesN::<32>::from_slice(host, wasm_hash.as_slice())?
}
xdr::ContractExecutable::Token => {
return Err(host.err(
ScErrorType::Auth,
ScErrorCode::InternalError,
"unexpected auth context for create contract host fn",
&[],
))
}
xdr::ContractExecutable::Token => return Err(host.err(
ScErrorType::Auth,
ScErrorCode::InvalidInput,
"token executable is not allowed when authorizing create_contract host fn",
&[],
)),
};
let salt = match &args.contract_id_preimage {
ContractIdPreimage::Address(id_from_addr) => {
BytesN::<32>::from_slice(host, id_from_addr.salt.as_slice())?
}
ContractIdPreimage::Asset(_) => {
return Err(host.err(
ScErrorType::Auth,
ScErrorCode::InternalError,
"unexpected auth context for create contract host fn",
&[],
))
}
ContractIdPreimage::Asset(_) => return Err(host.err(
ScErrorType::Auth,
ScErrorCode::InvalidInput,
"asset preimage is not allowed when authorizing create_contract host fn",
&[],
)),
};
Ok(AuthorizationContext::CreateContractHostFn(
CreateContractHostFnContext {
Expand Down