github.com/aeternity/aepp-sdk-go@v1.0.3-0.20190606142815-1c0ffdc21fd9/generated/models/channel_force_progress_tx.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "bytes" 10 "encoding/json" 11 "io" 12 13 strfmt "github.com/go-openapi/strfmt" 14 15 "github.com/go-openapi/errors" 16 "github.com/go-openapi/runtime" 17 "github.com/go-openapi/swag" 18 19 utils "github.com/aeternity/aepp-sdk-go/utils" 20 ) 21 22 // ChannelForceProgressTx channel force progress tx 23 // swagger:model ChannelForceProgressTx 24 type ChannelForceProgressTx struct { 25 26 // channel id 27 // Required: true 28 ChannelID EncodedPubkey `json:"channel_id"` 29 30 // fee 31 // Required: true 32 Fee utils.BigInt `json:"fee"` 33 34 // from id 35 // Required: true 36 FromID EncodedPubkey `json:"from_id"` 37 38 // nonce 39 Nonce Uint64 `json:"nonce,omitempty"` 40 41 // The whole set of off-chain state trees 42 OffchainTrees EncodedByteArray `json:"offchain_trees,omitempty"` 43 44 // payload 45 // Required: true 46 Payload EncodedByteArray `json:"payload"` 47 48 // Channel's next round 49 // Required: true 50 Round Uint64 `json:"round"` 51 52 // Channel's next state_hash 53 // Required: true 54 StateHash EncodedHash `json:"state_hash"` 55 56 // ttl 57 TTL Uint64 `json:"ttl,omitempty"` 58 59 updateField OffChainUpdate 60 } 61 62 // Update gets the update of this base type 63 func (m *ChannelForceProgressTx) Update() OffChainUpdate { 64 return m.updateField 65 } 66 67 // SetUpdate sets the update of this base type 68 func (m *ChannelForceProgressTx) SetUpdate(val OffChainUpdate) { 69 m.updateField = val 70 } 71 72 // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure 73 func (m *ChannelForceProgressTx) UnmarshalJSON(raw []byte) error { 74 var data struct { 75 ChannelID EncodedPubkey `json:"channel_id"` 76 77 Fee utils.BigInt `json:"fee"` 78 79 FromID EncodedPubkey `json:"from_id"` 80 81 Nonce Uint64 `json:"nonce,omitempty"` 82 83 OffchainTrees EncodedByteArray `json:"offchain_trees,omitempty"` 84 85 Payload EncodedByteArray `json:"payload"` 86 87 Round Uint64 `json:"round"` 88 89 StateHash EncodedHash `json:"state_hash"` 90 91 TTL Uint64 `json:"ttl,omitempty"` 92 93 Update json.RawMessage `json:"update"` 94 } 95 buf := bytes.NewBuffer(raw) 96 dec := json.NewDecoder(buf) 97 dec.UseNumber() 98 99 if err := dec.Decode(&data); err != nil { 100 return err 101 } 102 103 propUpdate, err := UnmarshalOffChainUpdate(bytes.NewBuffer(data.Update), runtime.JSONConsumer()) 104 if err != nil && err != io.EOF { 105 return err 106 } 107 108 var result ChannelForceProgressTx 109 110 // channel_id 111 result.ChannelID = data.ChannelID 112 113 // fee 114 result.Fee = data.Fee 115 116 // from_id 117 result.FromID = data.FromID 118 119 // nonce 120 result.Nonce = data.Nonce 121 122 // offchain_trees 123 result.OffchainTrees = data.OffchainTrees 124 125 // payload 126 result.Payload = data.Payload 127 128 // round 129 result.Round = data.Round 130 131 // state_hash 132 result.StateHash = data.StateHash 133 134 // ttl 135 result.TTL = data.TTL 136 137 // update 138 result.updateField = propUpdate 139 140 *m = result 141 142 return nil 143 } 144 145 // MarshalJSON marshals this object with a polymorphic type to a JSON structure 146 func (m ChannelForceProgressTx) MarshalJSON() ([]byte, error) { 147 var b1, b2, b3 []byte 148 var err error 149 b1, err = json.Marshal(struct { 150 ChannelID EncodedPubkey `json:"channel_id"` 151 152 Fee utils.BigInt `json:"fee"` 153 154 FromID EncodedPubkey `json:"from_id"` 155 156 Nonce Uint64 `json:"nonce,omitempty"` 157 158 OffchainTrees EncodedByteArray `json:"offchain_trees,omitempty"` 159 160 Payload EncodedByteArray `json:"payload"` 161 162 Round Uint64 `json:"round"` 163 164 StateHash EncodedHash `json:"state_hash"` 165 166 TTL Uint64 `json:"ttl,omitempty"` 167 }{ 168 169 ChannelID: m.ChannelID, 170 171 Fee: m.Fee, 172 173 FromID: m.FromID, 174 175 Nonce: m.Nonce, 176 177 OffchainTrees: m.OffchainTrees, 178 179 Payload: m.Payload, 180 181 Round: m.Round, 182 183 StateHash: m.StateHash, 184 185 TTL: m.TTL, 186 }, 187 ) 188 if err != nil { 189 return nil, err 190 } 191 b2, err = json.Marshal(struct { 192 Update OffChainUpdate `json:"update"` 193 }{ 194 195 Update: m.updateField, 196 }, 197 ) 198 if err != nil { 199 return nil, err 200 } 201 202 return swag.ConcatJSON(b1, b2, b3), nil 203 } 204 205 // Validate validates this channel force progress tx 206 func (m *ChannelForceProgressTx) Validate(formats strfmt.Registry) error { 207 var res []error 208 209 if err := m.validateChannelID(formats); err != nil { 210 res = append(res, err) 211 } 212 213 if err := m.validateFee(formats); err != nil { 214 res = append(res, err) 215 } 216 217 if err := m.validateFromID(formats); err != nil { 218 res = append(res, err) 219 } 220 221 if err := m.validateNonce(formats); err != nil { 222 res = append(res, err) 223 } 224 225 if err := m.validateOffchainTrees(formats); err != nil { 226 res = append(res, err) 227 } 228 229 if err := m.validatePayload(formats); err != nil { 230 res = append(res, err) 231 } 232 233 if err := m.validateRound(formats); err != nil { 234 res = append(res, err) 235 } 236 237 if err := m.validateStateHash(formats); err != nil { 238 res = append(res, err) 239 } 240 241 if err := m.validateTTL(formats); err != nil { 242 res = append(res, err) 243 } 244 245 if err := m.validateUpdate(formats); err != nil { 246 res = append(res, err) 247 } 248 249 if len(res) > 0 { 250 return errors.CompositeValidationError(res...) 251 } 252 return nil 253 } 254 255 func (m *ChannelForceProgressTx) validateChannelID(formats strfmt.Registry) error { 256 257 if err := m.ChannelID.Validate(formats); err != nil { 258 if ve, ok := err.(*errors.Validation); ok { 259 return ve.ValidateName("channel_id") 260 } 261 return err 262 } 263 264 return nil 265 } 266 267 func (m *ChannelForceProgressTx) validateFee(formats strfmt.Registry) error { 268 269 if err := m.Fee.Validate(formats); err != nil { 270 if ve, ok := err.(*errors.Validation); ok { 271 return ve.ValidateName("fee") 272 } 273 return err 274 } 275 276 return nil 277 } 278 279 func (m *ChannelForceProgressTx) validateFromID(formats strfmt.Registry) error { 280 281 if err := m.FromID.Validate(formats); err != nil { 282 if ve, ok := err.(*errors.Validation); ok { 283 return ve.ValidateName("from_id") 284 } 285 return err 286 } 287 288 return nil 289 } 290 291 func (m *ChannelForceProgressTx) validateNonce(formats strfmt.Registry) error { 292 293 if swag.IsZero(m.Nonce) { // not required 294 return nil 295 } 296 297 if err := m.Nonce.Validate(formats); err != nil { 298 if ve, ok := err.(*errors.Validation); ok { 299 return ve.ValidateName("nonce") 300 } 301 return err 302 } 303 304 return nil 305 } 306 307 func (m *ChannelForceProgressTx) validateOffchainTrees(formats strfmt.Registry) error { 308 309 if swag.IsZero(m.OffchainTrees) { // not required 310 return nil 311 } 312 313 if err := m.OffchainTrees.Validate(formats); err != nil { 314 if ve, ok := err.(*errors.Validation); ok { 315 return ve.ValidateName("offchain_trees") 316 } 317 return err 318 } 319 320 return nil 321 } 322 323 func (m *ChannelForceProgressTx) validatePayload(formats strfmt.Registry) error { 324 325 if err := m.Payload.Validate(formats); err != nil { 326 if ve, ok := err.(*errors.Validation); ok { 327 return ve.ValidateName("payload") 328 } 329 return err 330 } 331 332 return nil 333 } 334 335 func (m *ChannelForceProgressTx) validateRound(formats strfmt.Registry) error { 336 337 if err := m.Round.Validate(formats); err != nil { 338 if ve, ok := err.(*errors.Validation); ok { 339 return ve.ValidateName("round") 340 } 341 return err 342 } 343 344 return nil 345 } 346 347 func (m *ChannelForceProgressTx) validateStateHash(formats strfmt.Registry) error { 348 349 if err := m.StateHash.Validate(formats); err != nil { 350 if ve, ok := err.(*errors.Validation); ok { 351 return ve.ValidateName("state_hash") 352 } 353 return err 354 } 355 356 return nil 357 } 358 359 func (m *ChannelForceProgressTx) validateTTL(formats strfmt.Registry) error { 360 361 if swag.IsZero(m.TTL) { // not required 362 return nil 363 } 364 365 if err := m.TTL.Validate(formats); err != nil { 366 if ve, ok := err.(*errors.Validation); ok { 367 return ve.ValidateName("ttl") 368 } 369 return err 370 } 371 372 return nil 373 } 374 375 func (m *ChannelForceProgressTx) validateUpdate(formats strfmt.Registry) error { 376 377 if err := m.Update().Validate(formats); err != nil { 378 if ve, ok := err.(*errors.Validation); ok { 379 return ve.ValidateName("update") 380 } 381 return err 382 } 383 384 return nil 385 } 386 387 // MarshalBinary interface implementation 388 func (m *ChannelForceProgressTx) MarshalBinary() ([]byte, error) { 389 if m == nil { 390 return nil, nil 391 } 392 return swag.WriteJSON(m) 393 } 394 395 // UnmarshalBinary interface implementation 396 func (m *ChannelForceProgressTx) UnmarshalBinary(b []byte) error { 397 var res ChannelForceProgressTx 398 if err := swag.ReadJSON(b, &res); err != nil { 399 return err 400 } 401 *m = res 402 return nil 403 }