mirror of
https://github.com/status-im/status-go.git
synced 2025-01-09 14:16:21 +00:00
07651d4d06
* feat: enable wallet without network binding * feat: make transfer network aware * feat: allow to pass initial networks via config * fix: nil check and feed * feat: Add documentation with better function name * fix: do not init the manager more than once * fix: PR feedbacks * Bump version * Update Jenkinsfile.tests * Convert int to string Co-authored-by: RichΛrd <info@richardramos.me>
29 lines
456 B
Go
29 lines
456 B
Go
package bigint
|
|
|
|
import (
|
|
"fmt"
|
|
"math/big"
|
|
"strings"
|
|
)
|
|
|
|
type BigInt struct {
|
|
*big.Int
|
|
}
|
|
|
|
func (b BigInt) MarshalJSON() ([]byte, error) {
|
|
return []byte("\"" + b.String() + "\""), nil
|
|
}
|
|
|
|
func (b *BigInt) UnmarshalJSON(p []byte) error {
|
|
if string(p) == "null" {
|
|
return nil
|
|
}
|
|
z := new(big.Int)
|
|
_, ok := z.SetString(strings.Trim(string(p), "\""), 10)
|
|
if !ok {
|
|
return fmt.Errorf("not a valid big integer: %s", string(p))
|
|
}
|
|
b.Int = z
|
|
return nil
|
|
}
|