-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2099 from OffchainLabs/4844-inbox-reader-fixes
4844 inbox reader fixes
- Loading branch information
Showing
6 changed files
with
90 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2024, Offchain Labs, Inc. | ||
// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE | ||
|
||
package jsonapi | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
) | ||
|
||
// Uint64String is a uint64 that JSON marshals and unmarshals as string in decimal | ||
type Uint64String uint64 | ||
|
||
func (u *Uint64String) UnmarshalJSON(b []byte) error { | ||
s := string(b) | ||
if s == "null" { | ||
return nil | ||
} | ||
|
||
// Parse string as uint64, removing quotes | ||
value, err := strconv.ParseUint(s[1:len(s)-1], 10, 64) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
*u = Uint64String(value) | ||
return nil | ||
} | ||
|
||
func (u Uint64String) MarshalJSON() ([]byte, error) { | ||
return []byte(fmt.Sprintf("\"%d\"", uint64(u))), nil | ||
} |