-
Notifications
You must be signed in to change notification settings - Fork 1k
BigInteger in Neo.Json #3037
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
base: master
Are you sure you want to change the base?
BigInteger in Neo.Json #3037
Changes from all commits
6b31958
48c2649
186c2ba
eab5b25
776ab64
9ccb97d
458499b
edae719
be973c9
308d33d
19e3111
1214697
58ec583
efa2c34
bcc5fd0
e63f10b
9d16c53
f746f8d
8d7f9e8
3fc8077
620d938
7e31d0c
993e3fe
37bf0cb
7dba130
0457ccd
d7a291e
6e780c0
02d6ab9
8fb30df
f9244eb
650c9e9
331541a
eb96d14
74498e5
195abf9
4b6542b
758933e
3599c81
d418916
04402c9
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 |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ public enum Hardfork : byte | |
| HF_Aspidochelone, | ||
| HF_Basilisk, | ||
| HF_Cockatrice, | ||
| HF_Domovoi | ||
| HF_Domovoi, | ||
| HF_Echidna | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,14 +35,15 @@ public static class JsonSerializer | |
| /// Serializes a <see cref="StackItem"/> to a <see cref="JToken"/>. | ||
| /// </summary> | ||
| /// <param name="item">The <see cref="StackItem"/> to serialize.</param> | ||
| /// <param name="hardforkChecker">Hardfork checker</param> | ||
| /// <returns>The serialized object.</returns> | ||
| public static JToken Serialize(StackItem item) | ||
| public static JToken Serialize(StackItem item, Func<Hardfork, bool> hardforkChecker = null) | ||
|
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. @neo-project/core This methods seems that was only used in UT... |
||
| { | ||
| switch (item) | ||
| { | ||
| case Array array: | ||
| { | ||
| return array.Select(p => Serialize(p)).ToArray(); | ||
| return array.Select(p => Serialize(p, hardforkChecker)).ToArray(); | ||
| } | ||
| case ByteString _: | ||
| case Buffer _: | ||
|
|
@@ -51,10 +52,7 @@ public static JToken Serialize(StackItem item) | |
| } | ||
| case Integer num: | ||
| { | ||
| var integer = num.GetInteger(); | ||
| if (integer > JNumber.MAX_SAFE_INTEGER || integer < JNumber.MIN_SAFE_INTEGER) | ||
|
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. Hello, #2498. 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. He put it in the JNumber. Different exception, but will fail as well. 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. It was moved to the constructor, that was the bug, when we used parse we allowed it... |
||
| throw new InvalidOperationException(); | ||
| return (double)integer; | ||
| return new JNumber((long)num.GetInteger(), hardforkChecker == null || hardforkChecker(Hardfork.HF_Echidna)); | ||
| } | ||
| case Boolean boolean: | ||
| { | ||
|
|
@@ -66,10 +64,10 @@ public static JToken Serialize(StackItem item) | |
|
|
||
| foreach (var entry in map) | ||
| { | ||
| if (!(entry.Key is ByteString)) throw new FormatException(); | ||
| if (entry.Key is not ByteString) throw new FormatException(); | ||
|
|
||
| var key = entry.Key.GetString(); | ||
| var value = Serialize(entry.Value); | ||
| var value = Serialize(entry.Value, hardforkChecker); | ||
|
|
||
| ret[key] = value; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
valueisdouble. It shouldn't be limited.