Ejemplo n.º 1
0
 def _mint(self, params):
     sp.set_type(params, 
         sp.TRecord(
             to_ = sp.TAddress,
             amount = sp.TNat,
             token_address = sp.TAddress,
             token_id = sp.TOption(sp.TNat),
             metadata=sp.TOption(sp.TMap(sp.TString, sp.TBytes))
         )
     )
     
     sp.if params.token_id.is_some():
         c = sp.contract(
             t = sp.TRecord(
                     address = sp.TAddress,
                     amount = sp.TNat,
                     token_id=sp.TNat,
                     metadata=sp.TMap(sp.TString, sp.TBytes)
                 ), 
                 address = params.token_address, 
                 entry_point = "mint"
             ).open_some()
                         
         sp.transfer(
             sp.record(
                 address = params.to_,
                 amount = params.amount,
                 token_id = params.token_id.open_some(),
                 metadata = params.metadata.open_some()
             ), 
             sp.mutez(0),
             c
         )
Ejemplo n.º 2
0
    def __init__(self, oracles, admin, spare, min_lock, cryptos_symbols, timelocks):

        open_pool_data = {
            'cryptos': sp.TMap(sp.TString, sp.TString),
            'amount': sp.TMutez,
            'timestamp': sp.TTimestamp,
            'timelock': sp.TTimestamp,
            'dips': sp.TMap(sp.TNat, sp.TRecord(amount = sp.TMutez, sent = sp.TBool))
        }

        swap_pool_data = {
            'address': sp.TAddress,
            'amount': sp.TMutez,
            'crypto': sp.TString,
            'rate': sp.TMutez,
            'timestamp': sp.TTimestamp,
            'timelock': sp.TTimestamp,
            'swaps': sp.TList(sp.TNat),
            'swapped': sp.TBool,
            'settled': sp.TMutez
        }

        self.init(
            spare=spare,
            admin=admin,
            oracles = oracles,
            accepted_cryptos = cryptos_symbols,
            min_lock = min_lock,
            timelocks = timelocks,
            pool_counter=sp.nat(0),
            swap_counter=sp.nat(0),
            open_pool = sp.map(tkey=sp.TNat, tvalue=sp.TRecord(**open_pool_data)),
            swap_pool = sp.big_map(tkey=sp.TNat, tvalue=sp.TRecord(**swap_pool_data)),
            closed_pool = sp.big_map(tkey=sp.TNat, tvalue=sp.TRecord(**open_pool_data))
        )
Ejemplo n.º 3
0
    def __init__(self, admin, supply, **extra_storage):
        contract_metadata = sp.big_map(
            l = {
                "": sp.bytes_of_string('tezos-storage:data'),
                "data": sp.bytes_of_string(
                    """{ 
                        "name": "SmartLink",
                        "description": "Decentralized escrow platform for Web 3.0",
                        "authors": ["SmartLink Dev Team <*****@*****.**>"],
                        "homepage": "https://smartlink.so/",
                        "interfaces": [ "TZIP-007", "TZIP-016"],
                        "symbol":"SMAK",
                        "icon":"ipfs://QmU2C4jU154nwA71AKHeiEj79qe7ZQC4Mf7AeUj5ALXZfe",
                        "decimals":"3"
                    }"""
                )
            },
          tkey = sp.TString,
          tvalue = sp.TBytes            
        )

        token_metadata = sp.big_map(
            l = {
                0: (
                    0,
                    sp.map(
                        l = {
                            "name": sp.bytes_of_string('Smartlink'), 
                            "decimals": sp.bytes_of_string('3'),
                            "symbol": sp.bytes_of_string('SMAK'),
                            "icon": sp.bytes_of_string('ipfs://QmU2C4jU154nwA71AKHeiEj79qe7ZQC4Mf7AeUj5ALXZfe')
                        },
                        tkey = sp.TString,
                        tvalue = sp.TBytes
                    )
                )
            },
            tkey = sp.TNat,
            tvalue = sp.TPair(sp.TNat, sp.TMap(sp.TString, sp.TBytes))
        )
        
        self.balances = sp.big_map(
            l = {admin: sp.record(balance = supply, approvals = {})}, 
            tkey = sp.TAddress,
            tvalue = sp.TRecord(approvals = sp.TMap(sp.TAddress, sp.TNat), balance = sp.TNat)
        )
        
        self.init(
            balances = self.balances,
            metadata = contract_metadata,
            token_metadata = token_metadata, 
            frozen_accounts = sp.big_map(tkey = sp.TAddress, tvalue = sp.TTimestamp),
            totalSupply = supply,  
            **extra_storage
        )
