diff --git a/contracts/market.se b/contracts/market.se index 1545b48..1699404 100644 --- a/contracts/market.se +++ b/contracts/market.se @@ -34,8 +34,8 @@ def shared(): def add(): # not ideal, only one bid per block per sender - key = ticket - ticket = ticket + 1 + key = self.ticket + self.ticket = self.ticket + 1 self.pool[key].owner = msg.sender self.pool[key].epoch = block.number @@ -85,6 +85,19 @@ def deactivate(ticket): # delete the entire entry if possible self.pool[bidkey].state = -1 # non existant +# def add_sealed_offer(hash): +# # trade contract +# # dispute contract + +# # add to trade_offers[] + +# def reveal_offer(offer_id): +# # check sha of offer + +# def accept_offer(offer_id): +# # within accept blockchain number bounds +# # if other has accepted, create trade contract? + # TODO: Remove from storage # macro delete_blah(i): diff --git a/test.py b/test.py index fea4633..ea1417e 100644 --- a/test.py +++ b/test.py @@ -5,21 +5,33 @@ import os state = tester.state() - -def listener(msg): - if msg['event'] == 'LOG': - print(msg['topics']) - -slogging.log_listeners.listeners.append(listener) - +# Create Market Contract market = state.abi_contract('contracts/market.se', gas=10000000) +# Create Match Maker +class Matchmaker: + def listener(self, msg): + if msg['event'] == 'LOG': + print('announce', msg['topics']) + + def __init__(self): + slogging.log_listeners.listeners.append(self.listener) + +match_maker = Matchmaker() + +# Create buy ticket, add preferences, activate +buy_ticket = market.add() +market.add_preference(buy_ticket, "price", 5) +market.activate(buy_ticket) + +# Create sell ticket, add preferences, activate +sell_ticket = market.add() +market.add_preference(sell_ticket, "price", -5) +market.activate(sell_ticket) + + -# ticket = market.add() -# print(ticket) -# ticket2 = market.add() -# print(ticket) # head = tail = xorll.insert("head", 10, 0, 0) # tail = xorll.insert("tail", 20, 0, tail)