/
asset.go
26 lines (22 loc) · 1.15 KB
/
asset.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
package docs
import (
"net/http"
"github.com/AssetMantle/schema/go/data"
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 assetClassificationHandler(context client.Context) http.HandlerFunc {
return func(responseWriter http.ResponseWriter, httpRequest *http.Request) {
id, immutables, _ := ReadAndProcess(context, false, true, responseWriter, httpRequest)
rest.PostProcessResponse(responseWriter, context, newResponse(id.AsString(), immutables.GetProperty(constants.BondAmountProperty.GetID()).Get().(properties.MetaProperty).GetData().Get().(data.NumberData).AsString(), nil))
}
}
func assetIDHandler(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.NewAssetID(classificationID, immutables).AsString(), "", nil))
}
}