Ejemplo n.º 4
0
    def vest(self, params):
        sp.set_type(
            params, 
            sp.TList(
                sp.TRecord(
                    schedule_name = sp.TString,
                    beneficiery = sp.TAddress,
                    start = sp.TTimestamp,
                    end = sp.TTimestamp,
                    cliff = sp.TTimestamp,
                    vesting_amount = sp.TNat,
                    token_address = sp.TAddress,
                    token_id = sp.TOption(sp.TNat),
                    metadata=sp.TOption(sp.TMap(sp.TString, sp.TBytes))
                )
            )
        )

        sp.for schedule in params:
            self._vest(schedule)
            self._mint(
                sp.record(
                    to_ = sp.self_address,
                    amount = schedule.vesting_amount,
                    token_id = schedule.token_id,
                    token_address = schedule.token_address,
                    metadata = schedule.metadata
                )
            )
Ejemplo n.º 5
0
 def mint_OBJKT(self, params):
     sp.verify((params.amount > 0) & ((params.royalties >= 0) & (params.royalties <= 250)) & (params.amount <= 10000))
     
     c = sp.contract(
         sp.TRecord(
         address=sp.TAddress,
         amount=sp.TNat,
         token_id=sp.TNat,
         token_info=sp.TMap(sp.TString, sp.TBytes)
         ), 
         self.data.objkt, 
         entry_point = "mint").open_some()
         
     sp.transfer(
         sp.record(
         address=params.address,
         amount=params.amount,
         token_id=self.data.objkt_id,
         token_info={ '' : params.metadata }
         ), 
         sp.mutez(0), 
         c)
     
     self.data.royalties[self.data.objkt_id] = sp.record(issuer=sp.sender, royalties=params.royalties)
     self.data.objkt_id += 1
Ejemplo n.º 6
0
 def __init__(self, admin):
     with open('metadata/metadata.json', 'r') as f:
         #loads then dumps to confirm correctly formatted json
         metadata = json.dumps(json.load(f))
         self.init(
             paused=False,
             balances=sp.big_map(tvalue=sp.TRecord(
                 approvals=sp.TMap(sp.TAddress, sp.TNat), balance=sp.TNat)),
             administrator=admin,
             totalSupply=0,
             permits=sp.big_map(tkey=sp.TPair(sp.TAddress, sp.TBytes),
                                tvalue=sp.TTimestamp),
             user_expiries=sp.big_map(tkey=sp.TAddress,
                                      tvalue=sp.TOption(sp.TNat)),
             permit_expiries=sp.big_map(tkey=sp.TPair(
                 sp.TAddress, sp.TBytes),
                                        tvalue=sp.TOption(sp.TNat)),
             counter=0,
             default_expiry=50000,
             max_expiry=2628000,
             metadata=sp.big_map(
                 l={
                     "": sp.bytes_of_string("tezos-storage:md-json"),
                     "md-json": sp.bytes_of_string(metadata)
                 }))
Ejemplo n.º 7
0
 def get_type():
     return sp.TRecord(
         token_id = token_id_type,
         symbol = sp.TString,
         name = sp.TString,
         decimals = sp.TNat,
         extras = sp.TMap(sp.TString, sp.TString)
     )
Ejemplo n.º 8
0
    def __init__(self, config, **extra_storage):
        self.config = config

        self.init(
            balances = sp.big_map(tvalue = sp.TRecord(approvals = sp.TMap(sp.TAddress, sp.TNat), balance = sp.TNat)),
            totalSupply = 0,
            **extra_storage
        )
