payload to record attributes

This commit is contained in:
0xmuralik 2023-01-19 15:44:56 +05:30
parent 67208b08af
commit bf1670be78
3 changed files with 65 additions and 2 deletions

View File

@ -6,4 +6,4 @@ record:
repo_hash_reference:
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
version: 1.0.0
type: binary
type: Binary

View File

@ -6,4 +6,4 @@ record:
repo_hash_reference:
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
version: 1.0.0
type: binary
type: Binary

View File

@ -68,6 +68,69 @@ func payLoadAttributes(recordPayLoad map[string]interface{}) (*codectypes.Any, e
}
return codectypes.NewAnyWithValue(&attributes)
}
case "GitRepository":
{
var attributes GitRepository
err := json.Unmarshal(bz, &attributes)
if err != nil {
return &codectypes.Any{}, err
}
return codectypes.NewAnyWithValue(&attributes)
}
case "Binary":
{
var attributes Binary
err := json.Unmarshal(bz, &attributes)
if err != nil {
return &codectypes.Any{}, err
}
return codectypes.NewAnyWithValue(&attributes)
}
case "DockerImage":
{
var attributes DockerImage
err := json.Unmarshal(bz, &attributes)
if err != nil {
return &codectypes.Any{}, err
}
return codectypes.NewAnyWithValue(&attributes)
}
case "WatcherRegistrationRecord":
{
var attributes WatcherRegistrationRecord
err := json.Unmarshal(bz, &attributes)
if err != nil {
return &codectypes.Any{}, err
}
return codectypes.NewAnyWithValue(&attributes)
}
case "ResponderContract":
{
var attributes ResponderContract
err := json.Unmarshal(bz, &attributes)
if err != nil {
return &codectypes.Any{}, err
}
return codectypes.NewAnyWithValue(&attributes)
}
case "JSPackage":
{
var attributes JSPackage
err := json.Unmarshal(bz, &attributes)
if err != nil {
return &codectypes.Any{}, err
}
return codectypes.NewAnyWithValue(&attributes)
}
case "ChainRegistrationRecord":
{
var attributes ChainRegistrationRecord
err := json.Unmarshal(bz, &attributes)
if err != nil {
return &codectypes.Any{}, err
}
return codectypes.NewAnyWithValue(&attributes)
}
default:
return &codectypes.Any{}, fmt.Errorf("unsupported record type %s", recordType.(string))
}