Skip to content

Commit

Permalink
Add support for JSON marshalling the DeployChainDeploy struct
Browse files Browse the repository at this point in the history
  • Loading branch information
mdehoog committed Oct 4, 2024
1 parent d390d9a commit b324d3a
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions bindings/deploy_chain_deploy_marshalling.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package bindings

import (
"encoding/json"
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)

type deployChainDeployMarshal struct {
ChainID *big.Int
ConfigHash common.Hash
OutputRoot common.Hash
BatchInbox common.Address
Addresses DeployChainDeployAddresses
Raw types.Log
}

func (d *DeployChainDeploy) MarshalJSON() ([]byte, error) {
m := deployChainDeployMarshal{
ChainID: d.ChainID,
ConfigHash: d.ConfigHash,
OutputRoot: d.OutputRoot,
BatchInbox: d.BatchInbox,
Addresses: d.Addresses,
Raw: d.Raw,
}
return json.Marshal(m)
}

func (d *DeployChainDeploy) UnmarshalJSON(data []byte) error {
var m deployChainDeployMarshal
err := json.Unmarshal(data, &m)
if err != nil {
return err
}
d.ChainID = m.ChainID
d.ConfigHash = m.ConfigHash
d.OutputRoot = m.OutputRoot
d.BatchInbox = m.BatchInbox
d.Addresses = m.Addresses
d.Raw = m.Raw
return nil
}

0 comments on commit b324d3a

Please sign in to comment.