Ejemplo n.º 9
0
 def update(self, params):
     sp.set_type(params, sp.TMap(sp.TString, FeeData))
     sp.verify(sp.sender == self.data.admin)
     keyValueList = params.items()
     sp.for feeData in keyValueList:
         sp.if self.data.fees.contains(feeData.key):
             sp.if feeData.value.update_time > self.data.fees[feeData.key].update_time:
                 self.data.fees[feeData.key] = feeData.value
Ejemplo n.º 10
0
 def get_type(self):
     t = sp.TRecord(
         token_id = token_id_type,
         token_metadata_map = sp.TMap(sp.TString, sp.TBytes)
     )
     if self.config.force_layouts:
         t = t.layout(("token_id",
                       ("token_metadata_map")))
     return t
Ejemplo n.º 11
0
 def mint(self, params):
     sp.set_type(params, 
         sp.TRecord(
             address=sp.TAddress,
             amount=sp.TNat,
             token_id=sp.TNat,
             metadata=sp.TMap(sp.TString, sp.TBytes),
         )
     )
Ejemplo n.º 12
0
 def get_type(self):
     t = sp.TRecord(
         player_id=player_id_type,
         metadata=sp.TString,
         name=sp.TString,
         extras=sp.TMap(sp.TString, sp.TString)
     )
     if self.config.force_layouts:
         t = t.layout(("player_id", ("name", "metadata")))
     return t
Ejemplo n.º 13
0
 def _init_(self,_Admin,members,amt):
     self.init (
         admin = _Admin,
         mincontribution = amt,
         tokencontract = sp.TAddress,
         totalmembers = members,
         allocprop = sp.big_map(tkey = sp.TNat, 
                                         tvalue = 
                                             sp.TRecord(
                                                 creator = sp.TAddress,
                                                 amount  = sp.TNat,
                                                 votesfor   = sp.TNat,
                                                 votesagainst = sp.TNat,
                                                 voteCount = sp.TNat,
                                                 allocexpiry  = sp.TTimestamp,
                                                 accepted = sp.TBool,
                                                 voteexpiry = sp.TTimestamp,
                                                 diff = sp.TInt
                                                 
                                             )
                                 ),
         membermap = sp.big_map(tkey = sp.TAddress,
                         tvalue = sp.TBool),                                
         addmemberdata = sp.big_map(tkey = sp.TNat,
                                tvalue = sp.record(
                                    address = sp.TAddress,
                                    balance = sp.TNat,
                                    status = sp.TBool
                                    )
                                 ),
         addmemberdataid = sp.nat(0),
         membermapid = sp.nat(0),
         membercount = sp.nat(0),
         allocpropid = sp.nat(0),
         indispute = sp.TBool,
         finalproject = sp.TAddress,
         projectdata = sp.big_map(tkey = sp.TAddress,
                                 tvalue = sp.TRecord(
                             funded = sp.TBool,
                             votesfor   = sp.TNat,
                             votesagainst = sp.TNat,
                             voteCount = sp.TNat,
                             expiry  = sp.TTimestamp,
                             diff = sp.TInt)
                             ),
             holders = sp.big_map(  # Holder address to balance, approvals map
             tkey = sp.TAddress, 
             tvalue = sp.TRecord(
                 approvals = sp.TMap(sp.TAddress, sp.TNat),
                 balance = sp.TNat
             )
         ) 
                             
         
     )
Ejemplo n.º 14
0
 def get_type():
     return sp.TRecord(
         token_id=sp.TNat,
         symbol=sp.TString,
         name=sp.TString,
         decimals=sp.TNat,
         extras=sp.TMap(sp.TString, sp.TString)
     ).layout(("token_id",
               ("symbol",
                ("name",
                 ("decimals", "extras")))))
Ejemplo n.º 15
0
 def __init__(self, manager, spare):
     
     self.init(
         certifiers=sp.map(tkey=sp.TString, tvalue=sp.TAddress),
         products=sp.big_map(
             tkey=sp.TString, 
             tvalue=sp.TRecord(**{'certifier':sp.TString, 
             'metahash':sp.TList(sp.TMap(sp.TString, sp.TString)), 'lookups':sp.TNat})),
         manager=manager,
         spare=spare
         )
