Open andromeda911 opened 3 years ago
Equally important is the network identifier parameter, because of which we cannot use the generated code for test networks
You can set the chainId
in the generated constructor. But I agree that there should be a way to change the other parameters for calls:
BlockNum atBlock
parameter to view historical dataWe also need a way to make this backwards compatible. Perhaps we could add an optional Transaction
parameter and make the generated contract call copyWith
for the fields its setting itself.
You can set the
chainId
in the generated constructor. But I agree that there should be a way to change the other parameters for calls:
Thanks, i misssed it;
What about some new class "TransactionSettings" like this:
class TransactionSettings {
int? maxGas;
BigInt? gasPrice;
_i1.EtherAmount? value;
int? nonce;
TransactionSettings({
this.maxGas,
this.gasPrice,
this.value,
this.nonce,
});
}
whose instance we can pass to call that requires transaction:
Future<String> transfer(
_i1.EthereumAddress _to,
BigInt _value,
{
required _i1.Credentials credentials,
// NEW:
TransactionSettings? txSettings,
}
) async {
final function = self.function('transfer');
final params = [_to, _value];
final transaction = _i1.Transaction.callContract(
contract: self,
function: function,
parameters: params,
// NEW:
gasPrice: txSettings?.gasPrice,
maxGas: txSettings?.maxGas,
value: txSettings?.value,
nonce: txSettings?.nonce,
);
return write(credentials, transaction);
}
This way does not require backward compatibility, but need to have new class.
But we also can`t estimate gas for transaction in current implementation.
I've added some more parameters in af4c3fb4a0c258f4146f051e4c27d1674046003b, it works similar to what you're describing.
Estimating gas is a good point, maybe we should generate another method that returns a Transaction
without running it? :thinking:
If I understood everything correctly, then in the current implementation we cannot pass the gas price, nonce and other parameters, except for the function arguments when calling the smart contract generated methods. Equally important is the network identifier parameter, because of which we cannot use the generated code for test networks.
A possible solution is to add an optional parameter of the container of additional settings to the list of arguments of those methods in which the transaction is created. This container will contain and pass to transaction constructor all other transaction settings as: gasPrice, nonce, maxGas, chainId, value.