74
74
chain : Chain ,
75
75
etherscan_api_key : Option < String > ,
76
76
) -> Result < String > {
77
- let ( tx, func) =
78
- self . build_tx ( from, to, Some ( args) , None , None , None , chain, etherscan_api_key) . await ?;
77
+ let ( tx, func) = self
78
+ . build_tx ( from, to, Some ( args) , None , None , None , chain, etherscan_api_key, false )
79
+ . await ?;
79
80
let res = self . provider . call ( & tx, None ) . await ?;
80
81
81
82
// decode args into tokens
@@ -133,7 +134,7 @@ where
133
134
/// let gas = U256::from_str("200000").unwrap();
134
135
/// let value = U256::from_str("1").unwrap();
135
136
/// let nonce = U256::from_str("1").unwrap();
136
- /// let data = cast.send(from, to, Some((sig, args)), Some(gas), Some(value), Some(nonce), Chain::Mainnet, None).await?;
137
+ /// let data = cast.send(from, to, Some((sig, args)), Some(gas), Some(value), Some(nonce), Chain::Mainnet, None, false ).await?;
137
138
/// println!("{}", *data);
138
139
/// # Ok(())
139
140
/// # }
@@ -149,9 +150,11 @@ where
149
150
nonce : Option < U256 > ,
150
151
chain : Chain ,
151
152
etherscan_api_key : Option < String > ,
153
+ legacy : bool ,
152
154
) -> Result < PendingTransaction < ' _ , M :: Provider > > {
153
- let ( tx, _) =
154
- self . build_tx ( from, to, args, gas, value, nonce, chain, etherscan_api_key) . await ?;
155
+ let ( tx, _) = self
156
+ . build_tx ( from, to, args, gas, value, nonce, chain, etherscan_api_key, legacy)
157
+ . await ?;
155
158
let res = self . provider . send_transaction ( tx, None ) . await ?;
156
159
157
160
Ok :: < _ , eyre:: Error > ( res)
@@ -212,8 +215,9 @@ where
212
215
chain : Chain ,
213
216
etherscan_api_key : Option < String > ,
214
217
) -> Result < U256 > {
215
- let ( tx, _) =
216
- self . build_tx ( from, to, args, None , value, None , chain, etherscan_api_key) . await ?;
218
+ let ( tx, _) = self
219
+ . build_tx ( from, to, args, None , value, None , chain, etherscan_api_key, false )
220
+ . await ?;
217
221
let res = self . provider . estimate_gas ( & tx) . await ?;
218
222
219
223
Ok :: < _ , eyre:: Error > ( res)
@@ -230,6 +234,7 @@ where
230
234
nonce : Option < U256 > ,
231
235
chain : Chain ,
232
236
etherscan_api_key : Option < String > ,
237
+ legacy : bool ,
233
238
) -> Result < ( TypedTransaction , Option < ethers_core:: abi:: Function > ) > {
234
239
let from = match from. into ( ) {
235
240
NameOrAddress :: Name ( ref ens_name) => self . provider . resolve_name ( ens_name) . await ?,
@@ -245,7 +250,7 @@ where
245
250
} ;
246
251
247
252
// make the call
248
- let mut tx: TypedTransaction = if chain. is_legacy ( ) {
253
+ let mut tx: TypedTransaction = if chain. is_legacy ( ) || legacy {
249
254
TransactionRequest :: new ( ) . from ( from) . to ( to) . into ( )
250
255
} else {
251
256
Eip1559TransactionRequest :: new ( ) . from ( from) . to ( to) . into ( )
0 commit comments