Skip to content

Commit

Permalink
test unmarshal capability
Browse files Browse the repository at this point in the history
  • Loading branch information
darioush committed Sep 6, 2024
1 parent 502a3ae commit 3fb0338
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
8 changes: 4 additions & 4 deletions core/gen_genesis.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ type Genesis struct {

// field type overrides for gencodec
type genesisSpecMarshaling struct {
Config *ChainConfig
Nonce math.HexOrDecimal64
Timestamp math.HexOrDecimal64
ExtraData hexutil.Bytes
Expand Down
26 changes: 26 additions & 0 deletions core/genesis_libevm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package core

import (
"encoding/json"

"github.com/ava-labs/subnet-evm/params"
gethparams "github.com/ethereum/go-ethereum/params"
)

type ChainConfig params.ChainConfig

func (c *ChainConfig) MarshalJSON() ([]byte, error) {
return json.Marshal((*params.ChainConfig)(c))
}

func (c *ChainConfig) UnmarshalJSON(input []byte) error {
var tmp gethparams.ChainConfig
if err := json.Unmarshal(input, &tmp); err != nil {
return err
}
*c = (ChainConfig)(*params.FromChainConfig(&tmp))
return nil
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,4 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/ethereum/go-ethereum => github.com/ava-labs/go-ethereum v0.0.0-20240905220331-07aa8e3a81e2
replace github.com/ethereum/go-ethereum => github.com/ava-labs/go-ethereum v0.0.0-20240905235234-ba862f93dfc1
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ github.com/ava-labs/avalanchego v1.11.11 h1:MIQq8xRavRj4ZXHA4G+aMiymig7SOScGOG1S
github.com/ava-labs/avalanchego v1.11.11/go.mod h1:yFx3V31Jy9NFa8GZlgGnwiVf8KGjeF2+Uc99l9Scd/8=
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240815193440-a96bc921e732 h1:wlhGJbmb7s3bU2QWtxKjscGjfHknQiq+cVhhUjONsB8=
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240815193440-a96bc921e732/go.mod h1:RkQLaQ961Xe/sUb3ycn4Qi18vPPuEetTqDf2eDcquAs=
github.com/ava-labs/go-ethereum v0.0.0-20240905220331-07aa8e3a81e2 h1:S/Hzu4LJzqcznlEgL1AEuS50UVUcYdAntbeqj0MZ9ds=
github.com/ava-labs/go-ethereum v0.0.0-20240905220331-07aa8e3a81e2/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU=
github.com/ava-labs/go-ethereum v0.0.0-20240905235234-ba862f93dfc1 h1:x3jEc/ev/c5YsCUWbP5DHzIl0viBY9tn4bUZ2DrlAss=
github.com/ava-labs/go-ethereum v0.0.0-20240905235234-ba862f93dfc1/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down

0 comments on commit 3fb0338

Please sign in to comment.