Skip to content

Commit

Permalink
Fix type of signature in auth (#1110)
Browse files Browse the repository at this point in the history
### What
Change the type of the signature in custom auth from Vec<Val> to Val.

### Why
The protocol and env don't actually require it to be a Vec anymore, and
so the SDK is limiting the type unnecessarily.
  • Loading branch information
leighmcculloch authored Oct 19, 2023
1 parent 24f9f74 commit fdd5027
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion soroban-sdk/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub trait CustomAccountInterface {
fn __check_auth(
env: Env,
signature_payload: BytesN<32>,
signatures: Vec<Self::Signature>,
signatures: Self::Signature,
auth_contexts: Vec<Context>,
) -> Result<(), Self::Error>;
}
16 changes: 6 additions & 10 deletions soroban-sdk/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,10 +1036,10 @@ impl Env {
/// pub fn __check_auth(
/// _env: Env,
/// _signature_payload: BytesN<32>,
/// signatures: Vec<Val>,
/// signature: Val,
/// _auth_context: Vec<Context>,
/// ) -> Result<(), NoopAccountError> {
/// if signatures.is_empty() {
/// if signature.is_void() {
/// Err(NoopAccountError::SomeError)
/// } else {
/// Ok(())
Expand All @@ -1057,7 +1057,7 @@ impl Env {
/// e.try_invoke_contract_check_auth::<NoopAccountError>(
/// &account_contract.address,
/// &BytesN::random(&e),
/// &vec![&e],
/// ().into(),
/// &vec![&e],
/// ),
/// // The inner `Result` is for conversion error and will be Ok
Expand All @@ -1070,7 +1070,7 @@ impl Env {
/// e.try_invoke_contract_check_auth::<soroban_sdk::Error>(
/// &account_contract.address,
/// &BytesN::random(&e),
/// &vec![&e, 0_i32.into()],
/// 0_i32.into(),
/// &vec![&e],
/// ),
/// Ok(())
Expand All @@ -1081,16 +1081,12 @@ impl Env {
&self,
contract: &Address,
signature_payload: &BytesN<32>,
signatures: &Vec<Val>,
signature: Val,
auth_context: &Vec<auth::Context>,
) -> Result<(), Result<E, E::Error>> {
let args = Vec::from_array(
self,
[
signature_payload.to_val(),
signatures.to_val(),
auth_context.to_val(),
],
[signature_payload.to_val(), signature, auth_context.to_val()],
);
let res = self
.host()
Expand Down

0 comments on commit fdd5027

Please sign in to comment.