-
Notifications
You must be signed in to change notification settings - Fork 12
/
auxiliary_request.go
42 lines (34 loc) · 1.18 KB
/
auxiliary_request.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright [2021] - [2022], AssetMantle Pte. Ltd. and the code contributors
// SPDX-License-Identifier: Apache-2.0
package mint
import (
"github.com/AssetMantle/schema/go/ids"
"github.com/asaskevich/govalidator"
sdkTypes "github.com/cosmos/cosmos-sdk/types"
"github.com/AssetMantle/modules/helpers"
)
type auxiliaryRequest struct {
OwnerID ids.IdentityID `json:"ownerID" valid:"required~required field ownerID missing"`
ids.AssetID `json:"assetID" valid:"required~required field assetId missing"`
Value sdkTypes.Int `json:"value" valid:"required~required field value missing"`
}
var _ helpers.AuxiliaryRequest = (*auxiliaryRequest)(nil)
func (auxiliaryRequest auxiliaryRequest) Validate() error {
_, err := govalidator.ValidateStruct(auxiliaryRequest)
return err
}
func auxiliaryRequestFromInterface(request helpers.AuxiliaryRequest) auxiliaryRequest {
switch value := request.(type) {
case auxiliaryRequest:
return value
default:
return auxiliaryRequest{}
}
}
func NewAuxiliaryRequest(ownerID ids.IdentityID, assetID ids.AssetID, value sdkTypes.Int) helpers.AuxiliaryRequest {
return auxiliaryRequest{
OwnerID: ownerID,
AssetID: assetID,
Value: value,
}
}