Skip to content

Commit

Permalink
Fix decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
firelizzard18 committed Jun 17, 2024
1 parent 1b23603 commit 1b25ea9
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 32 deletions.
24 changes: 12 additions & 12 deletions cmd/accumulated/run/types_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -2689,13 +2689,13 @@ func (v *Config) UnmarshalJSON(data []byte) error {
v.Logging = u.Logging
v.Instrumentation = u.Instrumentation
v.P2P = u.P2P
if u.Configurations.Value != nil {
if u.Configurations != nil && u.Configurations.Value != nil {
v.Configurations = make([]Configuration, len(u.Configurations.Value))
for i, x := range u.Configurations.Value {
v.Configurations[i] = x
}
}
if u.Services.Value != nil {
if u.Services != nil && u.Services.Value != nil {
v.Services = make([]Service, len(u.Services.Value))
for i, x := range u.Services.Value {
v.Services[i] = x
Expand Down Expand Up @@ -2740,7 +2740,7 @@ func (v *ConsensusService) UnmarshalJSON(data []byte) error {
v.Listen = u.Listen.Value
}

if u.BootstrapPeers.Value != nil {
if u.BootstrapPeers != nil && u.BootstrapPeers.Value != nil {
v.BootstrapPeers = make([]p2p.Multiaddr, len(u.BootstrapPeers.Value))
for i, x := range u.BootstrapPeers.Value {
v.BootstrapPeers[i] = x
Expand Down Expand Up @@ -2831,13 +2831,13 @@ func (v *CoreValidatorConfiguration) UnmarshalJSON(data []byte) error {

v.DnGenesis = u.DnGenesis
v.BvnGenesis = u.BvnGenesis
if u.DnBootstrapPeers.Value != nil {
if u.DnBootstrapPeers != nil && u.DnBootstrapPeers.Value != nil {
v.DnBootstrapPeers = make([]p2p.Multiaddr, len(u.DnBootstrapPeers.Value))
for i, x := range u.DnBootstrapPeers.Value {
v.DnBootstrapPeers[i] = x
}
}
if u.BvnBootstrapPeers.Value != nil {
if u.BvnBootstrapPeers != nil && u.BvnBootstrapPeers.Value != nil {
v.BvnBootstrapPeers = make([]p2p.Multiaddr, len(u.BvnBootstrapPeers.Value))
for i, x := range u.BvnBootstrapPeers.Value {
v.BvnBootstrapPeers[i] = x
Expand Down Expand Up @@ -2990,7 +2990,7 @@ func (v *HttpListener) UnmarshalJSON(data []byte) error {
if err != nil {
return err
}
if u.Listen.Value != nil {
if u.Listen != nil && u.Listen.Value != nil {
v.Listen = make([]p2p.Multiaddr, len(u.Listen.Value))
for i, x := range u.Listen.Value {
v.Listen[i] = x
Expand Down Expand Up @@ -3028,7 +3028,7 @@ func (v *HttpPeerMapEntry) UnmarshalJSON(data []byte) error {
}

v.Partitions = u.Partitions
if u.Addresses.Value != nil {
if u.Addresses != nil && u.Addresses.Value != nil {
v.Addresses = make([]p2p.Multiaddr, len(u.Addresses.Value))
for i, x := range u.Addresses.Value {
v.Addresses[i] = x
Expand Down Expand Up @@ -3075,7 +3075,7 @@ func (v *HttpService) UnmarshalJSON(data []byte) error {
if !(v.Type() == u.Type) {
return fmt.Errorf("field Type: not equal: want %v, got %v", v.Type(), u.Type)
}
if u.Listen.Value != nil {
if u.Listen != nil && u.Listen.Value != nil {
v.HttpListener.Listen = make([]p2p.Multiaddr, len(u.Listen.Value))
for i, x := range u.Listen.Value {
v.HttpListener.Listen[i] = x
Expand Down Expand Up @@ -3120,7 +3120,7 @@ func (v *Instrumentation) UnmarshalJSON(data []byte) error {
if err != nil {
return err
}
if u.Listen.Value != nil {
if u.Listen != nil && u.Listen.Value != nil {
v.HttpListener.Listen = make([]p2p.Multiaddr, len(u.Listen.Value))
for i, x := range u.Listen.Value {
v.HttpListener.Listen[i] = x
Expand Down Expand Up @@ -3298,13 +3298,13 @@ func (v *P2P) UnmarshalJSON(data []byte) error {
if err != nil {
return err
}
if u.Listen.Value != nil {
if u.Listen != nil && u.Listen.Value != nil {
v.Listen = make([]p2p.Multiaddr, len(u.Listen.Value))
for i, x := range u.Listen.Value {
v.Listen[i] = x
}
}
if u.BootstrapPeers.Value != nil {
if u.BootstrapPeers != nil && u.BootstrapPeers.Value != nil {
v.BootstrapPeers = make([]p2p.Multiaddr, len(u.BootstrapPeers.Value))
for i, x := range u.BootstrapPeers.Value {
v.BootstrapPeers[i] = x
Expand Down Expand Up @@ -3491,7 +3491,7 @@ func (v *SubnodeService) UnmarshalJSON(data []byte) error {
v.NodeKey = u.NodeKey.Value
}

if u.Services.Value != nil {
if u.Services != nil && u.Services.Value != nil {
v.Services = make([]Service, len(u.Services.Value))
for i, x := range u.Services.Value {
v.Services[i] = x
Expand Down
4 changes: 2 additions & 2 deletions internal/api/v2/types_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -4742,7 +4742,7 @@ func (v *SignaturePage) UnmarshalJSON(data []byte) error {
return err
}
v.Signer = u.Signer
if u.Signatures.Value != nil {
if u.Signatures != nil && u.Signatures.Value != nil {
v.Signatures = make([]protocol.Signature, len(u.Signatures.Value))
for i, x := range u.Signatures.Value {
v.Signatures[i] = x
Expand Down Expand Up @@ -4950,7 +4950,7 @@ func (v *TransactionQueryResponse) UnmarshalJSON(data []byte) error {
}
v.Txid = u.Txid
v.Transaction = u.Transaction
if u.Signatures.Value != nil {
if u.Signatures != nil && u.Signatures.Value != nil {
v.Signatures = make([]protocol.Signature, len(u.Signatures.Value))
for i, x := range u.Signatures.Value {
v.Signatures[i] = x
Expand Down
2 changes: 1 addition & 1 deletion internal/core/healing/types_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (v *PeerInfo) UnmarshalJSON(data []byte) error {
v.Key = *x
}
v.Status = u.Status
if u.Addresses.Value != nil {
if u.Addresses != nil && u.Addresses.Value != nil {
v.Addresses = make([]p2p.Multiaddr, len(u.Addresses.Value))
for i, x := range u.Addresses.Value {
v.Addresses[i] = x
Expand Down
4 changes: 2 additions & 2 deletions internal/node/config/types_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,13 +774,13 @@ func (v *P2P) UnmarshalJSON(data []byte) error {
if err != nil {
return err
}
if u.Listen.Value != nil {
if u.Listen != nil && u.Listen.Value != nil {
v.Listen = make([]p2p.Multiaddr, len(u.Listen.Value))
for i, x := range u.Listen.Value {
v.Listen[i] = x
}
}
if u.BootstrapPeers.Value != nil {
if u.BootstrapPeers != nil && u.BootstrapPeers.Value != nil {
v.BootstrapPeers = make([]p2p.Multiaddr, len(u.BootstrapPeers.Value))
for i, x := range u.BootstrapPeers.Value {
v.BootstrapPeers[i] = x
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/v3/message/types_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -3609,7 +3609,7 @@ func (v *EventMessage) UnmarshalJSON(data []byte) error {
if !(v.Type() == u.Type) {
return fmt.Errorf("field Type: not equal: want %v, got %v", v.Type(), u.Type)
}
if u.Value.Value != nil {
if u.Value != nil && u.Value.Value != nil {
v.Value = make([]api.Event, len(u.Value.Value))
for i, x := range u.Value.Value {
v.Value[i] = x
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/v3/types_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -8836,7 +8836,7 @@ func (v *FindServiceResult) UnmarshalJSON(data []byte) error {
}

v.Status = u.Status
if u.Addresses.Value != nil {
if u.Addresses != nil && u.Addresses.Value != nil {
v.Addresses = make([]p2p.Multiaddr, len(u.Addresses.Value))
for i, x := range u.Addresses.Value {
v.Addresses[i] = x
Expand Down Expand Up @@ -9383,7 +9383,7 @@ func (v *RecordRange[T]) UnmarshalJSON(data []byte) error {
if !(v.RecordType() == u.RecordType) {
return fmt.Errorf("field RecordType: not equal: want %v, got %v", v.RecordType(), u.RecordType)
}
if u.Records.Value != nil {
if u.Records != nil && u.Records.Value != nil {
v.Records = make([]T, len(u.Records.Value))
for i, x := range u.Records.Value {
v.Records[i] = x
Expand Down
4 changes: 2 additions & 2 deletions pkg/types/messaging/types_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -2942,7 +2942,7 @@ func (v *Envelope) UnmarshalJSON(data []byte) error {
if err != nil {
return err
}
if u.Signatures.Value != nil {
if u.Signatures != nil && u.Signatures.Value != nil {
v.Signatures = make([]protocol.Signature, len(u.Signatures.Value))
for i, x := range u.Signatures.Value {
v.Signatures[i] = x
Expand All @@ -2954,7 +2954,7 @@ func (v *Envelope) UnmarshalJSON(data []byte) error {
v.TxHash = x
}
v.Transaction = u.Transaction
if u.Messages.Value != nil {
if u.Messages != nil && u.Messages.Value != nil {
v.Messages = make([]Message, len(u.Messages.Value))
for i, x := range u.Messages.Value {
v.Messages[i] = x
Expand Down
12 changes: 6 additions & 6 deletions protocol/types_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -22758,7 +22758,7 @@ func (v *NetworkMaintenance) UnmarshalJSON(data []byte) error {
if !(v.Type() == u.Type) {
return fmt.Errorf("field Type: not equal: want %v, got %v", v.Type(), u.Type)
}
if u.Operations.Value != nil {
if u.Operations != nil && u.Operations.Value != nil {
v.Operations = make([]NetworkMaintenanceOperation, len(u.Operations.Value))
for i, x := range u.Operations.Value {
v.Operations[i] = x
Expand Down Expand Up @@ -23352,7 +23352,7 @@ func (v *SignatureSet) UnmarshalJSON(data []byte) error {
} else {
v.TransactionHash = *x
}
if u.Signatures.Value != nil {
if u.Signatures != nil && u.Signatures.Value != nil {
v.Signatures = make([]Signature, len(u.Signatures.Value))
for i, x := range u.Signatures.Value {
v.Signatures[i] = x
Expand Down Expand Up @@ -23439,7 +23439,7 @@ func (v *SyntheticCreateIdentity) UnmarshalJSON(data []byte) error {
v.SyntheticOrigin.Initiator = u.Initiator
v.SyntheticOrigin.FeeRefund = u.FeeRefund
v.SyntheticOrigin.Index = u.Index
if u.Accounts.Value != nil {
if u.Accounts != nil && u.Accounts.Value != nil {
v.Accounts = make([]Account, len(u.Accounts.Value))
for i, x := range u.Accounts.Value {
v.Accounts[i] = x
Expand Down Expand Up @@ -23998,7 +23998,7 @@ func (v *TransactionStatus) UnmarshalJSON(data []byte) error {

v.Received = u.Received
v.Initiator = u.Initiator
if u.Signers.Value != nil {
if u.Signers != nil && u.Signers.Value != nil {
v.Signers = make([]Signer, len(u.Signers.Value))
for i, x := range u.Signers.Value {
v.Signers[i] = x
Expand Down Expand Up @@ -24129,7 +24129,7 @@ func (v *UpdateAccountAuth) UnmarshalJSON(data []byte) error {
if !(v.Type() == u.Type) {
return fmt.Errorf("field Type: not equal: want %v, got %v", v.Type(), u.Type)
}
if u.Operations.Value != nil {
if u.Operations != nil && u.Operations.Value != nil {
v.Operations = make([]AccountAuthOperation, len(u.Operations.Value))
for i, x := range u.Operations.Value {
v.Operations[i] = x
Expand Down Expand Up @@ -24236,7 +24236,7 @@ func (v *UpdateKeyPage) UnmarshalJSON(data []byte) error {
if !(v.Type() == u.Type) {
return fmt.Errorf("field Type: not equal: want %v, got %v", v.Type(), u.Type)
}
if u.Operation.Value != nil {
if u.Operation != nil && u.Operation.Value != nil {
v.Operation = make([]KeyPageOperation, len(u.Operation.Value))
for i, x := range u.Operation.Value {
v.Operation[i] = x
Expand Down
2 changes: 1 addition & 1 deletion test/simulator/recorder_types_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ func (v *recordMessages) UnmarshalJSON(data []byte) error {
if err != nil {
return err
}
if u.Messages.Value != nil {
if u.Messages != nil && u.Messages.Value != nil {
v.Messages = make([]consensus.Message, len(u.Messages.Value))
for i, x := range u.Messages.Value {
v.Messages[i] = x
Expand Down
2 changes: 1 addition & 1 deletion tools/cmd/debug/types_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ func (v *DbPatch) UnmarshalJSON(data []byte) error {
if err != nil {
return err
}
if u.Operations.Value != nil {
if u.Operations != nil && u.Operations.Value != nil {
v.Operations = make([]DbPatchOp, len(u.Operations.Value))
for i, x := range u.Operations.Value {
v.Operations[i] = x
Expand Down
2 changes: 1 addition & 1 deletion tools/cmd/gen-types/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ func GoValueFromJson(field *Field, tgtName, srcName, errName string, errArgs ...
return fmt.Sprintf("\tif %s != nil { %s = %[1]s.Value }\n", srcName, tgtName), nil
}
return fmt.Sprintf(
" if %[3]s.Value != nil {\n"+
" if %[3]s != nil && %[3]s.Value != nil {\n"+
" %[1]s = make(%s, len(%s.Value));\n"+
" for i, x := range %[3]s.Value {\n"+
" %[1]s[i] = x\n"+
Expand Down
2 changes: 1 addition & 1 deletion tools/internal/typegen/types_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ func (v *EntityRecord) UnmarshalJSON(data []byte) error {
v.ValueStore = u.ValueStore
v.Root = u.Root
v.Interface = u.Interface
if u.Attributes.Value != nil {
if u.Attributes != nil && u.Attributes.Value != nil {
v.Attributes = make([]Record, len(u.Attributes.Value))
for i, x := range u.Attributes.Value {
v.Attributes[i] = x
Expand Down

0 comments on commit 1b25ea9

Please sign in to comment.