Skip to content

Commit

Permalink
update API
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronc committed Nov 23, 2023
1 parent 6304cbb commit 347b33c
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 66 deletions.
83 changes: 40 additions & 43 deletions proto/regen/ecocredit/curation/v1beta1/state.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,83 +3,80 @@ syntax = "proto3";
package regen.ecocredit.curation.v1beta1;

import "cosmos/orm/v1alpha1/orm.proto";

Check failure on line 5 in proto/regen/ecocredit/curation/v1beta1/state.proto

View workflow job for this annotation

GitHub Actions / buf-lint

read cosmos/orm/v1alpha1/orm.proto: file does not exist
import "regen/ecocredit/curation/v1beta1/types.proto";

message TagSet {
message TagDefinition {
option (cosmos.orm.v1alpha1.table) = {
id: 1,
primary_key: {fields: "id", auto_increment: true}
index: {id: 1, fields: "curator"}
};

uint64 id = 1;
string curator = 2;
string domain_name = 3;
bytes curator_address = 2;
TagMeta metadata = 3;
TagType type = 4;
}

message TagDefinition {
option (cosmos.orm.v1alpha1.table) = {
id: 1,
primary_key: {fields: "id", auto_increment: true}
index: {id: 1, fields: "tag_set,name", unique: true}
};

uint64 id = 1;
uint64 tag_set = 2;
string name = 3;
bytes metadata = 4;
message NumericTagType {
int32 precision = 1;
string min = 2;
string max = 3;
NumericTagTypeSize size = 4;
}

// NumericAttributeDefinition allows curators to define numeric attributes
// which can be assigned to credit classes
message NumericAttributeDefinition {
enum NumericTagTypeSize {
NUMERIC_TAG_TYPE_SIZE_32_UNSPECIFIED = 0;
NUMERIC_TAG_TYPE_SIZE_64 = 1;
}

message AddressTagEntry {
option (cosmos.orm.v1alpha1.table) = {
id: 1,
primary_key: {fields: "id", auto_increment: true}
index: {id: 1, fields: "owner_address"}
id: 2,
primary_key: {fields: "class_id,tag_id"}
};

uint64 id = 1;
bytes owner_address = 2;
bytes metadata = 3;
bytes address = 1;
uint64 tag_id = 2;
TagValue value = 3;
}

// max_decimal_places
uint32 max_decimal_places = 4;
optional int32 min = 5;
optional int32 max = 6;
message TagValue {
oneof sum {
uint32 uint32_value = 1;
uint64 uint64_value = 2;
}
}

message ClassTagEntry {
option (cosmos.orm.v1alpha1.table) = {
id: 1,
id: 3,
primary_key: {fields: "class_id,tag_id"}
};

uint64 class_id = 1;
uint64 tag_id = 2;
bytes metadata = 3;
TagValue value = 3;
}

message TagEntry {
message ProjectTagEntry {
option (cosmos.orm.v1alpha1.table) = {
id: 1,
primary_key: {fields: "target,tag_id"}
id: 4,
primary_key: {fields: "project_id,tag_id"}
};

string target = 1;
uint64 project_id = 1;
uint64 tag_id = 2;
bytes metadata = 3;
TagValue value = 3;
}

message NumericAttributeEntry {
message BatchTagEntry {
option (cosmos.orm.v1alpha1.table) = {
id: 1,
primary_key: {fields: "target,tag_id"}
index:{id: 1, fields: "tag_id,value"}
id: 5,
primary_key: {fields: "batch_id,tag_id"}
};

string target = 1;
uint64 attr_id = 2;
bytes metadata = 3;
// value represents a 32-bit decimal value with 2 decimal places, equivalent to value/100.
sfixed32 value = 4;
uint64 batch_id = 1;
uint64 tag_id = 2;
TagValue value = 3;
}
36 changes: 13 additions & 23 deletions proto/regen/ecocredit/curation/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,27 @@ import "regen/ecocredit/curation/v1beta1/types.proto";

service Msg {
rpc DefineTag(MsgDefineTag) returns (MsgDefineTagResponse) {}
rpc DefineNumericAttr(MsgDefineNumericAttr) returns (MsgDefineNumericAttrResponse) {}
rpc Tag(MsgTag) returns (MsgTagResponse) {}
rpc SetNumericAttr(MsgSetNumericAttr) returns (MsgSetNumericAttrResponse) {}
rpc TagNumeric(MsgTagNumeric) returns (MsgTagNumericResponse) {}
}

message MsgDefineTag {
string curator = 1;
AllowedTagTargets targets = 2;
TagMeta meta = 2;
TagType type = 3;
}

message MsgDefineTagResponse {
string tag_id = 1;
}

message MsgDefineNumericAttr {
string curator = 1;
AllowedTagTargets targets = 2;
string min = 3;
string max = 4;
int32 precision = 5;
}

message MsgDefineNumericAttrResponse {
string tag_id = 1;
}

// MsgTag is the Msg/Tag request type.
message MsgTag {
// curator
string curator = 1;

// taggings are the tag operations.
repeated Tagging taggings = 2;
repeated Tagging operations = 2;

// Tagging is a tag operations.
message Tagging {
Expand All @@ -49,25 +37,27 @@ message MsgTag {

// untag indicates that a tag should be removed if set to true.
bool untag = 3;

}
}

message MsgTagResponse { }

message MsgSetNumericAttr {
message MsgTagNumeric {
string curator = 1;

repeated SetAttr set_attr = 2;
repeated NumericTagging operations = 2;

message SetAttr {
string attr_id = 1;
message NumericTagging {
string tag_id = 1;

TagTarget target = 2;

// value should be empty delete
// value is the decimal string representation of the numeric value to set.
// If it is empty, the value will be deleted.
// value must be within the range of the attribute's min and max values
// and must not exceed the attribute's precision.
string value = 3;
}
}

message MsgSetNumericAttrResponse {}
message MsgTagNumericResponse { }
37 changes: 37 additions & 0 deletions proto/regen/ecocredit/curation/v1beta1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ package regen.ecocredit.curation.v1beta1;
// TagTarget represents the target of a tag.
message TagTarget {
oneof sum {
// address indicates that this tag targets the address of an account such as a credit class admin
// or a project admin.
string address = 1;

// class_id indicates that this tag targets all the credits within a given class.
string class_id = 2;

Expand All @@ -22,4 +25,38 @@ message AllowedTagTargets {
bool class = 2;
bool project = 3;
bool batch = 4;
}

message TagMeta {
string name = 1;
string description = 2;
AllowedTagTargets allowed_targets = 3;
}

message TagType {
oneof sum {
TagTagType tag = 1;
NumericTagType numeric = 2;
}
}

// TagTagType represents a tag that can either be present or not present.
message TagTagType {}

// NumericTagType represents a tag that can have a numeric value.
message NumericTagType {
// min is the minimum value of the attribute as a decimal string. It is required.
string min = 1;

// max is the maximum value of the attribute as a decimal string. It is required.
string max = 2;

// precision is the number of significant decimal places after the decimal point if it is a positive value.
// For instance 1 indicates that 3.54 would be an invalid value and that 3.5 is the most precise value
// that could be submitted.
// If it is a negative value, it is the number of non-significant digits after the decimal point.
// For instance -1 indicates that 34 would be an invalid value and that 30 is the most precise value
// that could be submitted.
// A value of 0 indicates an integer value.
int32 precision = 3;
}

0 comments on commit 347b33c

Please sign in to comment.