SC CODE: /* CipherSamizdat Registry - curated catalogue.
owner : manages admins + categories, removes volumes, edits payout,
adds volumes, links volumes into books (series).
admin : may ONLY add volumes (with their metadata + payout + series).
No fee to post.
A registered SCID points to a TELA-DOC (the text, HTML). To LINK several
volumes of one book, give them the same "series" name and an ordered
"part" number; the UI groups them into one book with a contents list.
Standalone texts use series="" (and part="").
Per volume N: scid:N title:N author:N created:N cat:N pay:N (EPOCH payout)
ser:N (series/book name) prt:N (part order) by:N h:N. ctg:<name> categories.
idx:<scid> dedup. */
Function Initialize() Uint64
10 STORE("owner", SIGNER())
20 STORE("count", 0)
30 RETURN 0
End Function
Function AddAdmin(address String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("adm:" + ADDRESS_RAW(address), 1)
40 RETURN 0
End Function
Function RemoveAdmin(address String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 DELETE("adm:" + ADDRESS_RAW(address))
40 RETURN 0
End Function
Function AddCategory(name String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 IF name == "" THEN GOTO 60
40 STORE("ctg:" + name, 1)
50 RETURN 0
60 RETURN 1
End Function
Function RemoveCategory(name String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 DELETE("ctg:" + name)
40 RETURN 0
End Function
/* owner OR admin. category must exist (or be ""). payout is dero1... (or "").
series is the book name (or "" for a standalone text); part is its order
number as a string (or ""). Re-adding an existing SCID is a no-op. */
Function AddVolume(scid String, title String, author String, created String, category String, payout String, series String, part String) Uint64
10 DIM n as Uint64
20 IF LOAD("owner") == SIGNER() THEN GOTO 50
30 IF EXISTS("adm:" + SIGNER()) THEN GOTO 50
40 RETURN 1
50 IF EXISTS("idx:" + scid) THEN GOTO 200
60 IF category == "" THEN GOTO 90
70 IF EXISTS("ctg:" + category) THEN GOTO 90
80 RETURN 1
90 LET n = LOAD("count")
100 STORE("scid:" + n, scid)
110 STORE("title:" + n, title)
120 STORE("author:" + n, author)
130 STORE("created:" + n, created)
140 STORE("cat:" + n, category)
150 STORE("pay:" + n, payout)
155 STORE("ser:" + n, series)
157 STORE("prt:" + n, part)
160 STORE("by:" + n, SIGNER())
165 STORE("h:" + n, BLOCK_HEIGHT())
170 STORE("idx:" + scid, n)
175 STORE("count", n + 1)
200 RETURN 0
End Function
/* owner only - edit the payout address without touching the (immutable) text */
Function SetPayout(scid String, payout String) Uint64
10 DIM n as Uint64
20 IF LOAD("owner") == SIGNER() THEN GOTO 40
30 RETURN 1
40 IF EXISTS("idx:" + scid) THEN GOTO 60
50 RETURN 1
60 LET n = LOAD("idx:" + scid)
70 STORE("pay:" + n, payout)
80 RETURN 0
End Function
/* owner only - link a volume to a book: set its series name + part order */
Function SetSeries(scid String, series String, part String) Uint64
10 DIM n as Uint64
20 IF LOAD("owner") == SIGNER() THEN GOTO 40
30 RETURN 1
40 IF EXISTS("idx:" + scid) THEN GOTO 60
50 RETURN 1
60 LET n = LOAD("idx:" + scid)
70 STORE("ser:" + n, series)
80 STORE("prt:" + n, part)
90 RETURN 0
End Function
/* owner only */
Function RemoveVolume(scid String) Uint64
10 DIM n as Uint64
20 IF LOAD("owner") == SIGNER() THEN GOTO 40
30 RETURN 1
40 IF EXISTS("idx:" + scid) THEN GOTO 60
50 RETURN 1
60 LET n = LOAD("idx:" + scid)
70 DELETE("scid:" + n)
80 DELETE("title:" + n)
90 DELETE("author:" + n)
100 DELETE("created:" + n)
110 DELETE("cat:" + n)
120 DELETE("pay:" + n)
125 DELETE("ser:" + n)
127 DELETE("prt:" + n)
130 DELETE("by:" + n)
140 DELETE("h:" + n)
150 DELETE("idx:" + scid)
160 RETURN 0
End Function
Function TransferOwnership(newowner String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("tmpowner", ADDRESS_RAW(newowner))
40 RETURN 0
End Function
Function ClaimOwnership() Uint64
10 IF LOAD("tmpowner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("owner", SIGNER())
40 RETURN 0
End Function
Function UpdateCode(code String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 UPDATE_SC_CODE(code)
40 RETURN 0
End Function
|
| SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'/* CipherSamizdat Registry - curated catalogue.
owner : manages admins + categories, removes volumes, edits payout,
adds volumes, links volumes into books (series).
admin : may ONLY add volumes (with their metadata + payout + series).
No fee to post.
A registered SCID points to a TELA-DOC (the text, HTML). To LINK several
volumes of one book, give them the same "series" name and an ordered
"part" number; the UI groups them into one book with a contents list.
Standalone texts use series="" (and part="").
Per volume N: scid:N title:N author:N created:N cat:N pay:N (EPOCH payout)
ser:N (series/book name) prt:N (part order) by:N h:N. ctg:<name> categories.
idx:<scid> dedup. */
Function Initialize() Uint64
10 STORE("owner", SIGNER())
20 STORE("count", 0)
30 RETURN 0
End Function
Function AddAdmin(address String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("adm:" + ADDRESS_RAW(address), 1)
40 RETURN 0
End Function
Function RemoveAdmin(address String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 DELETE("adm:" + ADDRESS_RAW(address))
40 RETURN 0
End Function
Function AddCategory(name String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 IF name == "" THEN GOTO 60
40 STORE("ctg:" + name, 1)
50 RETURN 0
60 RETURN 1
End Function
Function RemoveCategory(name String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 DELETE("ctg:" + name)
40 RETURN 0
End Function
/* owner OR admin. category must exist (or be ""). payout is dero1... (or "").
series is the book name (or "" for a standalone text); part is its order
number as a string (or ""). Re-adding an existing SCID is a no-op. */
Function AddVolume(scid String, title String, author String, created String, category String, payout String, series String, part String) Uint64
10 DIM n as Uint64
20 IF LOAD("owner") == SIGNER() THEN GOTO 50
30 IF EXISTS("adm:" + SIGNER()) THEN GOTO 50
40 RETURN 1
50 IF EXISTS("idx:" + scid) THEN GOTO 200
60 IF category == "" THEN GOTO 90
70 IF EXISTS("ctg:" + category) THEN GOTO 90
80 RETURN 1
90 LET n = LOAD("count")
100 STORE("scid:" + n, scid)
110 STORE("title:" + n, title)
120 STORE("author:" + n, author)
130 STORE("created:" + n, created)
140 STORE("cat:" + n, category)
150 STORE("pay:" + n, payout)
155 STORE("ser:" + n, series)
157 STORE("prt:" + n, part)
160 STORE("by:" + n, SIGNER())
165 STORE("h:" + n, BLOCK_HEIGHT())
170 STORE("idx:" + scid, n)
175 STORE("count", n + 1)
200 RETURN 0
End Function
/* owner only - edit the payout address without touching the (immutable) text */
Function SetPayout(scid String, payout String) Uint64
10 DIM n as Uint64
20 IF LOAD("owner") == SIGNER() THEN GOTO 40
30 RETURN 1
40 IF EXISTS("idx:" + scid) THEN GOTO 60
50 RETURN 1
60 LET n = LOAD("idx:" + scid)
70 STORE("pay:" + n, payout)
80 RETURN 0
End Function
/* owner only - link a volume to a book: set its series name + part order */
Function SetSeries(scid String, series String, part String) Uint64
10 DIM n as Uint64
20 IF LOAD("owner") == SIGNER() THEN GOTO 40
30 RETURN 1
40 IF EXISTS("idx:" + scid) THEN GOTO 60
50 RETURN 1
60 LET n = LOAD("idx:" + scid)
70 STORE("ser:" + n, series)
80 STORE("prt:" + n, part)
90 RETURN 0
End Function
/* owner only */
Function RemoveVolume(scid String) Uint64
10 DIM n as Uint64
20 IF LOAD("owner") == SIGNER() THEN GOTO 40
30 RETURN 1
40 IF EXISTS("idx:" + scid) THEN GOTO 60
50 RETURN 1
60 LET n = LOAD("idx:" + scid)
70 DELETE("scid:" + n)
80 DELETE("title:" + n)
90 DELETE("author:" + n)
100 DELETE("created:" + n)
110 DELETE("cat:" + n)
120 DELETE("pay:" + n)
125 DELETE("ser:" + n)
127 DELETE("prt:" + n)
130 DELETE("by:" + n)
140 DELETE("h:" + n)
150 DELETE("idx:" + scid)
160 RETURN 0
End Function
Function TransferOwnership(newowner String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("tmpowner", ADDRESS_RAW(newowner))
40 RETURN 0
End Function
Function ClaimOwnership() Uint64
10 IF LOAD("tmpowner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("owner", SIGNER())
40 RETURN 0
End Function
Function UpdateCode(code String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 UPDATE_SC_CODE(code)
40 RETURN 0
End Function
'] |