Ejemplo n.º 16
0
 def get_type():
     return sp.TRecord(
         balance=sp.TNat,
         operators=sp.TSet(
             sp.TAddress
         ),
         approvals=sp.TMap(
             sp.TAddress,
             sp.TNat,
         ),
     )
Ejemplo n.º 17
0
 def __init__(self):
     self.init_type(t = sp.TRecord(owner = sp.TAddress,
             master_auction_contract = sp.TAddress,
             asset_id = sp.TNat,
             deposit = sp.TNat,
             sealed_bids = sp.TMap(sp.TAddress, sp.TBytes),
             revealed_count = sp.TNat,
             highest_bid = sp.TMutez,
             highest_bidder = sp.TAddress,
             started = sp.TBool,
             first_revealed = sp.TBool,
             ended = sp.TBool,
             start_time = sp.TTimestamp,
             round_time = sp.TInt))
Ejemplo n.º 18
0
 def set_token_metadata(self, metadata):
     """
         Store the token_metadata values in a big-map annotated %token_metadata
         of type (big_map nat (pair (nat %token_id) (map %token_info string bytes))).
     """
     self.update_initial_storage(
         token_metadata = sp.big_map(
             {
                 0: sp.record(token_id = 0, token_info = self.normalize_metadata(metadata))
             },
             tkey = sp.TNat,
             tvalue = sp.TRecord(token_id = sp.TNat, token_info = sp.TMap(sp.TString, sp.TBytes))
         )
     )
Ejemplo n.º 19
0
 def get_type(self):
     t = sp.TRecord(
         token_id = token_id_type,
         symbol = sp.TString,
         name = sp.TString,
         decimals = sp.TNat,
         extras = sp.TMap(sp.TString, sp.TString)
     )
     if self.config.force_layouts:
         t = t.layout(("token_id",
                       ("symbol",
                        ("name",
                         ("decimals", "extras")))))
     return t
Ejemplo n.º 20
0
 def get_type(self):
     t = sp.TRecord(
         token_id=token_id_type,
         card_score=sp.TNat,
         inMatch=sp.TBool,
         player_id=sp.TNat,
         extras=sp.TMap(sp.TString, sp.TString)
     )
     if self.config.force_layouts:
         t = t.layout(("token_id",
                       ("card_score",
                        ("inMatch",
                         ("player_id", "extras")))))
     return t
Ejemplo n.º 21
0
 def mint_OBJKT(self, params):
     sp.verify(params.amount > 0)
     sp.set_type(params, sp.TRecord(address=sp.TAddress, amount=sp.TNat, metadata=sp.TMap(sp.TString, sp.TBytes)))
     c = sp.contract(
         sp.TRecord(
         address=sp.TAddress,
         amount=sp.TNat,
         token_id=sp.TNat,
         token_info=sp.TMap(sp.TString, sp.TBytes)
         ), 
         self.data.objkt, 
         entry_point = "mint").open_some()
         
     sp.transfer(
         sp.record(
         address=params.address,
         amount=params.amount,
         token_id=self.data.objkt_id,
         token_info=params.metadata
         ), 
         sp.mutez(0), 
         c)
     
     self.data.objkt_id += 1
Ejemplo n.º 22
0
    def __init__(self, owner, totalSupply):
        self.init(
            owner=owner,
            totalSupply=sp.as_nat(totalSupply),
            ledger=sp.big_map({
                owner: sp.record(balance=sp.as_nat(totalSupply), allowances={})

            },
                tkey=sp.TAddress,
                tvalue=sp.TRecord(
                    balance=sp.TNat,
                    allowances=sp.TMap(
                        sp.TAddress,
                        sp.TNat
                    )
            )
            )
        )
Ejemplo n.º 23
0
 def __init__(self, schedule, duration, interval, periods, payer, issuer, start):
     self.init(
         schedule = schedule,
         duration = duration,
         interval = interval,
         periods = periods,
         payer = payer,
         issuer = issuer,
         start = start,
         freeCollateral = sp.mutez(0),
         balances = sp.big_map(
             tkey = sp.TAddress,
             tvalue = sp.TRecord(
                 balance = sp.TNat,
                 approvals = sp.TMap(k = sp.TAddress, v = sp.TNat),
             )
         )
     )
