@@ -6,14 +6,12 @@ use std::{
66 collections:: VecDeque ,
77 error:: Error ,
88 sync:: atomic:: { AtomicU64 , Ordering } ,
9- time:: Instant ,
9+ time:: Instant , u128 ,
1010} ;
11- // use subxt::{ext::sp_core::Pair, utils::AccountId32, OnlineClient, PolkadotConfig};
1211
1312use sp_core:: { sr25519:: Pair as SrPair , Pair } ;
1413use subxt:: {
15- blocks:: BlockRef , config:: polkadot:: PolkadotExtrinsicParamsBuilder as Params , dynamic:: Value ,
16- tx:: SubmittableTransaction , OnlineClient , PolkadotConfig ,
14+ blocks:: BlockRef , config:: polkadot:: PolkadotExtrinsicParamsBuilder as Params , dynamic:: Value , ext:: scale_value:: { Primitive , ValueDef } , tx:: SubmittableTransaction , OnlineClient , PolkadotConfig
1715} ;
1816use tokio:: sync:: RwLock ;
1917
@@ -23,6 +21,14 @@ const SENDER_SEED: &str = "//Sender";
2321const RECEIVER_SEED : & str = "//Receiver" ;
2422const ALICE_SEED : & str = "//Alice" ;
2523
24+ /// Amount to send in each transaction, small so that we can do many transactions before
25+ /// running out of funds.
26+ const SMALL_TOKEN_AMOUNT : Value = Value { value : ValueDef :: Primitive ( Primitive :: U128 ( 1 ) ) , context : ( ) } ;
27+
28+ /// Amount to seed each sender with, largest possible value so that we do not run out of funds.
29+ const BIG_TOKEN_AMOUNT : Value = Value { value : ValueDef :: Primitive ( Primitive :: U128 ( u128:: MAX ) ) , context : ( ) } ;
30+
31+
2632/// Util program to send transactions
2733#[ derive( Parser , Debug ) ]
2834#[ command( author, version, about, long_about = None ) ]
@@ -157,7 +163,7 @@ fn main() -> Result<(), Box<dyn Error>> {
157163 "transfer_keep_alive" ,
158164 vec ! [
159165 Value :: unnamed_variant( "Id" , [ Value :: from_bytes( sender. public( ) ) ] ) ,
160- Value :: u128 ( 100000000000000000000 ) ,
166+ BIG_TOKEN_AMOUNT ,
161167 ] ,
162168 ) ;
163169
@@ -270,7 +276,7 @@ fn main() -> Result<(), Box<dyn Error>> {
270276 "transfer_keep_alive" ,
271277 vec ! [
272278 Value :: unnamed_variant( "Id" , [ Value :: from_bytes( receivers[ i] . public( ) ) ] ) ,
273- Value :: u128 ( 1000000000000 ) ,
279+ SMALL_TOKEN_AMOUNT ,
274280 ] ,
275281 ) . into_value ( )
276282 ) . collect :: < Vec < _ > > ( ) ;
@@ -286,7 +292,7 @@ fn main() -> Result<(), Box<dyn Error>> {
286292 "transfer_keep_alive" ,
287293 vec ! [
288294 Value :: unnamed_variant( "Id" , [ Value :: from_bytes( receivers[ 0 ] . public( ) ) ] ) ,
289- Value :: u128 ( 1000000000000 ) ,
295+ SMALL_TOKEN_AMOUNT ,
290296 ] ,
291297 )
292298 } ;
0 commit comments