@@ -15,7 +15,7 @@ private async Task<ThirdwebTransaction> CreateSampleTransaction()
15
15
var wallet = await PrivateKeyWallet . Create ( client , _testPrivateKey ) ;
16
16
var chainId = new BigInteger ( 421614 ) ;
17
17
18
- var transaction = await ThirdwebTransaction . Create ( client , wallet , new ThirdwebTransactionInput ( ) , chainId ) ;
18
+ var transaction = await ThirdwebTransaction . Create ( client , wallet , new ThirdwebTransactionInput ( ) { From = await wallet . GetAddress ( ) , To = await wallet . GetAddress ( ) , } , chainId ) ;
19
19
return transaction ;
20
20
}
21
21
@@ -24,18 +24,28 @@ public async Task Create_ValidatesInputParameters()
24
24
{
25
25
var client = ThirdwebClient . Create ( secretKey : _secretKey ) ;
26
26
var wallet = await PrivateKeyWallet . Create ( client , _testPrivateKey ) ;
27
- var txInput = new ThirdwebTransactionInput ( ) { From = await wallet . GetAddress ( ) } ;
27
+ var txInput = new ThirdwebTransactionInput ( ) { From = await wallet . GetAddress ( ) , To = Constants . ADDRESS_ZERO } ;
28
28
var chainId = new BigInteger ( 421614 ) ;
29
29
var transaction = await ThirdwebTransaction . Create ( client , wallet , txInput , chainId ) ;
30
30
Assert . NotNull ( transaction ) ;
31
31
}
32
32
33
+ [ Fact ]
34
+ public async Task Create_ThrowsOnNoTo ( )
35
+ {
36
+ var client = ThirdwebClient . Create ( secretKey : _secretKey ) ;
37
+ var wallet = await PrivateKeyWallet . Create ( client , _testPrivateKey ) ;
38
+ var txInput = new ThirdwebTransactionInput ( ) { From = await wallet . GetAddress ( ) } ;
39
+ var ex = await Assert . ThrowsAsync < ArgumentException > ( ( ) => ThirdwebTransaction . Create ( client , wallet , txInput , BigInteger . Zero ) ) ;
40
+ Assert . Contains ( "Transaction recipient (to) must be provided" , ex . Message ) ;
41
+ }
42
+
33
43
[ Fact ]
34
44
public async Task Create_ThrowsOnInvalidAddress ( )
35
45
{
36
46
var client = ThirdwebClient . Create ( secretKey : _secretKey ) ;
37
47
var wallet = await PrivateKeyWallet . Create ( client , _testPrivateKey ) ;
38
- var txInput = new ThirdwebTransactionInput ( ) { From = "0x123" } ;
48
+ var txInput = new ThirdwebTransactionInput ( ) { From = "0x123" , To = Constants . ADDRESS_ZERO } ;
39
49
var ex = await Assert . ThrowsAsync < ArgumentException > ( ( ) => ThirdwebTransaction . Create ( client , wallet , txInput , BigInteger . Zero ) ) ;
40
50
Assert . Contains ( "Transaction sender (from) must match wallet address" , ex . Message ) ;
41
51
}
@@ -150,7 +160,7 @@ public async Task Send_ThrowsIfToAddressNotProvided()
150
160
var transaction = await CreateSampleTransaction ( ) ;
151
161
_ = transaction . SetTo ( null ) ;
152
162
153
- _ = await Assert . ThrowsAsync < ArgumentException > ( ( ) => ThirdwebTransaction . Send ( transaction ) ) ;
163
+ _ = await Assert . ThrowsAsync < InvalidOperationException > ( ( ) => ThirdwebTransaction . Send ( transaction ) ) ;
154
164
}
155
165
156
166
[ Fact ]
@@ -268,15 +278,11 @@ public async Task EstimateGasCosts_SmartWalletHigherThanPrivateKeyWallet()
268
278
var privateKeyAccount = await PrivateKeyWallet . Create ( client , _testPrivateKey ) ;
269
279
var smartAccount = await SmartWallet . Create ( client , personalWallet : privateKeyAccount , factoryAddress : "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052" , gasless : true , chainId : 421614 ) ;
270
280
271
- var transaction = await ThirdwebTransaction . Create ( client , smartAccount , new ThirdwebTransactionInput ( ) , 421614 ) ;
272
- _ = transaction . SetTo ( Constants . ADDRESS_ZERO ) ;
273
- _ = transaction . SetValue ( new BigInteger ( 1000 ) ) ;
281
+ var transaction = await ThirdwebTransaction . Create ( client , smartAccount , new ThirdwebTransactionInput ( ) { To = Constants . ADDRESS_ZERO , Value = new HexBigInteger ( 1000 ) , } , 421614 ) ;
274
282
275
283
var smartCosts = await ThirdwebTransaction . EstimateGasCosts ( transaction ) ;
276
284
277
- transaction = await ThirdwebTransaction . Create ( client , privateKeyAccount , new ThirdwebTransactionInput ( ) , 421614 ) ;
278
- _ = transaction . SetTo ( Constants . ADDRESS_ZERO ) ;
279
- _ = transaction . SetValue ( new BigInteger ( 1000 ) ) ;
285
+ transaction = await ThirdwebTransaction . Create ( client , privateKeyAccount , new ThirdwebTransactionInput ( ) { To = Constants . ADDRESS_ZERO , Value = new HexBigInteger ( 1000 ) , } , 421614 ) ;
280
286
281
287
var privateCosts = await ThirdwebTransaction . EstimateGasCosts ( transaction ) ;
282
288
@@ -339,9 +345,18 @@ public async Task Simulate_ReturnsData()
339
345
var client = ThirdwebClient . Create ( secretKey : _secretKey ) ;
340
346
var privateKeyAccount = await PrivateKeyWallet . Create ( client , _testPrivateKey ) ;
341
347
var smartAccount = await SmartWallet . Create ( client , personalWallet : privateKeyAccount , factoryAddress : "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052" , gasless : true , chainId : 421614 ) ;
342
- var transaction = await ThirdwebTransaction . Create ( client , smartAccount , new ThirdwebTransactionInput ( ) , 421614 ) ;
343
- _ = transaction . SetValue ( new BigInteger ( 0 ) ) ;
344
- _ = transaction . SetGasLimit ( 250000 ) ;
348
+ var transaction = await ThirdwebTransaction . Create (
349
+ client ,
350
+ smartAccount ,
351
+ new ThirdwebTransactionInput ( )
352
+ {
353
+ To = Constants . ADDRESS_ZERO ,
354
+ Value = new HexBigInteger ( 0 ) ,
355
+ Data = "0x" ,
356
+ Gas = new HexBigInteger ( 250000 ) ,
357
+ } ,
358
+ 421614
359
+ ) ;
345
360
346
361
var data = await ThirdwebTransaction . Simulate ( transaction ) ;
347
362
Assert . NotNull ( data ) ;
0 commit comments