SC CODE: Function InitializePrivate() Uint64
10 STORE("bid_index", 0)
20 STORE("owner", SIGNER())
30 RETURN 0
End Function
Function CreateBid(dero_amt Uint64, pls_amt Uint64, from_to String, pls_bid_address String) Uint64
10 dim bid_index as Uint64
20 LET bid_index = LOAD("bid_index")
21 IF EXISTS("ban" + ADDRESS_STRING(SIGNER())) == 0 THEN GOTO 23
22 RETURN 1
23 IF from_to == "pls-dero" THEN GOTO 31
24 IF from_to == "dero-pls" THEN GOTO 26
25 RETURN 1
26 IF pls_bid_address != "" THEN GOTO 30
27 RETURN 1
30 STORE("pls_bid_address" + bid_index, pls_bid_address)
31 STORE("dero_bid_address" + bid_index, ADDRESS_STRING(SIGNER()))
32 STORE("deroamt" + bid_index, dero_amt)
33 STORE("plsamt" + bid_index, pls_amt)
34 STORE("from_to" + bid_index, from_to)
35 STORE("bid_index",(bid_index + 1))
60 RETURN 0
End Function
Function RemoveBid(bid_id String) Uint64
10 IF LOAD("dero_bid_address" + bid_id) == ADDRESS_STRING(SIGNER()) THEN GOTO 21
20 RETURN 1
21 IF EXISTS("accepted_by_dero" + bid_id) == 0 THEN GOTO 30
22 RETURN 1
30 DELETE("dero_bid_address" + bid_id)
31 DELETE("pls_bid_address" + bid_id)
32 DELETE("deroamt" + bid_id)
33 DELETE("plsamt" + bid_id)
34 DELETE("from_to" + bid_id)
60 RETURN 0
End Function
Function AcceptBid(bid_id String, accepted_by_pls String) Uint64
10 IF EXISTS("accepted_by_dero" + bid_id) == 0 THEN GOTO 21
20 RETURN 1
21 IF accepted_by_pls != "" THEN GOTO 23
22 RETURN 1
23 IF EXISTS("ban" + ADDRESS_STRING(SIGNER())) == 0 THEN GOTO 25
24 RETURN 1
25 STORE("accepted_by_dero"+bid_id,ADDRESS_STRING(SIGNER()))
26 STORE("accepted_by_pls"+bid_id, accepted_by_pls)
60 RETURN 0
End Function
Function AddDEROSCID(bid_id String, scid String) Uint64
10 IF EXISTS("dscid" + bid_id) == 0 THEN GOTO 21
11 RETURN 1
21 IF LOAD("from_to" + bid_id) == "pls-dero" THEN GOTO 30
22 IF LOAD("from_to" + bid_id) == "dero-pls" THEN GOTO 40
30 IF LOAD("accepted_by_dero" + bid_id) == ADDRESS_STRING(SIGNER()) THEN GOTO 50
31 RETURN 1
40 IF LOAD("dero_bid_address" + bid_id) == ADDRESS_STRING(SIGNER()) THEN GOTO 50
41 RETURN 1
50 STORE("dscid"+bid_id, scid)
60 RETURN 0
End Function
Function AddPLSSCID(bid_id String, scid String) Uint64
10 IF EXISTS("pscid" + bid_id) == 0 THEN GOTO 21
11 RETURN 1
21 IF LOAD("from_to" + bid_id) == "pls-dero" THEN GOTO 30
22 IF LOAD("from_to" + bid_id) == "dero-pls" THEN GOTO 40
30 IF LOAD("dero_bid_address" + bid_id) == ADDRESS_STRING(SIGNER()) THEN GOTO 50
31 RETURN 1
40 IF LOAD("accepted_by_dero" + bid_id) == ADDRESS_STRING(SIGNER()) THEN GOTO 50
41 RETURN 1
50 STORE("pscid"+bid_id, scid)
60 RETURN 0
End Function
Function FindAddress(address_w_id String) String
10 dim bid_index,count as Uint64
11 dim t1,t2,address,derived_id as String
16 LET derived_id = SUBSTR(address_w_id,66, (STRLEN(address_w_id)-66))
17 LET count = ATOI(derived_id)
18 IF count == 0 THEN GOTO 60
20 LET t1 = "dero_bid_address" + derived_id
21 LET t2 = "accepted_by_dero" + derived_id
30 IF EXISTS(t1) == 1 THEN GOTO 40
31 IF EXISTS(t2) == 1 THEN GOTO 45
32 LET address = SUBSTR(address_w_id,0,66)
33 RETURN FindAddress(address + (count -1))
40 LET address = SUBSTR(address_w_id,0,66)
41 GOTO 50
45 LET address = SUBSTR(address_w_id,0,66)
46 GOTO 54
50 IF LOAD(t1) == address THEN GOTO 70
52 IF EXISTS(t2) == 1 THEN GOTO 54
53 RETURN FindAddress(address + (count -1))
54 IF LOAD(t2) == address THEN GOTO 70
55 RETURN FindAddress(address + (count -1))
60 RETURN "1"
70 RETURN "0"
End Function
Function AddBan(value Uint64, banned String) Uint64
1 dim address_w_id,found as String
2 dim index as Uint64
3 IF banned == ADDRESS_STRING(SIGNER()) THEN GOTO 61
4 LET index = LOAD("bid_index")
10 IF value < 325 THEN GOTO 25
20 IF IS_ADDRESS_VALID(ADDRESS_RAW(banned)) THEN GOTO 30
25 RETURN 1
30 IF EXISTS("ban" + banned) == 1 THEN GOTO 61
31 IF EXISTS("ban" + ADDRESS_STRING(SIGNER())) THEN GOTO 61
32 LET address_w_id = banned + index
33 LET found = FindAddress(address_w_id)
36 IF found == "0" THEN GOTO 40
39 RETURN 1
40 LET address_w_id = ADDRESS_STRING(SIGNER()) + ITOA(index)
43 LET found = FindAddress(address_w_id)
44 IF found == "0" THEN GOTO 50
45 RETURN 1
50 STORE("ban" + banned, ITOA(value))
60 RETURN 0
61 RETURN 1
End Function
Function RemoveBan(value Uint64, banned String) Uint64
20 IF ITOA(value) == LOAD("ban" + banned) THEN GOTO 30
21 RETURN 1
30 DELETE("ban" + banned)
60 RETURN 0
End Function
Function CashOut(amount Uint64) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 SEND_DERO_TO_ADDRESS(SIGNER(), amount)
40 RETURN 0
End Function |
SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'Function InitializePrivate() Uint64
10 STORE("bid_index", 0)
20 STORE("owner", SIGNER())
30 RETURN 0
End Function
Function CreateBid(dero_amt Uint64, pls_amt Uint64, from_to String, pls_bid_address String) Uint64
10 dim bid_index as Uint64
20 LET bid_index = LOAD("bid_index")
21 IF EXISTS("ban" + ADDRESS_STRING(SIGNER())) == 0 THEN GOTO 23
22 RETURN 1
23 IF from_to == "pls-dero" THEN GOTO 31
24 IF from_to == "dero-pls" THEN GOTO 26
25 RETURN 1
26 IF pls_bid_address != "" THEN GOTO 30
27 RETURN 1
30 STORE("pls_bid_address" + bid_index, pls_bid_address)
31 STORE("dero_bid_address" + bid_index, ADDRESS_STRING(SIGNER()))
32 STORE("deroamt" + bid_index, dero_amt)
33 STORE("plsamt" + bid_index, pls_amt)
34 STORE("from_to" + bid_index, from_to)
35 STORE("bid_index",(bid_index + 1))
60 RETURN 0
End Function
Function RemoveBid(bid_id String) Uint64
10 IF LOAD("dero_bid_address" + bid_id) == ADDRESS_STRING(SIGNER()) THEN GOTO 21
20 RETURN 1
21 IF EXISTS("accepted_by_dero" + bid_id) == 0 THEN GOTO 30
22 RETURN 1
30 DELETE("dero_bid_address" + bid_id)
31 DELETE("pls_bid_address" + bid_id)
32 DELETE("deroamt" + bid_id)
33 DELETE("plsamt" + bid_id)
34 DELETE("from_to" + bid_id)
60 RETURN 0
End Function
Function AcceptBid(bid_id String, accepted_by_pls String) Uint64
10 IF EXISTS("accepted_by_dero" + bid_id) == 0 THEN GOTO 21
20 RETURN 1
21 IF accepted_by_pls != "" THEN GOTO 23
22 RETURN 1
23 IF EXISTS("ban" + ADDRESS_STRING(SIGNER())) == 0 THEN GOTO 25
24 RETURN 1
25 STORE("accepted_by_dero"+bid_id,ADDRESS_STRING(SIGNER()))
26 STORE("accepted_by_pls"+bid_id, accepted_by_pls)
60 RETURN 0
End Function
Function AddDEROSCID(bid_id String, scid String) Uint64
10 IF EXISTS("dscid" + bid_id) == 0 THEN GOTO 21
11 RETURN 1
21 IF LOAD("from_to" + bid_id) == "pls-dero" THEN GOTO 30
22 IF LOAD("from_to" + bid_id) == "dero-pls" THEN GOTO 40
30 IF LOAD("accepted_by_dero" + bid_id) == ADDRESS_STRING(SIGNER()) THEN GOTO 50
31 RETURN 1
40 IF LOAD("dero_bid_address" + bid_id) == ADDRESS_STRING(SIGNER()) THEN GOTO 50
41 RETURN 1
50 STORE("dscid"+bid_id, scid)
60 RETURN 0
End Function
Function AddPLSSCID(bid_id String, scid String) Uint64
10 IF EXISTS("pscid" + bid_id) == 0 THEN GOTO 21
11 RETURN 1
21 IF LOAD("from_to" + bid_id) == "pls-dero" THEN GOTO 30
22 IF LOAD("from_to" + bid_id) == "dero-pls" THEN GOTO 40
30 IF LOAD("dero_bid_address" + bid_id) == ADDRESS_STRING(SIGNER()) THEN GOTO 50
31 RETURN 1
40 IF LOAD("accepted_by_dero" + bid_id) == ADDRESS_STRING(SIGNER()) THEN GOTO 50
41 RETURN 1
50 STORE("pscid"+bid_id, scid)
60 RETURN 0
End Function
Function FindAddress(address_w_id String) String
10 dim bid_index,count as Uint64
11 dim t1,t2,address,derived_id as String
16 LET derived_id = SUBSTR(address_w_id,66, (STRLEN(address_w_id)-66))
17 LET count = ATOI(derived_id)
18 IF count == 0 THEN GOTO 60
20 LET t1 = "dero_bid_address" + derived_id
21 LET t2 = "accepted_by_dero" + derived_id
30 IF EXISTS(t1) == 1 THEN GOTO 40
31 IF EXISTS(t2) == 1 THEN GOTO 45
32 LET address = SUBSTR(address_w_id,0,66)
33 RETURN FindAddress(address + (count -1))
40 LET address = SUBSTR(address_w_id,0,66)
41 GOTO 50
45 LET address = SUBSTR(address_w_id,0,66)
46 GOTO 54
50 IF LOAD(t1) == address THEN GOTO 70
52 IF EXISTS(t2) == 1 THEN GOTO 54
53 RETURN FindAddress(address + (count -1))
54 IF LOAD(t2) == address THEN GOTO 70
55 RETURN FindAddress(address + (count -1))
60 RETURN "1"
70 RETURN "0"
End Function
Function AddBan(value Uint64, banned String) Uint64
1 dim address_w_id,found as String
2 dim index as Uint64
3 IF banned == ADDRESS_STRING(SIGNER()) THEN GOTO 61
4 LET index = LOAD("bid_index")
10 IF value < 325 THEN GOTO 25
20 IF IS_ADDRESS_VALID(ADDRESS_RAW(banned)) THEN GOTO 30
25 RETURN 1
30 IF EXISTS("ban" + banned) == 1 THEN GOTO 61
31 IF EXISTS("ban" + ADDRESS_STRING(SIGNER())) THEN GOTO 61
32 LET address_w_id = banned + index
33 LET found = FindAddress(address_w_id)
36 IF found == "0" THEN GOTO 40
39 RETURN 1
40 LET address_w_id = ADDRESS_STRING(SIGNER()) + ITOA(index)
43 LET found = FindAddress(address_w_id)
44 IF found == "0" THEN GOTO 50
45 RETURN 1
50 STORE("ban" + banned, ITOA(value))
60 RETURN 0
61 RETURN 1
End Function
Function RemoveBan(value Uint64, banned String) Uint64
20 IF ITOA(value) == LOAD("ban" + banned) THEN GOTO 30
21 RETURN 1
30 DELETE("ban" + banned)
60 RETURN 0
End Function
Function CashOut(amount Uint64) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 SEND_DERO_TO_ADDRESS(SIGNER(), amount)
40 RETURN 0
End Function'] |