Skip to content

Commit 5766b61

Browse files
authored
Merge pull request #1052 from oasisprotocol/ptrus/feature/rofl-app-owner
api/roflmarket_apps: Support filtering by admin
2 parents 593db4e + e32741a commit 5766b61

File tree

9 files changed

+148
-1
lines changed

9 files changed

+148
-1
lines changed

.changelog/1048.feature.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
api/roflmarket_apps: Support filtering by admin

api/spec/v1.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,11 @@ paths:
12691269
- *limit100
12701270
- *offset
12711271
- *runtime
1272+
- in: query
1273+
name: admin
1274+
schema: { allOf: [$ref: '#/components/schemas/EthOrOasisAddress'] }
1275+
examples: { eth: { $ref: '#/components/examples/EthAddress' }, oasis: { $ref: '#/components/examples/StakingAddress' } }
1276+
description: A filter on the admin of the ROFL app.
12721277
- in: query
12731278
name: name
12741279
style: form

storage/client/client.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2488,6 +2488,10 @@ func (c *StorageClient) RuntimeStatus(ctx context.Context, runtime common.Runtim
24882488

24892489
// RuntimeRoflApps returns a list of ROFL apps.
24902490
func (c *StorageClient) RuntimeRoflApps(ctx context.Context, runtime common.Runtime, params apiTypes.GetRuntimeRoflAppsParams, id *string) (*RoflAppList, error) { //nolint:gocyclo
2491+
ocAddrAdmin, err := apiTypes.UnmarshalToOcAddress(params.Admin)
2492+
if err != nil {
2493+
return nil, err
2494+
}
24912495
if params.Name != nil && len(*params.Name) > maxFilterNameFragments {
24922496
return nil, fmt.Errorf("too many names in the name filter: %w", apiCommon.ErrBadRequest)
24932497
}
@@ -2496,7 +2500,7 @@ func (c *StorageClient) RuntimeRoflApps(ctx context.Context, runtime common.Runt
24962500
*params.Limit = 100
24972501
}
24982502

2499-
args := []interface{}{runtime, id}
2503+
args := []interface{}{runtime, id, ocAddrAdmin}
25002504
query := queries.RuntimeRoflApps(params.Name, &args)
25012505
args = append(args, params.Limit, params.Offset)
25022506

storage/client/queries/queries.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,7 @@ func RuntimeRoflApps(rawNames *[]string, args *[]interface{}) string {
13831383
WHERE
13841384
ra.runtime = $1::runtime AND
13851385
($2::text IS NULL OR ra.id = $2::text) AND
1386+
($3::oasis_addr IS NULL OR ra.admin = $3::oasis_addr) AND
13861387
%s AND
13871388
-- Exclude not yet processed apps.
13881389
ra.last_processed_round IS NOT NULL

storage/migrations/19_runtime_rofl.up.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ CREATE INDEX ix_rofl_apps_stale ON chain.rofl_apps (runtime, id) WHERE last_proc
2929
-- On the API endpoint we only ever return apps that have been processed.
3030
CREATE INDEX ix_rofl_apps_processed ON chain.rofl_apps (runtime, id) WHERE last_processed_round IS NOT NULL;
3131
-- CREATE INDEX ix_rofl_apps_metadata_name ON chain.rofl_apps USING GIN (metadata_name gin_trgm_ops); -- Added in 29_runtime_rofl_metadata_name_partial.up.sql.
32+
-- CREATE INDEX ix_rofl_apps_admin ON chain.rofl_apps (runtime, admin); -- Added in 37_rofl_admin_idx.up.sql.
3233

3334
CREATE TABLE chain.rofl_instances
3435
(
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
BEGIN;
2+
3+
CREATE INDEX IF NOT EXISTS ix_rofl_apps_admin ON chain.rofl_apps (runtime, admin);
4+
5+
COMMIT;
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"is_total_count_clipped": false,
3+
"rofl_apps": [
4+
{
5+
"active_instances": [
6+
{
7+
"endorsing_node_id": "7zI/cYuiUTPz61PL9M7f1Q/7b43nG0xk1w6yGde+msQ=",
8+
"expiration_epoch": 44111,
9+
"extra_keys": [
10+
"{\"secp256k1\":\"A6wV1gI3WXkpacOV5gfYYj1ingodg7KWfLFXLDnl8+dk\"}"
11+
],
12+
"rak": "JI4ZKGmq2AEguG2/54i+8X+K21Qlzpi8CNwzSteN4ZA=",
13+
"rek": "9Ky0XhpqXHePykbQHfZmgMQwIxSUdfrx7HjjpyvYKyo="
14+
},
15+
{
16+
"endorsing_node_id": "bOlqho9R3JHP64kJk+SfMxZt5fNkYWf6gdhErWlY60E=",
17+
"expiration_epoch": 44111,
18+
"extra_keys": [
19+
"{\"secp256k1\":\"A/8hOM8jscOcpZLC5u+tBC8gsFEipPj9/bHCzhJPB9ZW\"}"
20+
],
21+
"rak": "UPnsG77rGgUjFXn/uzM0SlVKucVDwSTS5YR8dwfresQ=",
22+
"rek": "qPzW85Lz5+Vyb7Dp0NgX47LSrqfunOgHISxb/PKcaGo="
23+
},
24+
{
25+
"endorsing_entity_id": "hp8sjG2cJPncrEYWZKqisUNiMYzUC/QomhrJwoLQVjc=",
26+
"endorsing_node_id": "5MsgQwijUlpH9+0Hbyors5jwmx7tTmKMA4c9leV3prI=",
27+
"expiration_epoch": 44111,
28+
"extra_keys": [
29+
"{\"secp256k1\":\"ApfMZa/cDYWCOjnktY05z7aYogI7n80b0tsC+PbDltnc\"}"
30+
],
31+
"rak": "TycKYTka2ppTlqp2aUI8bI0Eu+sir3jCh+mY0GGn2tg=",
32+
"rek": "xm87elvMdu1+dYlZBLE4Tw4qiwODnT5ZOKmECYH8WHg="
33+
}
34+
],
35+
"admin": "oasis1qpwaggvmhwq5uk40clase3knt655nn2tdy39nz2f",
36+
"date_created": "2025-05-06T15:54:15Z",
37+
"id": "rofl1qrqw99h0f7az3hwt2cl7yeew3wtz0fxunu7luyfg",
38+
"last_activity": "2025-05-06T16:09:22Z",
39+
"metadata": {
40+
"net.oasis.rofl.name": "rofl-scheduler",
41+
"net.oasis.rofl.repository": "https://github.com/oasisprotocol/oasis-sdk",
42+
"net.oasis.rofl.version": "0.1.0"
43+
},
44+
"num_active_instances": 3,
45+
"policy": {
46+
"enclaves": [
47+
"2OKs276ykwRIRetgtYGQJMOyfI5FyZ861qMvZGgHVikAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
48+
"gjsdGO/HZda3cpvIVp7se/EAUHf80TCKb60IEJ+ba4EAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
49+
"PE2TSgy9aMfAmxGIDgMpbjr9ejk2evb2wdzaBEkA4TMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
50+
"+3Sv/xqzc171KyieVot07v8H7lCGpSqIuaDelVmTE8IAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="
51+
],
52+
"endorsements": [
53+
{
54+
"any": {}
55+
}
56+
],
57+
"fees": 2,
58+
"max_expiration": 3,
59+
"quotes": {
60+
"pcs": {
61+
"min_tcb_evaluation_data_number": 18,
62+
"tcb_validity_period": 30,
63+
"tdx": {}
64+
}
65+
}
66+
},
67+
"removed": false,
68+
"secrets": null,
69+
"sek": "2EqhwE5KMLSB3Spx3wzrl3Kud0U4Gu4Jty5bWb90/mk=",
70+
"stake": "100000000000000000000"
71+
},
72+
{
73+
"active_instances": [
74+
{
75+
"endorsing_node_id": "7zI/cYuiUTPz61PL9M7f1Q/7b43nG0xk1w6yGde+msQ=",
76+
"expiration_epoch": 44111,
77+
"extra_keys": [
78+
"{\"secp256k1\":\"Ao3qmFS3aE6iQ122cYON8m1kF0tL6HIUijgeUCGu1GZN\"}"
79+
],
80+
"rak": "2ykEN3K2N0hgC5EFkdNiqDX4TLi+Aul3PYHUJX041SE=",
81+
"rek": "Z5nJSrh270+0CqUUcjBiSUqEEoGJP2BsyfCzxDCAMWE="
82+
}
83+
],
84+
"admin": "oasis1qpwaggvmhwq5uk40clase3knt655nn2tdy39nz2f",
85+
"date_created": "2025-05-06T15:54:21Z",
86+
"id": "rofl1qp55evqls4qg6cjw5fnlv4al9ptc0fsakvxvd9uw",
87+
"last_activity": "2025-05-06T16:21:51Z",
88+
"metadata": {
89+
"net.oasis.rofl.author": "Jernej Kos <jernej@kos.mx>",
90+
"net.oasis.rofl.license": "Apache-2.0",
91+
"net.oasis.rofl.name": "demo-rofl",
92+
"net.oasis.rofl.repository": "https://github.com/oasisprotocol/demo-rofl",
93+
"net.oasis.rofl.version": "0.1.1"
94+
},
95+
"num_active_instances": 1,
96+
"policy": {
97+
"enclaves": [
98+
"qc98ULKN37r8sZNJlSvM2klZBBAH1sCu09w07HNagH4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
99+
"HQADK7bsA9jKv+V7eS9OB+smnN6Vf6Wp/zUeIlyZW18AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="
100+
],
101+
"endorsements": [
102+
{
103+
"any": {}
104+
}
105+
],
106+
"fees": 2,
107+
"max_expiration": 3,
108+
"quotes": {
109+
"pcs": {
110+
"min_tcb_evaluation_data_number": 17,
111+
"tcb_validity_period": 30,
112+
"tdx": {}
113+
}
114+
}
115+
},
116+
"removed": false,
117+
"secrets": null,
118+
"sek": "438B4/HJ6nmyzg0v50UxvRiBLn9ZJRa8uzDjpsD18Dw=",
119+
"stake": "10000000000000000000000"
120+
}
121+
],
122+
"total_count": 2
123+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
HTTP/1.1 200 OK
2+
Content-Type: application/json
3+
Vary: Origin
4+
Date: UNINTERESTING
5+
Transfer-Encoding: chunked
6+

tests/e2e_regression/eden_testnet_2025/test_cases.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ testCases=(
3333
'sapphire_account_with_rose /v1/sapphire/accounts/0xeDA395666E56dd9E2Ef3Bdc76eee373b738640DD'
3434
'sapphire_account_with_evm_token /v1/sapphire/accounts/0xeDA395666E56dd9E2Ef3Bdc76eee373b738640DD'
3535
'sapphire_rofl_app /v1/sapphire/rofl_apps/rofl1qp55evqls4qg6cjw5fnlv4al9ptc0fsakvxvd9uw'
36+
'sapphire_rofl_app_by_admin /v1/sapphire/rofl_apps?admin=oasis1qpwaggvmhwq5uk40clase3knt655nn2tdy39nz2f'
3637
'sapphire_rofl_app_by_name /v1/sapphire/rofl_apps?name=demo-rofl'
3738
'sapphire_rofl_app_by_multiple_names /v1/sapphire/rofl_apps?name=chatbot,demo'
3839
'sapphire_rofl_app_instances /v1/sapphire/rofl_apps/rofl1qp55evqls4qg6cjw5fnlv4al9ptc0fsakvxvd9uw/instances'

0 commit comments

Comments
 (0)