{
"id": "289",
"prompt": "Identity-first onboarding: while viewer_has_identity() is 0 the ONLY thing on screen is a CREATE IDENTITY button wired to request_identity() - flash a WELCOME banner when it returns 1. Once a wallet exists, swap to the real app: a subscribe/unsubscribe toggle that reflects is_subscribed() plus the live subscriber_count(). Edge-detect every tap with the previous pointer state in a slot.",
"solution_rl": "fn frame(t: i32) {\n host::display::clear(0x0d1014);\n let has: i32 = host::agent::viewer_has_identity();\n let down: i32 = host::display::pointer_down();\n let prev: i32 = host::display::state_get(0);\n host::display::state_set(0, down);\n let mut click: i32 = 0;\n if down == 1 && prev == 0 {\n click = 1;\n }\n\n if has == 0 {\n host::display::draw_string(110, 120, \"THIS APP NEEDS\", 0x8899aa, 2);\n host::display::draw_string(122, 150, \"AN IDENTITY\", 0x8899aa, 2);\n host::display::fill_rect(106, 220, 300, 90, 0xdddddd);\n host::display::draw_string(126, 252, \"CREATE IDENTITY\", 0x000000, 2);\n if click == 1 {\n let px: i32 = host::display::pointer_x();\n let py: i32 = host::display::pointer_y();\n if px >= 106 && px < 406 && py >= 220 && py < 310 {\n let got: i32 = host::agent::request_identity();\n if got == 1 {\n host::display::state_set(1, 60);\n }\n }\n }\n } else {\n let welcome: i32 = host::display::state_get(1);\n if welcome > 0 {\n host::display::draw_string(160, 60, \"WELCOME IN\", 0x22bb44, 2);\n host::display::state_set(1, welcome - 1);\n }\n let subbed: i32 = host::agent::is_subscribed();\n let mut col: i32 = 0x222a33;\n if subbed == 1 {\n col = 0x1a5c2a;\n }\n host::display::fill_rect(106, 180, 300, 90, col);\n if subbed == 1 {\n host::display::draw_string(150, 212, \"SUBSCRIBED\", 0x99ffbb, 2);\n } else {\n host::display::draw_string(162, 212, \"SUBSCRIBE\", 0xffffff, 2);\n }\n host::display::draw_string(106, 320, \"FEED MEMBERS\", 0x556677, 1);\n host::display::draw_number(220, 314, host::agent::subscriber_count(), 0xffffff, 3);\n if click == 1 {\n let px2: i32 = host::display::pointer_x();\n let py2: i32 = host::display::pointer_y();\n if px2 >= 106 && px2 < 406 && py2 >= 180 && py2 < 270 {\n if subbed == 1 {\n host::agent::unsubscribe();\n } else {\n host::agent::subscribe();\n }\n }\n }\n }\n host::display::present();\n}\n",
"tags": [
"agent",
"identity",
"feed"
]
}