Contract con_uw_nitro


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
10 @construct
11 def seed():
12 metadata['operator'] = ctx.caller
13 metadata['nitro_cost'] = 150
14 metadata['fees'] = decimal('0.15')
15 metadata['nitro_cost_init'] = 120
16 metadata['demand_cost'] = 20
17 metadata['time'] = 120
18 metadata['delivery'] = now
19
20
21 @export
22 def nitro_send_cost(contract: str, item_contract: str, uid: str, to: str, cost:float):
23 sender = ctx.caller
24 thing_master_owner = I.import_module(item_contract)
25 owner = thing_master_owner.get_owner(uid)
26
27 if (now - metadata['delivery']).minutes >= metadata['time']:
28 metadata['nitro_cost'] = metadata['nitro_cost_init']
29
30 assert wp[sender] >= metadata['nitro_cost'] + cost, 'Not enough coins to send!'
31 assert owner == sender , 'Not Owner'
32
33 con_uwarriors_lst001.transfer_from(metadata['nitro_cost'], metadata['operator'], sender)
34 metadata['nitro_cost'] += 20
35 metadata['delivery'] = now
36
37 thing_master_contract = I.import_module(contract)
38 thing_master_contract.transfer_from(
39 uid=uid,
40 to=ctx.this,
41 main_account=ctx.caller,
42 contract=item_contract)
43
44
45 balances[uid] = True
46 balances[uid, 'item'] = {owner: owner, contract: contract, item_contract: item_contract, uid: uid, to: to, cost: cost}
47
48
49 @export
50 def nitro_send_cancel(uid: str):
51 sender = ctx.caller
52 item = balances[uid, 'item']
53
54 assert balances[uid] == True , 'Not Owner'
55
56 thing_master_contract = I.import_module(item['contract'])
57 thing_master_contract.transfer(
58 uid=uid,
59 to=item['owner'],
60 main_account=ctx.this,
61 contract=item['item_contract'])
62
63 balances[uid, 'item'] = ''
64 balances[uid] = False
65
66
67 @export
68 def nitro_send_confirm(uid: str):
69 sender = ctx.caller
70 item = balances[uid, 'item']
71
72 assert wp[sender] >= item['cost'] , 'Not enough coins to send!'
73 assert balances[uid] == True , 'Not Send'
74 assert item[to] == sender , 'Not delivery receiver'
75
76 price_amount_pay = item['cost'] - (item['cost'] * metadata['fees'])
77
78 con_uwarriors_lst001.transfer_from(price_amount_pay, item[owner], sender)
79 con_uwarriors_lst001.transfer_from((item['cost'] * metadata['fees']), metadata['operator'], sender)
80
81 thing_master_contract = I.import_module(item['contract'])
82 thing_master_contract.transfer(
83 uid=uid,
84 to=item[to],
85 main_account=ctx.this,
86 contract=item['item_contract'])
87
88
89 @export
90 def nitro_send_free(contract: str, item_contract: str, uid: str, to: str):
91 sender = ctx.caller
92 thing_master_owner = I.import_module(item_contract)
93 owner = thing_master_owner.get_owner(uid)
94
95 if (now - metadata['delivery']).minutes >= metadata['time']:
96 metadata['nitro_cost'] = metadata['nitro_cost_init']
97
98 assert wp[sender] >= metadata['nitro_cost'] , 'Not enough coins to send!'
99 assert owner == sender , 'Not Owner'
100
101 con_uwarriors_lst001.transfer_from(metadata['nitro_cost'], metadata['operator'], sender)
102 metadata['nitro_cost'] += 20
103 metadata['delivery'] = now
104
105 thing_master_contract = I.import_module(contract)
106 thing_master_contract.transfer_from(
107 uid=uid,
108 to=to,
109 main_account=ctx.caller,
110 contract=item_contract)
111
112 @export
113 def change_metadata(key: str, value: Any):
114 assert ctx.caller == metadata['operator'], 'Only operator can set metadata!'
115 metadata[key] = value
116
117
118 @export
119 def operator_transfer_thing(uid: str, new_owner: str, contract: str, item_contract: str):
120 assert ctx.caller == metadata['operator'], 'Only auction operator can transfer things from contract.'
121 thing_master_contract = I.import_module(contract)
122 thing_master_contract.transfer(uid=uid, new_owner=new_owner, contract=item_contract)
123 S[uid] = False
124
125
126 @export
127 def operator_transfer_currency(amount: str, to: float):
128 assert ctx.caller == metadata['operator'], 'Only auction operator can transfer currency from contract.'
129 con_uwarriors_lst001.transfer(amount=amount, to=to)
130

