-
Notifications
You must be signed in to change notification settings - Fork 670
Fix eth_sumulate defaults #9529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9d042d7
e47ae97
9eb30e0
0298967
2ad47be
c9a1c0e
fd184c2
5ac4885
28b312e
de3bec1
87848f5
c35fd66
3880ccb
183533f
8a8a68f
82fed87
7c16b39
8359e29
cebcfe7
81e2809
41e052f
4440723
d09a5a2
b52404b
3400d7d
a6b8d17
0405ef0
300b187
6afef1b
333f81c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -123,27 +123,39 @@ internal static void RegisterTransactionType<T>() where T : TransactionForRpc, I | |||||
|
|
||||||
| public override TransactionForRpc? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||||||
| { | ||||||
| const string TypeFieldKey = nameof(TransactionForRpc.Type); | ||||||
| // Copy the reader so we can do a double parse: | ||||||
| // The first parse is used to check for fields, while the second parses the entire Transaction | ||||||
| Utf8JsonReader txTypeReader = reader; | ||||||
| JsonObject untyped = JsonSerializer.Deserialize<JsonObject>(ref txTypeReader, options); | ||||||
|
|
||||||
| TxType? txType = null; | ||||||
| if (untyped.TryGetPropertyValue(TypeFieldKey, out JsonNode? node)) | ||||||
| Type concreteTxType = DeriveTxType(untyped, options); | ||||||
|
|
||||||
| return (TransactionForRpc?)JsonSerializer.Deserialize(ref reader, concreteTxType, options); | ||||||
| } | ||||||
|
|
||||||
| private Type DeriveTxType(JsonObject untyped, JsonSerializerOptions options) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| { | ||||||
| Type defaultTxType = typeof(EIP1559TransactionForRpc); | ||||||
| const string gasPriceFieldKey = nameof(LegacyTransactionForRpc.GasPrice); | ||||||
| const string typeFieldKey = nameof(TransactionForRpc.Type); | ||||||
|
|
||||||
| if (untyped.TryGetPropertyValue(typeFieldKey, out JsonNode? node)) | ||||||
| { | ||||||
| txType = node.Deserialize<TxType?>(options); | ||||||
| TxType? setType = node.Deserialize<TxType?>(options); | ||||||
| if (setType is not null) | ||||||
| { | ||||||
| return _txTypes.FirstOrDefault(p => p.TxType == setType)?.Type ?? | ||||||
| throw new JsonException("Unknown transaction type"); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| Type concreteTxType = | ||||||
| ( | ||||||
| txType is not null | ||||||
| ? _txTypes.FirstOrDefault(p => p.TxType == txType) | ||||||
| : _txTypes.FirstOrDefault(p => p.DiscriminatorProperties.Any(name => untyped.ContainsKey(name)), _txTypes[^1]) | ||||||
| )?.Type | ||||||
| ?? throw new JsonException("Unknown transaction type"); | ||||||
| if (untyped.ContainsKey(gasPriceFieldKey)) | ||||||
| { | ||||||
| return typeof(LegacyTransactionForRpc); | ||||||
| } | ||||||
|
Comment on lines
+152
to
+155
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If Legacy is first item in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's last. So we should return Legacy if gasPrice is set. Even if we have blobHashes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok we have:
Interesting, maybe we should do that ignoring index? So:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what's |
||||||
|
|
||||||
| return (TransactionForRpc?)JsonSerializer.Deserialize(ref reader, concreteTxType, options); | ||||||
| return _txTypes | ||||||
| .FirstOrDefault(p => p.DiscriminatorProperties.Any(untyped.ContainsKey))?.Type ?? defaultTxType; | ||||||
| } | ||||||
|
|
||||||
| public override void Write(Utf8JsonWriter writer, TransactionForRpc value, JsonSerializerOptions options) | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.