toString method
A string representation of this object.
Some classes have a default textual representation,
often paired with a static parse
function (like int.parse).
These classes will provide the textual representation as
their string representation.
Other classes have no meaningful textual representation
that a program will care about.
Such classes will typically override toString
to provide
useful information when inspecting the object,
mainly for debugging or logging.
Implementation
@override
String toString() {
debugPrint('[$runtimeType] method $method');
final m = 'method:\'$method\'';
final t = 'type:\'${super.type}\'';
final p = params.map((i) => '$i').toList();
if (method == 'personal_sign') {
final data = p.first;
final address = p.last;
return '{$t,payload:{$m,params:[\'$data\',\'$address\']}}';
}
if (method == 'eth_signTypedData_v4' ||
method == 'eth_signTypedData_v3' ||
method == 'eth_signTypedData') {
// final data = jsonEncode(jsonDecode(p.first) as Map<String, dynamic>);
final data = p.first;
final address = p.last;
return '{$t,payload:{$m,params:[\'$address\',\'$data\']}}';
}
if (method == 'eth_sendTransaction' || method == 'eth_signTransaction') {
final jp = jsonEncode(params.first);
return '{$t,payload:{$m,params:[$jp]}}';
}
final ps = p.join(',');
return '{$t,payload:{$m,params:[$ps]}}';
}