-
Notifications
You must be signed in to change notification settings - Fork 0
/
Veronica v2
40 lines (30 loc) · 1.09 KB
/
Veronica v2
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
# SPDX-License-Identifier: Unlicensed
# Cairo version 0.6.2
from starkware.cairo.common.cairo_builtins import HashBuiltin
from starkware.cairo.common.math import assert_not_zero
from starkware.cairo.common.registers import get_fp_and_pc
from starkware.starknet.common.storage import Storage
from starkware.starknet.services.api.gateway.felt import get_caller_address
from starkware.starknet.services.api.gateway.felt import get_l1_address
@storage_var
func videos(video_id: felt) -> (uploader: felt, video: felt):
pass
@storage_var
func video_counter() -> (counter: felt):
pass
@external
func upload_video(video: felt):
# Get the uploader's address.
let (uploader,) = get_caller_address()
# Get the current video counter.
let (counter,) = video_counter.read()
# Write the new video.
videos.write(counter, uploader, video)
# Increment the video counter.
video_counter.write(counter + 1)
return ()
@view
func get_video(video_id: felt) -> (uploader: felt, video: felt):
# Get the video.
let (uploader, video) = videos.read(video_id)
return (uploader, video)