Пример #1
0
 def __init__(self, owner):
     self.add_flag("edo")
     self.init_type(
         sp.TRecord(admin=sp.TAddress,
                    tickets=sp.TBigMap(sp.TNat, sp.TTicket(sp.TNat)),
                    current_id=sp.TNat,
                    token_metadata=TOKEN_METADATA_TYPE))
     self.init(admin=owner,
               tickets=sp.big_map({}),
               current_id=0,
               token_metadata=sp.big_map({}))
Пример #2
0
    def sendNft(self, params):
        sp.set_type(
            params,
            sp.TRecord(ticket_id=sp.TNat,
                       send_to=sp.TContract(sp.TTicket(sp.TNat))))
        sp.verify(sp.sender == self.data.admin)
        my_ticket, new_map = sp.get_and_update(self.data.tickets,
                                               params.ticket_id, sp.none)
        sp.verify(my_ticket.is_some(), "Ticket does not exist")

        self.data.tickets = new_map
        sp.transfer(my_ticket.open_some(), sp.mutez(0), params.send_to)
    def cancelAuction(self):
        sp.verify(self.data.in_progress, "No Auction in progress")
        sp.verify(sp.sender == self.data.owner, "User not Authorized")
        self.data.current_price = 0

        #Send back ticket to owner
        c = sp.contract(sp.TTicket(sp.TNat),
                        self.data.owner,
                        entry_point="receiveNft").open_some()
        sp.transfer(self.data.ticket.open_some(), sp.mutez(0), c)
        # endAuction
        self.data.ticket = sp.none
        self.data.in_progress = sp.bool(False)
 def receiveNft(self, nft):
     sp.set_type(nft, sp.TTicket(sp.TNat))
     ticket_data, ticket_next = sp.read_ticket(nft)
     qty = sp.compute(sp.snd(sp.snd(ticket_data)))
     originator = sp.compute(sp.fst(ticket_data))
     id = sp.compute(sp.fst(sp.snd(ticket_data)))
     sp.verify(qty == 1, "Only send 1 Nft to this entrypoint")
     sp.verify(sp.source == self.data.admin,
               "Ticket needs to be sent by wallet admin")
     current_id = self.data.current_id
     new_map = sp.update_map(self.data.tickets, current_id,
                             sp.some(ticket_next))
     self.data.tickets = new_map
     self.data.current_id = current_id + 1
Пример #5
0
 def __init__(self, admin):
     self.add_flag("edo")
     self.init(owner=admin,
               current_price=0,
               reserve_price=0,
               in_progress=sp.bool(False),
               start_time=sp.timestamp(0),
               round_time=0,
               ticket=sp.none)
     self.init_type(t=sp.TRecord(owner=sp.TAddress,
                                 current_price=sp.TNat,
                                 reserve_price=sp.TNat,
                                 in_progress=sp.TBool,
                                 start_time=sp.TTimestamp,
                                 round_time=sp.TInt,
                                 ticket=sp.TOption(sp.TTicket(sp.TNat))))
Пример #6
0
    def buy(self, wallet_address):
        sp.set_type(wallet_address, sp.TAddress)
        sp.verify(self.data.in_progress)
        sp.verify(~(sp.sender == self.data.owner))
        sp.verify(sp.amount == sp.mutez(self.data.current_price))
        # verify now less than or equal to round_end_time = start_time + round_time
        sp.verify(
            sp.now <= self.data.start_time.add_seconds(self.data.round_time))

        sp.send(self.data.owner, sp.amount)

        #Send ticket/asset to winner. They must have a "receive_ticket" entrypoint that accepts ticket of correct type
        c = sp.contract(sp.TTicket(sp.TNat),
                        wallet_address,
                        entry_point="receiveNft").open_some()
        sp.transfer(self.data.ticket.open_some(), sp.mutez(0), c)

        # endAuction
        self.data.ticket = sp.none
        self.data.in_progress = sp.bool(False)
Пример #7
0
import smartpy as sp

AUCTION_PARAMS_TYPE = sp.TRecord(opening_price=sp.TNat,
                                 reserve_price=sp.TNat,
                                 start_time=sp.TTimestamp,
                                 round_time=sp.TInt,
                                 ticket=sp.TTicket(sp.TNat))

METADATA_TYPE = sp.TMap(sp.TString, sp.TBytes)

TOKEN_METADATA_TYPE = sp.TBigMap(sp.TNat, sp.TPair(sp.TNat, METADATA_TYPE))


class NFTWallet(sp.Contract):
    def __init__(self, owner):
        self.add_flag("edo")
        self.init_type(
            sp.TRecord(admin=sp.TAddress,
                       tickets=sp.TBigMap(sp.TNat, sp.TTicket(sp.TNat)),
                       current_id=sp.TNat,
                       token_metadata=TOKEN_METADATA_TYPE))
        self.init(admin=owner,
                  tickets=sp.big_map({}),
                  current_id=0,
                  token_metadata=sp.big_map({}))

    @sp.entry_point
    def createNft(self, metadata):
        sp.set_type(metadata, METADATA_TYPE)
        sp.verify(sp.sender == self.data.admin)
        my_ticket = sp.ticket(self.data.current_id, 1)