Contract con_uw_use_orbs


Contract Code

1 import currency
2 import con_uwarriors_lst001
3 I = importlib
4
5 S = Hash(default_value=None)
6 metadata = Hash(default_value=0)
7 balances = Hash(default_value=0)
8 wp = ForeignHash(foreign_contract='con_uwarriors_lst001', foreign_name='balances')
9 orbs = ForeignHash(foreign_contract='con_uw_orbs', foreign_name='S')
10
11 @construct
12 def seed():
13 metadata['operator'] = ctx.caller
14 metadata['counter'] = 5
15
16
17 @export
18 def change_metadata(key: str, value: Any):
19 assert ctx.caller == metadata['operator'], 'Only operator can set metadata!'
20 metadata[key] = value
21
22 @export
23 def change_metadata_float(key: str, value: float):
24 assert ctx.caller == metadata['operator'], 'Only operator can set metadata!'
25 metadata[key] = value
26
27
28 @export
29 def operator_transfer_thing(uid: str, new_owner: str, contract: str, item_contract: str):
30 assert ctx.caller == metadata['operator'], 'Only auction operator can transfer things from contract.'
31 thing_master_contract = I.import_module(contract)
32 thing_master_contract.transfer(uid=uid, new_owner=new_owner, contract=item_contract)
33 S[uid] = False
34
35
36 @export
37 def operator_transfer_currency(amount: float, to: str):
38 assert ctx.caller == metadata['operator'], 'Only auction operator can transfer currency from contract.'
39 con_uwarriors_lst001.transfer_from(amount, metadata['operator'], to)
40
41 @export
42 def open_orbs_box():
43 sender = ctx.caller
44 return sender
45
46
47 @export
48 def consume_orbs(contract: str, item_contract: str, uid: str, character: str):
49 sender = ctx.caller
50 thing_master_owner = I.import_module(item_contract)
51 owner = thing_master_owner.get_owner(uid)
52
53 tipo = orbs[uid, 'meta', 'type']
54
55 assert balances[owner, character, tipo] <= metadata['counter'], 'Not use more orbs'
56
57 thing_master_contract = I.import_module(contract)
58 thing_master_contract.transfer_from(
59 uid=uid,
60 to=ctx.this,
61 main_account=ctx.caller,
62 contract=item_contract)
63
64 balances[owner, character, tipo] += 1
65
66 return tipo
67
68

Byte Code

e3000000000000000000000000060000004000000073fa000000640064016c005a00640064016c015a0165025a03650464016402640364048d035a05650464006402640564048d035a06650464006402640664048d035a076508640764066402640864098d045a096508640a64036402640b64098d045a0a640c640d84005a0b650c64028301650d650e640e9c02640f6410840483015a0f650c64028301650d6510640e9c0264116412840483015a11650c64028301650d650d650d650d64139c0464146415840483015a12650c640283016510650d64169c0264176418840483015a13650c640283016419641a840083015a14650c64028301650d650d650d650d641b9c04641c641d840483015a1564015300291ee9000000004eda0f636f6e5f75775f7573655f6f726273da01532903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086d65746164617461da0862616c616e636573da14636f6e5f7577617272696f72735f6c7374303031da0277702904da10666f726569676e5f636f6e7472616374da0c666f726569676e5f6e616d6572050000007206000000da0b636f6e5f75775f6f726273da046f726273630000000000000000000000000300000043000000731600000074006a01740264013c006402740264033c006400530029044eda086f70657261746f72e905000000da07636f756e7465722903da03637478da0663616c6c6572da0a5f5f6d65746164617461a90072150000007215000000da00da045f5f5f5f0d000000730400000000010a0172170000002902da036b6579da0576616c7565630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e720f0000007a1f4f6e6c79206f70657261746f722063616e20736574206d65746164617461212904721200000072130000007214000000da0e417373657274696f6e4572726f72290272180000007219000000721500000072150000007216000000da0f6368616e67655f6d65746164617461120000007306000000000210010601721b000000630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e720f0000007a1f4f6e6c79206f70657261746f722063616e20736574206d65746164617461212904721200000072130000007214000000721a000000290272180000007219000000721500000072150000007216000000da156368616e67655f6d657461646174615f666c6f6174190000007306000000000210010601721c0000002904da03756964da096e65775f6f776e65727205000000da0d6974656d5f636f6e7472616374630400000000000000050000000500000043000000733c00000074006a017402640119006b027316740364028301820174046a057c0283017d047c046a067c007c017c0364038d030100640474077c003c006400530029054e720f0000007a384f6e6c792061756374696f6e206f70657261746f722063616e207472616e73666572207468696e67732066726f6d20636f6e74726163742e2903721d000000721e0000007205000000462908721200000072130000007214000000721a000000da0149da0d696d706f72745f6d6f64756c65da087472616e73666572da035f5f532905721d000000721e0000007205000000721f000000da157468696e675f6d61737465725f636f6e7472616374721500000072150000007216000000da176f70657261746f725f7472616e736665725f7468696e6720000000730c0000000003100106010a010801080172250000002902da06616d6f756e74da02746f630200000000000000020000000400000043000000732c00000074006a017402640119006b027316740364028301820174046a057c007402640119007c01830301006400530029034e720f0000007a3a4f6e6c792061756374696f6e206f70657261746f722063616e207472616e736665722063757272656e63792066726f6d20636f6e74726163742e2906721200000072130000007214000000721a0000007209000000da0d7472616e736665725f66726f6d290272260000007227000000721500000072150000007216000000da1a6f70657261746f725f7472616e736665725f63757272656e63792b00000073060000000002100106017229000000630000000000000000010000000100000043000000730a00000074006a017d007c00530029014e2902721200000072130000002901da0673656e646572721500000072150000007216000000da0d6f70656e5f6f7262735f626f7832000000730400000000020601722b00000029047205000000721f000000721d000000da09636861726163746572630400000000000000090000000600000043000000738000000074006a017d0474026a037c0183017d057c056a047c0283017d0674057c0264016402660319007d0774067c067c037c07660319007407640319006b017346740864048301820174026a037c0083017d087c086a097c0274006a0a74006a017c0164058d04010074067c067c037c076603050019006406370003003c007c07530029074eda046d657461da047479706572110000007a114e6f7420757365206d6f7265206f7262732904721d0000007227000000da0c6d61696e5f6163636f756e747205000000e901000000290b7212000000721300000072200000007221000000da096765745f6f776e6572da065f5f6f726273da0a5f5f62616c616e6365737214000000721a0000007228000000da047468697329097205000000721f000000721d000000722c000000722a000000da127468696e675f6d61737465725f6f776e6572da056f776e6572da047469706f7224000000721500000072150000007216000000da0c636f6e73756d655f6f726273380000007316000000000206010a010a010e01180106010a010a010c01160172380000002916da0863757272656e63797209000000da09696d706f72746c69627220000000da0448617368722300000072140000007233000000da0b466f726569676e48617368da045f5f777072320000007217000000da085f5f6578706f7274da03737472da03416e79721b000000da05666c6f6174721c00000072250000007229000000722b00000072380000007215000000721500000072150000007216000000da083c6d6f64756c653e01000000732c0000000801080104010e010e010e0104010c0106010a03080506011206060112060601060110090601120610060601