-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpredicate-v1.json
More file actions
139 lines (139 loc) · 4.78 KB
/
Copy pathpredicate-v1.json
File metadata and controls
139 lines (139 loc) · 4.78 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://sluice.unitynodes.com/schema/predicate-v1.json",
"title": "Sluice Predicate v1",
"description": "Boolean filter applied to every Casper Transfer event on the network. The top level is an \"and\" array of nodes; each node is either a leaf condition ({field, op, value}) or a nested group ({\"and\": [...]} / {\"or\": [...]}). Groups may nest up to 4 levels deep, with 32 leaf conditions total. When the tree evaluates true, Sluice POSTs the full event to the subscription's webhook URL. Reference this schema in your editor for autocompletion: add a top-level \"$schema\": \"https://sluice.unitynodes.com/schema/predicate-v1.json\" to any predicate.json.",
"type": "object",
"required": ["and"],
"additionalProperties": true,
"properties": {
"$schema": {
"type": "string",
"description": "Optional, declare this schema for IDE/editor autocompletion."
},
"and": {
"type": "array",
"minItems": 1,
"maxItems": 32,
"description": "Every node must match (logical AND). A node is a leaf condition or a nested { \"and\": [...] } / { \"or\": [...] } group.",
"items": { "$ref": "#/$defs/node" }
}
},
"$defs": {
"node": {
"description": "A predicate node: a leaf condition, or a nested and/or group.",
"oneOf": [
{ "$ref": "#/$defs/condition" },
{ "$ref": "#/$defs/andGroup" },
{ "$ref": "#/$defs/orGroup" }
]
},
"andGroup": {
"type": "object",
"required": ["and"],
"additionalProperties": false,
"description": "Nested AND group. Every child node must match.",
"properties": {
"and": {
"type": "array",
"minItems": 1,
"maxItems": 32,
"items": { "$ref": "#/$defs/node" }
}
}
},
"orGroup": {
"type": "object",
"required": ["or"],
"additionalProperties": false,
"description": "Nested OR group. At least one child node must match.",
"properties": {
"or": {
"type": "array",
"minItems": 1,
"maxItems": 32,
"items": { "$ref": "#/$defs/node" }
}
}
},
"condition": {
"type": "object",
"required": ["field", "op", "value"],
"additionalProperties": false,
"properties": {
"field": {
"$ref": "#/$defs/field",
"description": "Dot-path into the Casper Transfer event."
},
"op": { "$ref": "#/$defs/operator" },
"value": {
"description": "Right-hand side of the comparison. Strings that parse as integers compare numerically (so motes work as bigints). For 'in' and 'not_in' this must be an array. For 'regex' this is a JS-style pattern.",
"oneOf": [
{ "type": "string" },
{ "type": "number" },
{ "type": "boolean" },
{
"type": "array",
"maxItems": 32,
"items": { "type": ["string", "number"] }
}
]
}
},
"allOf": [
{
"if": { "properties": { "op": { "const": "in" } }, "required": ["op"] },
"then": { "properties": { "value": { "type": "array" } } }
},
{
"if": { "properties": { "op": { "const": "not_in" } }, "required": ["op"] },
"then": { "properties": { "value": { "type": "array" } } }
}
]
},
"operator": {
"type": "string",
"enum": [
"eq", "neq", "gt", "gte", "lt", "lte",
"contains", "starts_with", "ends_with",
"in", "not_in", "regex"
],
"description": "Twelve operators. Numeric ops (gt/gte/lt/lte) work on bigint-strings, useful for motes. String ops (contains/starts_with/ends_with/regex) run on the stringified value. Set ops (in/not_in) require an array value."
},
"field": {
"type": "string",
"minLength": 1,
"examples": [
"amount",
"to_account_hash",
"initiator_account_hash",
"from_purse",
"to_purse",
"deploy_hash",
"block_height",
"timestamp",
"transfer_index"
]
}
},
"examples": [
{
"$schema": "https://sluice.unitynodes.com/schema/predicate-v1.json",
"and": [
{ "field": "amount", "op": "gte", "value": "5000000000000" },
{ "field": "to_account_hash", "op": "eq", "value": "dc725246306b8ebfb6623feca7f777c4e9f52c96691cdccf338b797480787c9c" }
]
},
{
"and": [
{ "field": "amount", "op": "gt", "value": "100000000000" },
{
"or": [
{ "field": "initiator_account_hash", "op": "in", "value": ["aabb…", "ccdd…"] },
{ "field": "to_account_hash", "op": "eq", "value": "eeff…" }
]
}
]
}
]
}