@@ -25,12 +25,11 @@ use super::{
2525 ContractExecResult ,
2626 ContractInstantiateResult ,
2727 ContractsApi ,
28- Signer ,
28+ Keypair ,
2929} ;
3030use ink_env:: Environment ;
3131use ink_primitives:: MessageResult ;
3232use pallet_contracts_primitives:: ExecReturnValue ;
33- use sp_core:: Pair ;
3433#[ cfg( feature = "std" ) ]
3534use std:: {
3635 collections:: BTreeMap ,
@@ -52,7 +51,8 @@ use subxt::{
5251 ValueDef ,
5352 } ,
5453 } ,
55- tx:: PairSigner ,
54+ tx:: Signer ,
55+ Config ,
5656} ;
5757
5858/// Result of a contract instantiation.
@@ -61,7 +61,7 @@ pub struct InstantiationResult<C: subxt::Config, E: Environment> {
6161 pub account_id : E :: AccountId ,
6262 /// The result of the dry run, contains debug messages
6363 /// if there were any.
64- pub dry_run : ContractInstantiateResult < C :: AccountId , E :: Balance > ,
64+ pub dry_run : ContractInstantiateResult < C :: AccountId , E :: Balance , ( ) > ,
6565 /// Events that happened with the contract instantiation.
6666 pub events : ExtrinsicEvents < C > ,
6767}
@@ -191,7 +191,7 @@ where
191191pub struct CallDryRunResult < E : Environment , V > {
192192 /// The result of the dry run, contains debug messages
193193 /// if there were any.
194- pub exec_result : ContractExecResult < E :: Balance > ,
194+ pub exec_result : ContractExecResult < E :: Balance , ( ) > ,
195195 _marker : PhantomData < V > ,
196196}
197197
@@ -271,15 +271,15 @@ where
271271 /// No contract with the given name found in scope.
272272 ContractNotFound ( String ) ,
273273 /// The `instantiate_with_code` dry run failed.
274- InstantiateDryRun ( ContractInstantiateResult < C :: AccountId , E :: Balance > ) ,
274+ InstantiateDryRun ( ContractInstantiateResult < C :: AccountId , E :: Balance , ( ) > ) ,
275275 /// The `instantiate_with_code` extrinsic failed.
276276 InstantiateExtrinsic ( subxt:: error:: DispatchError ) ,
277277 /// The `upload` dry run failed.
278278 UploadDryRun ( CodeUploadResult < E :: Hash , E :: Balance > ) ,
279279 /// The `upload` extrinsic failed.
280280 UploadExtrinsic ( subxt:: error:: DispatchError ) ,
281281 /// The `call` dry run failed.
282- CallDryRun ( ContractExecResult < E :: Balance > ) ,
282+ CallDryRun ( ContractExecResult < E :: Balance , ( ) > ) ,
283283 /// The `call` extrinsic failed.
284284 CallExtrinsic ( subxt:: error:: DispatchError ) ,
285285 /// Error fetching account balance.
@@ -383,12 +383,11 @@ where
383383impl < C , E > Client < C , E >
384384where
385385 C : subxt:: Config ,
386- C :: AccountId : From < sp_runtime:: AccountId32 >
387- + scale:: Codec
388- + serde:: de:: DeserializeOwned
389- + Debug ,
386+ C :: AccountId :
387+ From < sr25519:: PublicKey > + scale:: Codec + serde:: de:: DeserializeOwned + Debug ,
388+ C :: Address : From < sr25519:: PublicKey > ,
390389 C :: Signature : From < sr25519:: Signature > ,
391- <C :: ExtrinsicParams as ExtrinsicParams < C :: Index , C :: Hash > >:: OtherParams : Default ,
390+ <C :: ExtrinsicParams as ExtrinsicParams < C :: Hash > >:: OtherParams : Default ,
392391
393392 E : Environment ,
394393 E :: AccountId : Debug ,
@@ -424,37 +423,38 @@ where
424423 /// number of times.
425424 pub async fn create_and_fund_account (
426425 & self ,
427- origin : & Signer < C > ,
426+ origin : & Keypair ,
428427 amount : E :: Balance ,
429- ) -> Signer < C >
428+ ) -> Keypair
430429 where
431430 E :: Balance : Clone ,
432431 C :: AccountId : Clone + core:: fmt:: Display + Debug ,
433432 C :: AccountId : From < sp_core:: crypto:: AccountId32 > ,
434433 {
435- let ( pair, _, _) = <sr25519:: Pair as Pair >:: generate_with_phrase ( None ) ;
436- let pair_signer = PairSigner :: < C , _ > :: new ( pair) ;
437- let account_id = pair_signer. account_id ( ) . to_owned ( ) ;
434+ let ( _, phrase, _) =
435+ <sp_core:: sr25519:: Pair as sp_core:: Pair >:: generate_with_phrase ( None ) ;
436+ let phrase =
437+ subxt_signer:: bip39:: Mnemonic :: parse ( phrase) . expect ( "valid phrase expected" ) ;
438+ let keypair = Keypair :: from_phrase ( & phrase, None ) . expect ( "valid phrase expected" ) ;
439+ let account_id = <Keypair as Signer < C > >:: account_id ( & keypair) ;
440+ let origin_account_id = origin. public_key ( ) . to_account_id ( ) ;
438441
439442 self . api
440443 . try_transfer_balance ( origin, account_id. clone ( ) , amount)
441444 . await
442445 . unwrap_or_else ( |err| {
443446 panic ! (
444447 "transfer from {} to {} failed with {:?}" ,
445- origin. account_id( ) ,
446- account_id,
447- err
448+ origin_account_id, account_id, err
448449 )
449450 } ) ;
450451
451452 log_info ( & format ! (
452453 "transfer from {} to {} succeeded" ,
453- origin. account_id( ) ,
454- account_id,
454+ origin_account_id, account_id,
455455 ) ) ;
456456
457- pair_signer
457+ keypair
458458 }
459459
460460 /// This function extracts the metadata of the contract at the file path
@@ -468,7 +468,7 @@ where
468468 pub async fn instantiate < ContractRef , Args , R > (
469469 & mut self ,
470470 contract_name : & str ,
471- signer : & Signer < C > ,
471+ signer : & Keypair ,
472472 constructor : CreateBuilderPartial < E , ContractRef , Args , R > ,
473473 value : E :: Balance ,
474474 storage_deposit_limit : Option < E :: Balance > ,
@@ -488,11 +488,11 @@ where
488488 pub async fn instantiate_dry_run < ContractRef , Args , R > (
489489 & mut self ,
490490 contract_name : & str ,
491- signer : & Signer < C > ,
491+ signer : & Keypair ,
492492 constructor : CreateBuilderPartial < E , ContractRef , Args , R > ,
493493 value : E :: Balance ,
494494 storage_deposit_limit : Option < E :: Balance > ,
495- ) -> ContractInstantiateResult < C :: AccountId , E :: Balance >
495+ ) -> ContractInstantiateResult < C :: AccountId , E :: Balance , ( ) >
496496 where
497497 Args : scale:: Encode ,
498498 {
@@ -535,7 +535,7 @@ where
535535 /// Executes an `instantiate_with_code` call and captures the resulting events.
536536 async fn exec_instantiate < ContractRef , Args , R > (
537537 & mut self ,
538- signer : & Signer < C > ,
538+ signer : & Keypair ,
539539 code : Vec < u8 > ,
540540 constructor : CreateBuilderPartial < E , ContractRef , Args , R > ,
541541 value : E :: Balance ,
@@ -646,7 +646,7 @@ where
646646 pub async fn upload (
647647 & mut self ,
648648 contract_name : & str ,
649- signer : & Signer < C > ,
649+ signer : & Keypair ,
650650 storage_deposit_limit : Option < E :: Balance > ,
651651 ) -> Result < UploadResult < C , E > , Error < C , E > > {
652652 let code = self . load_code ( contract_name) ;
@@ -660,7 +660,7 @@ where
660660 /// Executes an `upload` call and captures the resulting events.
661661 pub async fn exec_upload (
662662 & mut self ,
663- signer : & Signer < C > ,
663+ signer : & Keypair ,
664664 code : Vec < u8 > ,
665665 storage_deposit_limit : Option < E :: Balance > ,
666666 ) -> Result < UploadResult < C , E > , Error < C , E > > {
@@ -731,7 +731,7 @@ where
731731 /// contains all events that are associated with this transaction.
732732 pub async fn call < RetType > (
733733 & mut self ,
734- signer : & Signer < C > ,
734+ signer : & Keypair ,
735735 message : Message < E , RetType > ,
736736 value : E :: Balance ,
737737 storage_deposit_limit : Option < E :: Balance > ,
@@ -793,7 +793,7 @@ where
793793 /// contains all events that are associated with this transaction.
794794 pub async fn runtime_call < ' a > (
795795 & mut self ,
796- signer : & Signer < C > ,
796+ signer : & Keypair ,
797797 pallet_name : & ' a str ,
798798 call_name : & ' a str ,
799799 call_data : Vec < Value > ,
@@ -828,7 +828,7 @@ where
828828 /// invoked message.
829829 pub async fn call_dry_run < RetType > (
830830 & mut self ,
831- signer : & Signer < C > ,
831+ signer : & Keypair ,
832832 message : & Message < E , RetType > ,
833833 value : E :: Balance ,
834834 storage_deposit_limit : Option < E :: Balance > ,
@@ -839,7 +839,7 @@ where
839839 let exec_result = self
840840 . api
841841 . call_dry_run (
842- Signer :: account_id ( signer) . clone ( ) ,
842+ Signer :: < C > :: account_id ( signer) ,
843843 message,
844844 value,
845845 storage_deposit_limit,
@@ -940,6 +940,6 @@ where
940940}
941941
942942/// Returns true if the give event is System::Extrinsic failed.
943- fn is_extrinsic_failed_event ( event : & EventDetails ) -> bool {
943+ fn is_extrinsic_failed_event < C : Config > ( event : & EventDetails < C > ) -> bool {
944944 event. pallet_name ( ) == "System" && event. variant_name ( ) == "ExtrinsicFailed"
945945}
0 commit comments