@@ -346,7 +346,7 @@ impl Transaction {
346
346
/// #
347
347
/// # Ok::<(), anyhow::Error>(())
348
348
/// ```
349
- pub fn new < T : Signers > (
349
+ pub fn new < T : Signers + ? Sized > (
350
350
from_keypairs : & T ,
351
351
message : Message ,
352
352
recent_blockhash : Hash ,
@@ -501,7 +501,7 @@ impl Transaction {
501
501
/// #
502
502
/// # Ok::<(), anyhow::Error>(())
503
503
/// ```
504
- pub fn new_signed_with_payer < T : Signers > (
504
+ pub fn new_signed_with_payer < T : Signers + ? Sized > (
505
505
instructions : & [ Instruction ] ,
506
506
payer : Option < & Pubkey > ,
507
507
signing_keypairs : & T ,
@@ -526,7 +526,7 @@ impl Transaction {
526
526
///
527
527
/// Panics when signing fails. See [`Transaction::try_sign`] and for a full
528
528
/// description of failure conditions.
529
- pub fn new_with_compiled_instructions < T : Signers > (
529
+ pub fn new_with_compiled_instructions < T : Signers + ? Sized > (
530
530
from_keypairs : & T ,
531
531
keys : & [ Pubkey ] ,
532
532
recent_blockhash : Hash ,
@@ -705,7 +705,7 @@ impl Transaction {
705
705
/// #
706
706
/// # Ok::<(), anyhow::Error>(())
707
707
/// ```
708
- pub fn sign < T : Signers > ( & mut self , keypairs : & T , recent_blockhash : Hash ) {
708
+ pub fn sign < T : Signers + ? Sized > ( & mut self , keypairs : & T , recent_blockhash : Hash ) {
709
709
if let Err ( e) = self . try_sign ( keypairs, recent_blockhash) {
710
710
panic ! ( "Transaction::sign failed with error {e:?}" ) ;
711
711
}
@@ -731,7 +731,7 @@ impl Transaction {
731
731
/// handle the error. See the documentation for
732
732
/// [`Transaction::try_partial_sign`] for a full description of failure
733
733
/// conditions.
734
- pub fn partial_sign < T : Signers > ( & mut self , keypairs : & T , recent_blockhash : Hash ) {
734
+ pub fn partial_sign < T : Signers + ? Sized > ( & mut self , keypairs : & T , recent_blockhash : Hash ) {
735
735
if let Err ( e) = self . try_partial_sign ( keypairs, recent_blockhash) {
736
736
panic ! ( "Transaction::partial_sign failed with error {e:?}" ) ;
737
737
}
@@ -750,7 +750,7 @@ impl Transaction {
750
750
///
751
751
/// Panics if signing fails. Use [`Transaction::try_partial_sign_unchecked`]
752
752
/// to handle the error.
753
- pub fn partial_sign_unchecked < T : Signers > (
753
+ pub fn partial_sign_unchecked < T : Signers + ? Sized > (
754
754
& mut self ,
755
755
keypairs : & T ,
756
756
positions : Vec < usize > ,
@@ -843,7 +843,7 @@ impl Transaction {
843
843
/// #
844
844
/// # Ok::<(), anyhow::Error>(())
845
845
/// ```
846
- pub fn try_sign < T : Signers > (
846
+ pub fn try_sign < T : Signers + ? Sized > (
847
847
& mut self ,
848
848
keypairs : & T ,
849
849
recent_blockhash : Hash ,
@@ -906,7 +906,7 @@ impl Transaction {
906
906
/// [`PresignerError::VerificationFailure`]: crate::signer::presigner::PresignerError::VerificationFailure
907
907
/// [`solana-remote-wallet`]: https://docs.rs/solana-remote-wallet/latest/
908
908
/// [`RemoteKeypair`]: https://docs.rs/solana-remote-wallet/latest/solana_remote_wallet/remote_keypair/struct.RemoteKeypair.html
909
- pub fn try_partial_sign < T : Signers > (
909
+ pub fn try_partial_sign < T : Signers + ? Sized > (
910
910
& mut self ,
911
911
keypairs : & T ,
912
912
recent_blockhash : Hash ,
@@ -932,7 +932,7 @@ impl Transaction {
932
932
/// # Errors
933
933
///
934
934
/// Returns an error if signing fails.
935
- pub fn try_partial_sign_unchecked < T : Signers > (
935
+ pub fn try_partial_sign_unchecked < T : Signers + ? Sized > (
936
936
& mut self ,
937
937
keypairs : & T ,
938
938
positions : Vec < usize > ,
@@ -1668,4 +1668,22 @@ mod tests {
1668
1668
. unwrap_err ( ) ;
1669
1669
assert_eq ! ( err, SignerError :: KeypairPubkeyMismatch ) ;
1670
1670
}
1671
+
1672
+ #[ test]
1673
+ fn test_unsized_signers ( ) {
1674
+ fn instructions_to_tx (
1675
+ instructions : & [ Instruction ] ,
1676
+ signers : Box < dyn Signers > ,
1677
+ ) -> Transaction {
1678
+ let pubkeys = signers. pubkeys ( ) ;
1679
+ let first_signer = pubkeys. first ( ) . expect ( "should exist" ) ;
1680
+ let message = Message :: new ( instructions, Some ( first_signer) ) ;
1681
+ Transaction :: new ( signers. as_ref ( ) , message, Hash :: default ( ) )
1682
+ }
1683
+
1684
+ let signer: Box < dyn Signer > = Box :: new ( Keypair :: new ( ) ) ;
1685
+ let tx = instructions_to_tx ( & [ ] , Box :: new ( vec ! [ signer] ) ) ;
1686
+
1687
+ assert ! ( tx. is_signed( ) ) ;
1688
+ }
1671
1689
}
0 commit comments