@@ -304,7 +304,7 @@ var _ = Describe("Multichain", func() {
304
304
rpcURL pack.String
305
305
randomRecipientAddr func () multichain.Address
306
306
initialise func (pack.String ) (multichain.AccountClient , multichain.AccountTxBuilder )
307
- txParams func () (pack.U256 , pack.U256 , pack.U256 , pack.Bytes )
307
+ txParams func (multichain. AccountClient ) (pack. U256 , pack.U256 , pack.U256 , pack.U256 , pack.Bytes )
308
308
chain multichain.Chain
309
309
}{
310
310
{
@@ -355,12 +355,13 @@ var _ = Describe("Multichain", func() {
355
355
356
356
return client , txBuilder
357
357
},
358
- func () (pack.U256 , pack.U256 , pack.U256 , pack.Bytes ) {
358
+ func (_ multichain. AccountClient ) (pack. U256 , pack.U256 , pack.U256 , pack.U256 , pack.Bytes ) {
359
359
amount := pack .NewU256FromU64 (pack .U64 (2000000 ))
360
360
gasLimit := pack .NewU256FromU64 (pack .U64 (100000 ))
361
361
gasPrice := pack .NewU256FromU64 (pack .U64 (1 ))
362
+ gasCap := pack .NewU256FromInt (gasPrice .Int ())
362
363
payload := pack .NewBytes ([]byte ("multichain" ))
363
- return amount , gasLimit , gasPrice , payload
364
+ return amount , gasLimit , gasPrice , gasCap , payload
364
365
},
365
366
multichain .Terra ,
366
367
},
@@ -419,20 +420,22 @@ var _ = Describe("Multichain", func() {
419
420
)
420
421
Expect (err ).NotTo (HaveOccurred ())
421
422
422
- gasEstimator := filecoin .NewGasEstimator (client , 2189560 )
423
- _ , gasPremium , err := gasEstimator .EstimateGasPrice (context .Background ())
424
- Expect (err ).NotTo (HaveOccurred ())
425
-
426
- txBuilder := filecoin .NewTxBuilder (gasPremium )
423
+ txBuilder := filecoin .NewTxBuilder ()
427
424
428
425
return client , txBuilder
429
426
},
430
- func () (pack.U256 , pack.U256 , pack.U256 , pack.Bytes ) {
427
+ func (client multichain. AccountClient ) (pack. U256 , pack.U256 , pack.U256 , pack.U256 , pack.Bytes ) {
431
428
amount := pack .NewU256FromU64 (pack .NewU64 (100000000 ))
432
429
gasLimit := pack .NewU256FromU64 (pack .NewU64 (2189560 ))
433
- gasPrice := pack .NewU256FromU64 (pack .NewU64 (300000 ))
430
+
431
+ // Fetch gas price and gas cap using the gas estimator.
432
+ filecoinClient := client .(* filecoin.Client )
433
+ gasPrice , gasCap , err := filecoin .NewGasEstimator (filecoinClient , gasLimit .Int ().Int64 ()).
434
+ EstimateGas (context .Background ())
435
+ Expect (err ).NotTo (HaveOccurred ())
436
+
434
437
payload := pack .Bytes (nil )
435
- return amount , gasLimit , gasPrice , payload
438
+ return amount , gasLimit , gasPrice , gasCap , payload
436
439
},
437
440
multichain .Filecoin ,
438
441
},
@@ -457,13 +460,13 @@ var _ = Describe("Multichain", func() {
457
460
Expect (err ).NotTo (HaveOccurred ())
458
461
459
462
// Build a transaction.
460
- amount , gasLimit , gasPrice , payload := accountChain .txParams ()
463
+ amount , gasLimit , gasPrice , gasCap , payload := accountChain .txParams (accountClient )
461
464
462
465
accountTx , err := txBuilder .BuildTx (
463
466
ctx ,
464
467
multichain .Address (senderAddr ),
465
468
recipientAddr ,
466
- amount , nonce , gasLimit , gasPrice ,
469
+ amount , nonce , gasLimit , gasPrice , gasCap ,
467
470
payload ,
468
471
)
469
472
Expect (err ).NotTo (HaveOccurred ())
0 commit comments