github.com/aeternity/aepp-sdk-go@v1.0.3-0.20190606142815-1c0ffdc21fd9/generated/models/off_chain_call_contract.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 12 strfmt "github.com/go-openapi/strfmt" 13 14 "github.com/go-openapi/errors" 15 "github.com/go-openapi/swag" 16 17 utils "github.com/aeternity/aepp-sdk-go/utils" 18 ) 19 20 // OffChainCallContract off chain call contract 21 // swagger:model OffChainCallContract 22 type OffChainCallContract struct { 23 24 // abi version 25 // Required: true 26 AbiVersion Uint16 `json:"abi_version"` 27 28 // amount 29 // Required: true 30 Amount utils.BigInt `json:"amount"` 31 32 // Contract call data 33 // Required: true 34 CallData EncodedByteArray `json:"call_data"` 35 36 // Contract caller 37 // Required: true 38 Caller EncodedPubkey `json:"caller"` 39 40 // Contract address 41 // Required: true 42 Contract EncodedPubkey `json:"contract"` 43 44 // gas 45 // Required: true 46 Gas Uint64 `json:"gas"` 47 48 // gas price 49 // Required: true 50 GasPrice utils.BigInt `json:"gas_price"` 51 } 52 53 // Op gets the op of this subtype 54 func (m *OffChainCallContract) Op() string { 55 return "OffChainCallContract" 56 } 57 58 // SetOp sets the op of this subtype 59 func (m *OffChainCallContract) SetOp(val string) { 60 61 } 62 63 // AbiVersion gets the abi version of this subtype 64 65 // Amount gets the amount of this subtype 66 67 // CallData gets the call data of this subtype 68 69 // Caller gets the caller of this subtype 70 71 // Contract gets the contract of this subtype 72 73 // Gas gets the gas of this subtype 74 75 // GasPrice gets the gas price of this subtype 76 77 // UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure 78 func (m *OffChainCallContract) UnmarshalJSON(raw []byte) error { 79 var data struct { 80 81 // abi version 82 // Required: true 83 AbiVersion Uint16 `json:"abi_version"` 84 85 // amount 86 // Required: true 87 Amount utils.BigInt `json:"amount"` 88 89 // Contract call data 90 // Required: true 91 CallData EncodedByteArray `json:"call_data"` 92 93 // Contract caller 94 // Required: true 95 Caller EncodedPubkey `json:"caller"` 96 97 // Contract address 98 // Required: true 99 Contract EncodedPubkey `json:"contract"` 100 101 // gas 102 // Required: true 103 Gas Uint64 `json:"gas"` 104 105 // gas price 106 // Required: true 107 GasPrice utils.BigInt `json:"gas_price"` 108 } 109 buf := bytes.NewBuffer(raw) 110 dec := json.NewDecoder(buf) 111 dec.UseNumber() 112 113 if err := dec.Decode(&data); err != nil { 114 return err 115 } 116 117 var base struct { 118 /* Just the base type fields. Used for unmashalling polymorphic types.*/ 119 120 Op string `json:"op"` 121 } 122 buf = bytes.NewBuffer(raw) 123 dec = json.NewDecoder(buf) 124 dec.UseNumber() 125 126 if err := dec.Decode(&base); err != nil { 127 return err 128 } 129 130 var result OffChainCallContract 131 132 if base.Op != result.Op() { 133 /* Not the type we're looking for. */ 134 return errors.New(422, "invalid op value: %q", base.Op) 135 } 136 137 result.AbiVersion = data.AbiVersion 138 139 result.Amount = data.Amount 140 141 result.CallData = data.CallData 142 143 result.Caller = data.Caller 144 145 result.Contract = data.Contract 146 147 result.Gas = data.Gas 148 149 result.GasPrice = data.GasPrice 150 151 *m = result 152 153 return nil 154 } 155 156 // MarshalJSON marshals this object with a polymorphic type to a JSON structure 157 func (m OffChainCallContract) MarshalJSON() ([]byte, error) { 158 var b1, b2, b3 []byte 159 var err error 160 b1, err = json.Marshal(struct { 161 162 // abi version 163 // Required: true 164 AbiVersion Uint16 `json:"abi_version"` 165 166 // amount 167 // Required: true 168 Amount utils.BigInt `json:"amount"` 169 170 // Contract call data 171 // Required: true 172 CallData EncodedByteArray `json:"call_data"` 173 174 // Contract caller 175 // Required: true 176 Caller EncodedPubkey `json:"caller"` 177 178 // Contract address 179 // Required: true 180 Contract EncodedPubkey `json:"contract"` 181 182 // gas 183 // Required: true 184 Gas Uint64 `json:"gas"` 185 186 // gas price 187 // Required: true 188 GasPrice utils.BigInt `json:"gas_price"` 189 }{ 190 191 AbiVersion: m.AbiVersion, 192 193 Amount: m.Amount, 194 195 CallData: m.CallData, 196 197 Caller: m.Caller, 198 199 Contract: m.Contract, 200 201 Gas: m.Gas, 202 203 GasPrice: m.GasPrice, 204 }, 205 ) 206 if err != nil { 207 return nil, err 208 } 209 b2, err = json.Marshal(struct { 210 Op string `json:"op"` 211 }{ 212 213 Op: m.Op(), 214 }, 215 ) 216 if err != nil { 217 return nil, err 218 } 219 220 return swag.ConcatJSON(b1, b2, b3), nil 221 } 222 223 // Validate validates this off chain call contract 224 func (m *OffChainCallContract) Validate(formats strfmt.Registry) error { 225 var res []error 226 227 if err := m.validateAbiVersion(formats); err != nil { 228 res = append(res, err) 229 } 230 231 if err := m.validateAmount(formats); err != nil { 232 res = append(res, err) 233 } 234 235 if err := m.validateCallData(formats); err != nil { 236 res = append(res, err) 237 } 238 239 if err := m.validateCaller(formats); err != nil { 240 res = append(res, err) 241 } 242 243 if err := m.validateContract(formats); err != nil { 244 res = append(res, err) 245 } 246 247 if err := m.validateGas(formats); err != nil { 248 res = append(res, err) 249 } 250 251 if err := m.validateGasPrice(formats); err != nil { 252 res = append(res, err) 253 } 254 255 if len(res) > 0 { 256 return errors.CompositeValidationError(res...) 257 } 258 return nil 259 } 260 261 func (m *OffChainCallContract) validateAbiVersion(formats strfmt.Registry) error { 262 263 if err := m.AbiVersion.Validate(formats); err != nil { 264 if ve, ok := err.(*errors.Validation); ok { 265 return ve.ValidateName("abi_version") 266 } 267 return err 268 } 269 270 return nil 271 } 272 273 func (m *OffChainCallContract) validateAmount(formats strfmt.Registry) error { 274 275 if err := m.Amount.Validate(formats); err != nil { 276 if ve, ok := err.(*errors.Validation); ok { 277 return ve.ValidateName("amount") 278 } 279 return err 280 } 281 282 return nil 283 } 284 285 func (m *OffChainCallContract) validateCallData(formats strfmt.Registry) error { 286 287 if err := m.CallData.Validate(formats); err != nil { 288 if ve, ok := err.(*errors.Validation); ok { 289 return ve.ValidateName("call_data") 290 } 291 return err 292 } 293 294 return nil 295 } 296 297 func (m *OffChainCallContract) validateCaller(formats strfmt.Registry) error { 298 299 if err := m.Caller.Validate(formats); err != nil { 300 if ve, ok := err.(*errors.Validation); ok { 301 return ve.ValidateName("caller") 302 } 303 return err 304 } 305 306 return nil 307 } 308 309 func (m *OffChainCallContract) validateContract(formats strfmt.Registry) error { 310 311 if err := m.Contract.Validate(formats); err != nil { 312 if ve, ok := err.(*errors.Validation); ok { 313 return ve.ValidateName("contract") 314 } 315 return err 316 } 317 318 return nil 319 } 320 321 func (m *OffChainCallContract) validateGas(formats strfmt.Registry) error { 322 323 if err := m.Gas.Validate(formats); err != nil { 324 if ve, ok := err.(*errors.Validation); ok { 325 return ve.ValidateName("gas") 326 } 327 return err 328 } 329 330 return nil 331 } 332 333 func (m *OffChainCallContract) validateGasPrice(formats strfmt.Registry) error { 334 335 if err := m.GasPrice.Validate(formats); err != nil { 336 if ve, ok := err.(*errors.Validation); ok { 337 return ve.ValidateName("gas_price") 338 } 339 return err 340 } 341 342 return nil 343 } 344 345 // MarshalBinary interface implementation 346 func (m *OffChainCallContract) MarshalBinary() ([]byte, error) { 347 if m == nil { 348 return nil, nil 349 } 350 return swag.WriteJSON(m) 351 } 352 353 // UnmarshalBinary interface implementation 354 func (m *OffChainCallContract) UnmarshalBinary(b []byte) error { 355 var res OffChainCallContract 356 if err := swag.ReadJSON(b, &res); err != nil { 357 return err 358 } 359 *m = res 360 return nil 361 }