Remove hard-coded record types #132
@ -269,7 +269,7 @@ func (k Keeper) GetRecordExpiryQueue(ctx sdk.Context) []*types.ExpiryQueueRecord
|
|||||||
// ProcessSetRecord creates a record.
|
// ProcessSetRecord creates a record.
|
||||||
func (k Keeper) ProcessSetRecord(ctx sdk.Context, msg types.MsgSetRecord) (*types.ReadableRecord, error) {
|
func (k Keeper) ProcessSetRecord(ctx sdk.Context, msg types.MsgSetRecord) (*types.ReadableRecord, error) {
|
||||||
payload := msg.Payload.ToReadablePayload()
|
payload := msg.Payload.ToReadablePayload()
|
||||||
record := types.ReadableRecord{Attributes: payload.Record, BondID: msg.BondId}
|
record := types.ReadableRecord{Attributes: payload.RecordAttributes, BondID: msg.BondId}
|
||||||
|
|
||||||
// Check signatures.
|
// Check signatures.
|
||||||
resourceSignBytes, _ := record.GetSignBytes()
|
resourceSignBytes, _ := record.GetSignBytes()
|
||||||
|
@ -41,7 +41,7 @@ type ReadableRecord struct {
|
|||||||
// Why? Because go-amino can't handle maps: https://github.com/tendermint/go-amino/issues/4.
|
// Why? Because go-amino can't handle maps: https://github.com/tendermint/go-amino/issues/4.
|
||||||
func (payloadObj *ReadablePayload) ToPayload() Payload {
|
func (payloadObj *ReadablePayload) ToPayload() Payload {
|
||||||
// Note: record directly contains the attributes here
|
// Note: record directly contains the attributes here
|
||||||
attributes := helpers.MarshalMapToJSONBytes(payloadObj.Record)
|
attributes := payloadObj.RecordAttributes
|
||||||
payload := Payload{
|
payload := Payload{
|
||||||
Record: &Record{
|
Record: &Record{
|
||||||
Deleted: false,
|
Deleted: false,
|
||||||
@ -66,8 +66,6 @@ func (payload Payload) ToReadablePayload() ReadablePayload {
|
|||||||
// ToRecordObj converts Record to RecordObj.
|
// ToRecordObj converts Record to RecordObj.
|
||||||
// Why? Because go-amino can't handle maps: https://github.com/tendermint/go-amino/issues/4.
|
// Why? Because go-amino can't handle maps: https://github.com/tendermint/go-amino/issues/4.
|
||||||
func (r *ReadableRecord) ToRecordObj() (Record, error) {
|
func (r *ReadableRecord) ToRecordObj() (Record, error) {
|
||||||
attributes := helpers.MarshalMapToJSONBytes(r.Attributes)
|
|
||||||
|
|
||||||
var resourceObj Record
|
var resourceObj Record
|
||||||
|
|
||||||
resourceObj.Id = r.ID
|
resourceObj.Id = r.ID
|
||||||
@ -82,8 +80,8 @@ func (r *ReadableRecord) ToRecordObj() (Record, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ToReadableRecord converts Record to a serializable object
|
// ToReadableRecord converts Record to a serializable object
|
||||||
func (r *Record) ToReadableRecord() RecordEncodable {
|
func (r *Record) ToReadableRecord() ReadableRecord {
|
||||||
var resourceObj RecordEncodable
|
var resourceObj ReadableRecord
|
||||||
|
|
||||||
resourceObj.ID = r.Id
|
resourceObj.ID = r.Id
|
||||||
resourceObj.BondID = r.BondId
|
resourceObj.BondID = r.BondId
|
||||||
|
Loading…
Reference in New Issue
Block a user