Skip to content

Commit

Permalink
Add support for aggregate stats (cumulative | average)
Browse files Browse the repository at this point in the history
  • Loading branch information
ismellike committed Sep 10, 2024
1 parent 0cc209c commit 74d9a7a
Show file tree
Hide file tree
Showing 9 changed files with 1,456 additions and 163 deletions.
240 changes: 222 additions & 18 deletions contracts/arena-league-module/schema/arena-league-module.json
Original file line number Diff line number Diff line change
Expand Up @@ -391,23 +391,51 @@
{
"type": "object",
"required": [
"update_stats"
"input_stats"
],
"properties": {
"update_stats": {
"input_stats": {
"type": "object",
"required": [
"competition_id",
"updates"
"stats"
],
"properties": {
"competition_id": {
"$ref": "#/definitions/Uint128"
},
"updates": {
"stats": {
"type": "array",
"items": {
"$ref": "#/definitions/MemberStatUpdate"
"$ref": "#/definitions/MemberStatsMsg"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"remove_stats"
],
"properties": {
"remove_stats": {
"type": "object",
"required": [
"competition_id",
"stats"
],
"properties": {
"competition_id": {
"$ref": "#/definitions/Uint128"
},
"stats": {
"type": "array",
"items": {
"$ref": "#/definitions/MemberStatsRemoveMsg"
}
}
},
Expand Down Expand Up @@ -959,7 +987,7 @@
},
"additionalProperties": false
},
"MemberStatUpdate": {
"MemberStatsMsg": {
"type": "object",
"required": [
"addr",
Expand All @@ -978,6 +1006,25 @@
},
"additionalProperties": false
},
"MemberStatsRemoveMsg": {
"type": "object",
"required": [
"addr",
"stats"
],
"properties": {
"addr": {
"type": "string"
},
"stats": {
"type": "array",
"items": {
"$ref": "#/definitions/StatsRemoveMsg"
}
}
},
"additionalProperties": false
},
"MigrateMsg": {
"oneOf": [
{
Expand Down Expand Up @@ -1011,6 +1058,13 @@
},
"additionalProperties": false
},
"StatAggregationType": {
"type": "string",
"enum": [
"average",
"cumulative"
]
},
"StatMsg": {
"type": "object",
"required": [
Expand All @@ -1035,6 +1089,16 @@
"value_type"
],
"properties": {
"aggregation_type": {
"anyOf": [
{
"$ref": "#/definitions/StatAggregationType"
},
{
"type": "null"
}
]
},
"is_beneficial": {
"type": "boolean"
},
Expand Down Expand Up @@ -1084,11 +1148,11 @@
{
"type": "object",
"required": [
"int"
"uint"
],
"properties": {
"int": {
"$ref": "#/definitions/Int128"
"uint": {
"$ref": "#/definitions/Uint128"
}
},
"additionalProperties": false
Expand All @@ -1100,9 +1164,27 @@
"enum": [
"bool",
"decimal",
"int"
"uint"
]
},
"StatsRemoveMsg": {
"type": "object",
"required": [
"height",
"name"
],
"properties": {
"height": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"name": {
"type": "string"
}
},
"additionalProperties": false
},
"Timestamp": {
"description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```",
"allOf": [
Expand Down Expand Up @@ -1368,6 +1450,43 @@
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"stat"
],
"properties": {
"stat": {
"type": "object",
"required": [
"addr",
"competition_id",
"stat_name"
],
"properties": {
"addr": {
"type": "string"
},
"competition_id": {
"$ref": "#/definitions/Uint128"
},
"height": {
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
"stat_name": {
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Query the contract's ownership information",
"type": "object",
Expand Down Expand Up @@ -2663,6 +2782,74 @@
}
}
},
"stat": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "StatMsg",
"type": "object",
"required": [
"name",
"value"
],
"properties": {
"name": {
"type": "string"
},
"value": {
"$ref": "#/definitions/StatValue"
}
},
"additionalProperties": false,
"definitions": {
"Decimal": {
"description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)",
"type": "string"
},
"StatValue": {
"oneOf": [
{
"type": "object",
"required": [
"bool"
],
"properties": {
"bool": {
"type": "boolean"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"decimal"
],
"properties": {
"decimal": {
"$ref": "#/definitions/Decimal"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"uint"
],
"properties": {
"uint": {
"$ref": "#/definitions/Uint128"
}
},
"additionalProperties": false
}
]
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"type": "string"
}
}
},
"stat_types": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Nullable_Array_of_StatType",
Expand All @@ -2674,6 +2861,13 @@
"$ref": "#/definitions/StatType"
},
"definitions": {
"StatAggregationType": {
"type": "string",
"enum": [
"average",
"cumulative"
]
},
"StatType": {
"type": "object",
"required": [
Expand All @@ -2682,6 +2876,16 @@
"value_type"
],
"properties": {
"aggregation_type": {
"anyOf": [
{
"$ref": "#/definitions/StatAggregationType"
},
{
"type": "null"
}
]
},
"is_beneficial": {
"type": "boolean"
},
Expand All @@ -2707,7 +2911,7 @@
"enum": [
"bool",
"decimal",
"int"
"uint"
]
}
}
Expand All @@ -2727,10 +2931,6 @@
"description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)",
"type": "string"
},
"Int128": {
"description": "An implementation of i128 that is using strings for JSON encoding/decoding, such that the full i128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `i128` to get the value out:\n\n``` # use cosmwasm_std::Int128; let a = Int128::from(258i128); assert_eq!(a.i128(), 258); ```",
"type": "string"
},
"StatMsg": {
"type": "object",
"required": [
Expand Down Expand Up @@ -2776,16 +2976,20 @@
{
"type": "object",
"required": [
"int"
"uint"
],
"properties": {
"int": {
"$ref": "#/definitions/Int128"
"uint": {
"$ref": "#/definitions/Uint128"
}
},
"additionalProperties": false
}
]
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"type": "string"
}
}
}
Expand Down
Loading

0 comments on commit 74d9a7a

Please sign in to comment.