Byte Code

e30000000000000000000000000700000040000000730c010000640064016c005a00640064016c015a0165025a03650464016402640364048d035a05650464006402640564048d035a06650464006402640664048d035a076508640764066402640864098d045a09640a640b84005a0a650b64028301650c650c650c650c650d640c9c05640d640e840483015a0e650b64028301650c640f9c0164106411840483015a0f650b64028301650c640f9c0164126413840483015a10650b64028301650c650c650c650c64149c0464156416840483015a11650b64028301650c651264179c0264186419840483015a13650b64028301650c650c650c650c641a9c04641b641c840483015a14650b64028301650c650d641d9c02641e641f840483015a15640153002920e9000000004eda0c636f6e5f75775f6e6974726fda01532903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086d65746164617461da0862616c616e636573da14636f6e5f7577617272696f72735f6c7374303031da0277702904da10666f726569676e5f636f6e7472616374da0c666f726569676e5f6e616d6572050000007206000000630000000000000000000000000300000043000000734200000074006a01740264013c006402740264033c00740364048301740264053c006406740264073c006408740264093c0064067402640a3c0074047402640b3c0064005300290c4eda086f70657261746f72e996000000da0a6e6974726f5f636f73747a04302e3135da0466656573e978000000da0f6e6974726f5f636f73745f696e6974e914000000da0b64656d616e645f636f7374da0474696d65da0864656c69766572792905da03637478da0663616c6c6572da0a5f5f6d65746164617461da07646563696d616cda036e6f77a900721c000000721c000000da00da045f5f5f5f0b000000730e00000000010a0108010c01080108010801721e00000029057205000000da0d6974656d5f636f6e7472616374da03756964da02746fda04636f7374630500000000000000090000000c0000004300000073e600000074006a017d0574026a037c0183017d067c066a047c0283017d07740574066401190018006a077406640219006b05723c740664031900740664043c0074087c0519007406640419007c0417006b05735874096405830182017c077c056b0273687409640683018201740a6a0b7406640419007406640719007c058303010074066404050019006408370003003c007405740664013c0074026a037c0083017d087c086a0b7c0274006a0c74006a017c0164098d040100640a740d7c023c007c077c077c007c007c017c017c027c027c037c037c047c046906740d7c02640b66023c0064005300290c4e721600000072150000007212000000720f0000007a194e6f7420656e6f75676820636f696e7320746f2073656e64217a094e6f74204f776e6572720d0000007213000000290472200000007221000000da0c6d61696e5f6163636f756e74720500000054da046974656d290e72170000007218000000da0149da0d696d706f72745f6d6f64756c65da096765745f6f776e6572721b0000007219000000da076d696e75746573da045f5f7770da0e417373657274696f6e4572726f727209000000da0d7472616e736665725f66726f6dda0474686973da0a5f5f62616c616e63657329097205000000721f000000722000000072210000007222000000da0673656e646572da127468696e675f6d61737465725f6f776e6572da056f776e6572da157468696e675f6d61737465725f636f6e7472616374721c000000721c000000721d000000da0f6e6974726f5f73656e645f636f7374150000007324000000000306010a010a0116010c010c01100110010c010a01100108010a010a010c0108010801723200000029017220000000630100000000000000040000000600000043000000736800000074006a017d0174027c006401660219007d0274027c00190064026b027326740364038301820174046a057c026404190083017d037c036a067c007c026405190074006a077c026406190064078d040100640874027c00640166023c00640974027c003c0064005300290a4e7224000000547a094e6f74204f776e657272050000007230000000721f00000029047220000000722100000072230000007205000000721d00000046290872170000007218000000722d000000722a00000072250000007226000000da087472616e73666572722c00000029047220000000722e00000072240000007231000000721c000000721c000000721d000000da116e6974726f5f73656e645f63616e63656c2c0000007310000000000206010c0114010e010c0110010c01723400000063010000000000000005000000060000004300000073c800000074006a017d0174027c006401660219007d0274037c0119007c02640219006b05732a740464038301820174027c00190064046b02733e74046405830182017c02740519007c016b02735274046406830182017c02640219007c0264021900740664071900140018007d0374076a087c037c02740919007c018303010074076a087c026402190074066407190014007406640819007c0183030100740a6a0b7c026409190083017d047c046a0c7c007c027405190074006a0d7c02640a1900640b8d04010064005300290c4e722400000072220000007a194e6f7420656e6f75676820636f696e7320746f2073656e6421547a084e6f742053656e647a154e6f742064656c69766572792072656365697665727210000000720d0000007205000000721f00000029047220000000722100000072230000007205000000290e72170000007218000000722d0000007229000000722a000000722100000072190000007209000000722b0000007230000000722500000072260000007233000000722c00000029057220000000722e0000007224000000da1070726963655f616d6f756e745f7061797231000000721c000000721c000000721d000000da126e6974726f5f73656e645f636f6e6669726d380000007318000000000206010c011801140114011801120112010c010e011001723600000029047205000000721f0000007220000000722100000063040000000000000008000000060000004300000073b400000074006a017d0474026a037c0183017d057c056a047c0283017d06740574066401190018006a077406640219006b05723c740664031900740664043c0074087c0419007406640419006b05735474096405830182017c067c046b0273647409640683018201740a6a0b7406640419007406640719007c048303010074066404050019006408370003003c007405740664013c0074026a037c0083017d077c076a0b7c027c0374006a017c0164098d04010064005300290a4e721600000072150000007212000000720f0000007a194e6f7420656e6f75676820636f696e7320746f2073656e64217a094e6f74204f776e6572720d000000721300000029047220000000722100000072230000007205000000290c72170000007218000000722500000072260000007227000000721b000000721900000072280000007229000000722a0000007209000000722b00000029087205000000721f00000072200000007221000000722e000000722f00000072300000007231000000721c000000721c000000721d000000da0f6e6974726f5f73656e645f6672656548000000731e000000000206010a010a0116010c011201060110010c010a01100108010a010c0172370000002902da036b6579da0576616c7565630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e720d0000007a1f4f6e6c79206f70657261746f722063616e20736574206d65746164617461212904721700000072180000007219000000722a000000290272380000007239000000721c000000721c000000721d000000da0f6368616e67655f6d657461646174615b0000007306000000000210010601723a00000029047220000000da096e65775f6f776e65727205000000721f000000630400000000000000050000000500000043000000733c00000074006a017402640119006b027316740364028301820174046a057c0283017d047c046a067c007c017c0364038d030100640474077c003c006400530029054e720d0000007a384f6e6c792061756374696f6e206f70657261746f722063616e207472616e73666572207468696e67732066726f6d20636f6e74726163742e29037220000000723b0000007205000000462908721700000072180000007219000000722a000000722500000072260000007233000000da035f5f5329057220000000723b0000007205000000721f0000007231000000721c000000721c000000721d000000da176f70657261746f725f7472616e736665725f7468696e6762000000730c0000000003100106010a0108010801723d0000002902da06616d6f756e747221000000630200000000000000020000000400000043000000732800000074006a017402640119006b027316740364028301820174046a057c007c0164038d0201006400530029044e720d0000007a3a4f6e6c792061756374696f6e206f70657261746f722063616e207472616e736665722063757272656e63792066726f6d20636f6e74726163742e2902723e00000072210000002906721700000072180000007219000000722a000000720900000072330000002902723e0000007221000000721c000000721c000000721d000000da1a6f70657261746f725f7472616e736665725f63757272656e63796d0000007306000000000210010601723f0000002916da0863757272656e63797209000000da09696d706f72746c69627225000000da0448617368723c0000007219000000722d000000da0b466f726569676e486173687229000000721e000000da085f5f6578706f7274da03737472da05666c6f61747232000000723400000072360000007237000000da03416e79723a000000723d000000723f000000721c000000721c000000721c000000721d000000da083c6d6f64756c653e0100000073300000000801080104010e010e010e0104010c03080a0601080110150601100b0601100f06011612060112060601060110090601