@@ -7,7 +7,14 @@ namespace TonLibDotNet
77{
88 public static class Program
99 {
10- private const bool useMainnet = true ;
10+ // You will need actual mnemonic and address with some coins to run tests like SendTon, SendJetton etc.
11+ // These tests have safeguards and will not run on mainnet.
12+ // But anyway, double check that you are using testnet and what tests are uncommented before putting actual seed phrase here!!!
13+ public const string TestAddress = "EQAkEWzRLi1sw9AlaGDDzPvk2_F20hjpTjlvsjQqYawVmdT0" ;
14+ public const string TestMnemonic = "" ; // put space-delimited mnemonic words here
15+
16+ // Some tests need mainnet (e.g. domains), some will run only in testnet (e.g. sending coins).
17+ public const bool UseMainnet = true ;
1118
1219 private const string DirectoryForKeys = "D:/Temp/keys" ;
1320
@@ -20,44 +27,32 @@ public static async Task Main(string[] args)
2027 {
2128 services . Configure < TonOptions > ( o =>
2229 {
23- o . UseMainnet = useMainnet ;
30+ o . UseMainnet = UseMainnet ;
2431 o . LogTextLimit = 500 ; // Set to 0 to see full requests/responses
2532 o . VerbosityLevel = 0 ;
2633 o . Options . KeystoreType = new KeyStoreTypeDirectory ( DirectoryForKeys ) ;
2734 } ) ;
35+
36+ services . AddHostedService < SamplesRunner > ( ) ;
37+
2838 services . AddSingleton < ITonClient , TonClient > ( ) ;
2939
30- services . AddTransient < GeneralNetworkInfo > ( ) ;
31- services . AddTransient < KeysAndMnemonics > ( ) ;
32- services . AddTransient < AccountBalanceAndTransactions > ( ) ;
33- services . AddTransient < LibraryExtensibility > ( ) ;
34- services . AddTransient < SendTon > ( ) ;
35- services . AddTransient < ResolveDomains > ( ) ;
36- services . AddTransient < ReadInfoFromSmartContracts > ( ) ;
37- services . AddTransient < BocAndCells > ( ) ;
38- services . AddTransient < DomainAuctionInfo > ( ) ;
40+ services . AddTransient < ISample , GeneralNetworkInfo > ( ) ;
41+ services . AddTransient < ISample , KeysAndMnemonics > ( ) ;
42+ services . AddTransient < ISample , AccountBalanceAndTransactions > ( ) ;
43+ services . AddTransient < ISample , LibraryExtensibility > ( ) ;
44+ services . AddTransient < ISample , SendTon > ( ) ;
45+ services . AddTransient < ISample , ResolveDomains > ( ) ;
46+ services . AddTransient < ISample , ReadInfoFromSmartContracts > ( ) ;
47+ services . AddTransient < ISample , BocAndCells > ( ) ;
48+ services . AddTransient < ISample , DomainAuctionInfo > ( ) ;
3949 } ) ;
4050
4151 /// Add types from current assembly (see <see cref="LibraryExtensibility"/> class for more info).
4252 TonClient . RegisterAssembly ( typeof ( Program ) . Assembly ) ;
4353
4454 var app = builder . Build ( ) ;
45-
46- await app . Services . GetRequiredService < ITonClient > ( ) . InitIfNeeded ( ) ;
47-
48- // Feel free to comment unneeded calls below
49- await app . Services . GetRequiredService < GeneralNetworkInfo > ( ) . Run ( ) ;
50- await app . Services . GetRequiredService < KeysAndMnemonics > ( ) . Run ( ) ;
51- await app . Services . GetRequiredService < AccountBalanceAndTransactions > ( ) . Run ( ) ;
52- await app . Services . GetRequiredService < LibraryExtensibility > ( ) . Run ( ) ;
53- await app . Services . GetRequiredService < SendTon > ( ) . Run ( useMainnet ) ;
54- await app . Services . GetRequiredService < ResolveDomains > ( ) . Run ( useMainnet ) ;
55- await app . Services . GetRequiredService < ReadInfoFromSmartContracts > ( ) . Run ( useMainnet ) ;
56- await app . Services . GetRequiredService < BocAndCells > ( ) . Run ( useMainnet ) ;
57- await app . Services . GetRequiredService < DomainAuctionInfo > ( ) . Run ( useMainnet ) ;
58-
59- // Loggers need some time to flush data to screen/console.
60- await Task . Delay ( TimeSpan . FromSeconds ( 1 ) ) ;
55+ await app . RunAsync ( ) ;
6156 }
6257 }
6358}
0 commit comments