Ejemplo n.º 24
0
 def _vest(self, params):
     sp.set_type(params,
         sp.TRecord(
             schedule_name = sp.TString,
             beneficiery = sp.TAddress,
             start = sp.TTimestamp,
             end = sp.TTimestamp,
             cliff = sp.TTimestamp,
             vesting_amount = sp.TNat,
             token_address = sp.TAddress,
             token_id = sp.TOption(sp.TNat),
             metadata=sp.TOption(sp.TMap(sp.TString, sp.TBytes))
         )
     )
     
     # if you send the same schedule_name
     # it will add to the vesting amount
     schedule_name = params.schedule_name
     
     sp.verify(params.start < params.cliff)
     sp.verify(params.start < params.end)
     sp.verify(params.cliff < params.end)
     
     beneficiery = params.beneficiery
     
     schedule = sp.record(
         revoked = False,
         revokedAt = sp.none,
         revokedBy = sp.none,
         start = params.start,
         end = params.end,
         cliff = params.cliff,
         claimed_amount = sp.as_nat(0),
         token_id = params.token_id,
         token_address = params.token_address,
         vesting_amount = params.vesting_amount,
     )
     
     sp.if ~self.data.schedules.contains(beneficiery):
         self.data.schedules[beneficiery] = {}
         self.data.schedules[beneficiery][schedule_name] = schedule
Ejemplo n.º 25
0
 def __init__(self):
     self.init(
         schedules = sp.map(
             tkey= sp.TAddress, 
             tvalue= sp.TMap(
                 sp.TString,
                 sp.TRecord(
                     revoked = sp.TBool,
                     revokedAt = sp.TOption(sp.TTimestamp),
                     revokedBy = sp.TOption(sp.TAddress),
                     start = sp.TTimestamp,
                     end = sp.TTimestamp,
                     cliff = sp.TTimestamp,
                     vesting_amount = sp.TNat,
                     claimed_amount = sp.TNat,
                     token_address = sp.TAddress,
                     token_id = sp.TOption(sp.TNat)
                 )
             )
         )
     )
Ejemplo n.º 26
0
 def join_hDAO(self, params):
     sp.verify((sp.amount > sp.mutez(0)) & (sp.balance < sp.tez(730000)))
     
     c = sp.contract(
         sp.TRecord(
         address=sp.TAddress,
         amount=sp.TNat,
         token_id=sp.TNat,
         token_info=sp.TMap(sp.TString, sp.TBytes)
         ), 
         self.data.ung, 
         entry_point = "mint").open_some()
         
     sp.transfer(
         sp.record(
         address=sp.sender,
         amount=sp.fst(sp.ediv(sp.amount, sp.mutez(1)).open_some()),
         token_id=1,
         token_info={"": sp.pack("ipfs://QmS87PA42aKj6WgPM1vQMHxyavKJkswa5ycgAn1wbSrNgi")}
         ), 
         sp.mutez(0), 
         c)
     
     self.data.balance += sp.amount
 def get_type():
     return sp.TRecord(timelock_id=sp.TNat, signatures=sp.TMap(sp.TKeyHash,sp.TSignature)).layout(("timelock_id","signatures"))
Ejemplo n.º 28
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)
Ejemplo n.º 29
0
 def __init__(self, admin):
     self.init(paused = False, ledger = sp.big_map(tvalue = sp.TRecord(approvals = sp.TMap(sp.TAddress, sp.TNat), balance = sp.TNat)), administrator = admin, totalSupply = 0)
Ejemplo n.º 30
0
 def getDataFromOrO(self, params):
     contract = sp.contract(sp.TMap(k=sp.TNat, v=sp.TRecord(points=sp.TNat, rank=sp.TNat)),
                            sp.sender, entry_point="receiveDataFromOrO").open_some()
     sp.transfer(self.data.playerPoints, sp.mutez(0), contract)