/
identity.go
45 lines (37 loc) · 2 KB
/
identity.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
43
44
45
package docs
import (
"net/http"
"github.com/AssetMantle/schema/go/data"
baseData "github.com/AssetMantle/schema/go/data/base"
baseDocuments "github.com/AssetMantle/schema/go/documents/base"
errorConstants "github.com/AssetMantle/schema/go/errors/constants"
baseIDs "github.com/AssetMantle/schema/go/ids/base"
"github.com/AssetMantle/schema/go/properties"
"github.com/AssetMantle/schema/go/properties/constants"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/types/rest"
)
func nameIdentityIDHandler(context client.Context) http.HandlerFunc {
return func(responseWriter http.ResponseWriter, httpRequest *http.Request) {
transactionRequest := Prototype()
if !rest.ReadRESTReq(responseWriter, httpRequest, context.LegacyAmino, &transactionRequest) {
panic(errorConstants.IncorrectFormat)
}
if rest.CheckBadRequestError(responseWriter, transactionRequest.Validate()) {
panic(errorConstants.IncorrectFormat)
}
rest.PostProcessResponse(responseWriter, context, newResponse(baseDocuments.NewNameIdentity(baseIDs.NewStringID(transactionRequest.(request).Name), baseData.PrototypeListData()).GetNameIdentityID().AsString(), "", nil))
}
}
func identityIDHandler(context client.Context) http.HandlerFunc {
return func(responseWriter http.ResponseWriter, httpRequest *http.Request) {
classificationID, immutables, _ := ReadAndProcess(context, false, false, responseWriter, httpRequest)
rest.PostProcessResponse(responseWriter, context, newResponse(baseIDs.NewIdentityID(classificationID, immutables).AsString(), "", nil))
}
}
func identityClassificationHandler(context client.Context) http.HandlerFunc {
return func(responseWriter http.ResponseWriter, httpRequest *http.Request) {
id, immutables, _ := ReadAndProcess(context, true, true, responseWriter, httpRequest)
rest.PostProcessResponse(responseWriter, context, newResponse(id.AsString(), immutables.GetProperty(constants.BondAmountProperty.GetID()).Get().(properties.MetaProperty).GetData().Get().(data.NumberData).AsString(), nil))
}
}