Contract con_gamma_phi_profile_v5
Creator | ae9cfa894495930b8d2f1707ab936325b5c848ace677bb8ba41dfe7dcdb3e3e6 |
Creation Hash | ed235859533ec657b18b7c0eb40b77d7f0f5a0dc17ef55973f91ee34b90cc532 |
Created On | 848 days ago - 12/29/2021, 8:37:57 PM UTC+0 |
Contract Code
1
# con_gamma_phi_profile_v5
2
I = importlib
3
4
owner = Variable()
5
6
metadata = Hash(default_value=None)
7
usernames = Hash(default_value=None)
8
channels = Hash(default_value=None)
9
total_users = Variable()
10
11
actions = Hash()
12
13
S = {
14
'metadata': metadata,
15
'usernames': usernames,
16
'total_users': total_users,
17
'channels': channels,
18
'owner': owner
19
}
20
21
# Policy interface
22
action_interface = [
23
I.Func('interact', args=('payload', 'state', 'caller')),
24
]
25
26
27
@construct
28
def seed():
29
total_users.set(0)
30
owner.set(ctx.caller)
31
32
33
@export
34
def register_action(action: str, contract: str):
35
assert ctx.caller == owner.get(), 'Only owner can call!'
36
assert actions[action] is None, 'Action already registered!'
37
# Attempt to import the contract to make sure it is already submitted
38
p = I.import_module(contract)
39
40
# Assert ownership is election_house and interface is correct
41
assert I.owner_of(p) == ctx.this, \
42
'This contract must control the action contract!'
43
44
assert I.enforce_interface(p, action_interface), \
45
'Action contract does not follow the correct interface!'
46
47
actions[action] = contract
48
49
@export
50
def override_action(action: str, contract: str):
51
assert ctx.caller == owner.get(), 'Only owner can call!'
52
assert actions[action] is not None, 'Action not already registered!'
53
# Attempt to import the contract to make sure it is already submitted
54
p = I.import_module(contract)
55
56
# Assert ownership is election_house and interface is correct
57
assert I.owner_of(p) == ctx.this, \
58
'This contract must control the action contract!'
59
60
assert I.enforce_interface(p, action_interface), \
61
'Action contract does not follow the correct interface!'
62
63
actions[action] = contract
64
65
@export
66
def unregister_action(action: str):
67
assert ctx.caller == owner.get(), 'Only owner can call!'
68
assert actions[action] is not None, 'Action does not exist!'
69
70
actions[action] = None
71
72
@export
73
def interact(action: str, payload: dict):
74
contract = actions[action]
75
assert contract is not None, 'Invalid action!'
76
77
module = I.import_module(contract)
78
79
result = module.interact(payload, S, ctx.caller)
80
return result
81
82
@export
83
def bulk_interact(action: str, payloads: list):
84
for payload in payloads:
85
interact(action, payload)
86
87
88
89
@export
90
def change_ownership(new_owner: str):
91
assert ctx.caller == owner.get(), 'Only the owner can change ownership!'
92
93
owner.set(new_owner)
Byte Code
e30000000000000000000000000600000040000000730a01000065005a0165026400640164028d025a03650464036400640464058d035a05650464036400640664058d035a06650464036400640764058d035a0765026400640864028d025a0865046400640964028d025a0965056506650865076503640a9c055a0a65016a0b640b6422640f8d0267015a0c6410641184005a0d650e64008301650f650f64129c0264136414840483015a10650e64008301650f650f64129c0264156416840483015a11650e64008301650f64179c0164186419840483015a12650e64008301650f6513641a9c02641b640b840483015a14650e64008301650f6515641c9c02641d641e840483015a16650e64008301650f641f9c0164206421840483015a17640353002923da18636f6e5f67616d6d615f7068695f70726f66696c655f7635da056f776e65722902da08636f6e7472616374da046e616d654eda086d657461646174612903da0d64656661756c745f76616c756572030000007204000000da09757365726e616d6573da086368616e6e656c73da0b746f74616c5f7573657273da07616374696f6e73290572050000007207000000720900000072080000007202000000da08696e746572616374da077061796c6f6164da057374617465da0663616c6c65722901da0461726773630000000000000000000000000200000043000000731a00000074006a0164018301010074026a0174036a04830101006400530029024ee9000000002905da0d5f5f746f74616c5f7573657273da03736574da075f5f6f776e6572da03637478720e000000a90072150000007215000000da00da045f5f5f5f11000000730400000000010a0172170000002902da06616374696f6e7203000000630200000000000000030000000300000043000000736c00000074006a0174026a0383006b027316740464018301820174057c00190064006b08732a740464028301820174066a077c0183017d0274066a087c02830174006a096b02734c740464038301820174066a0a7c02740b8302736074046404830182017c0174057c003c006400530029054e7a144f6e6c79206f776e65722063616e2063616c6c217a1a416374696f6e20616c72656164792072656769737465726564217a2f5468697320636f6e7472616374206d75737420636f6e74726f6c2074686520616374696f6e20636f6e7472616374217a36416374696f6e20636f6e747261637420646f6573206e6f7420666f6c6c6f772074686520636f727265637420696e7465726661636521290c7214000000720e0000007213000000da03676574da0e417373657274696f6e4572726f72da095f5f616374696f6e73da0149da0d696d706f72745f6d6f64756c65da086f776e65725f6f66da0474686973da11656e666f7263655f696e74657266616365da10616374696f6e5f696e74657266616365290372180000007203000000da0170721500000072150000007216000000da0f72656769737465725f616374696f6e1600000073100000000002160114010a01080110010e0106017223000000630200000000000000030000000300000043000000736c00000074006a0174026a0383006b027316740464018301820174057c00190064006b09732a740464028301820174066a077c0183017d0274066a087c02830174006a096b02734c740464038301820174066a0a7c02740b8302736074046404830182017c0174057c003c006400530029054e7a144f6e6c79206f776e65722063616e2063616c6c217a1e416374696f6e206e6f7420616c72656164792072656769737465726564217a2f5468697320636f6e7472616374206d75737420636f6e74726f6c2074686520616374696f6e20636f6e7472616374217a36416374696f6e20636f6e747261637420646f6573206e6f7420666f6c6c6f772074686520636f727265637420696e7465726661636521290c7214000000720e00000072130000007219000000721a000000721b000000721c000000721d000000721e000000721f000000722000000072210000002903721800000072030000007222000000721500000072150000007216000000da0f6f766572726964655f616374696f6e2200000073100000000002160114010a01080110010e010601722400000029017218000000630100000000000000010000000300000043000000733600000074006a0174026a0383006b027316740464018301820174057c00190064006b09732a7404640283018201640074057c003c006400530029034e7a144f6e6c79206f776e65722063616e2063616c6c217a16416374696f6e20646f6573206e6f742065786973742129067214000000720e00000072130000007219000000721a000000721b00000029017218000000721500000072150000007216000000da11756e72656769737465725f616374696f6e2e0000007306000000000216011401722500000029027218000000720c000000630200000000000000050000000400000043000000733600000074007c0019007d027c0264006b097318740164018301820174026a037c0283017d037c036a047c01740574066a0783037d047c04530029024e7a0f496e76616c696420616374696f6e212908721b000000721a000000721c000000721d000000720b000000da01537214000000720e00000029057218000000720c0000007203000000da066d6f64756c65da06726573756c74721500000072150000007216000000720b00000035000000730a0000000002080110010a01100129027218000000da087061796c6f616473630200000000000000030000000400000043000000731c00000078167c0144005d0e7d0274007c007c0283020100710657006400530029014e2901720b000000290372180000007229000000720c000000721500000072150000007216000000da0d62756c6b5f696e7465726163743e000000730400000000020a01722a0000002901da096e65775f6f776e6572630100000000000000010000000200000043000000732400000074006a0174026a0383006b027316740464018301820174026a057c00830101006400530029024e7a244f6e6c7920746865206f776e65722063616e206368616e6765206f776e6572736869702129067214000000720e00000072130000007219000000721a00000072120000002901722b000000721500000072150000007216000000da106368616e67655f6f776e65727368697044000000730400000000021601722c0000002903720c000000720d000000720e0000002918da09696d706f72746c6962721c000000da085661726961626c657213000000da0448617368da0a5f5f6d65746164617461da0b5f5f757365726e616d6573da0a5f5f6368616e6e656c737211000000721b0000007226000000da0446756e6372210000007217000000da085f5f6578706f7274da03737472722300000072240000007225000000da0464696374720b000000da046c697374722a000000722c0000007215000000721500000072150000007216000000da083c6d6f64756c653e01000000733400000004010c01060108010601080106010801040108010c0104010c01100308050601120b0601120b0601100606011208060112050601