예제 #1
0
def init_permit_data():
    return sp.record(permits = sp.map(tkey=sp.TPair(sp.TAddress, sp.TBytes), tvalue=sp.TTimestamp),
    user_expiries = sp.map(tkey=sp.TAddress, tvalue=sp.TOption(sp.TNat)),
    permit_expiries = sp.map(tkey=sp.TPair(sp.TAddress, sp.TBytes), tvalue=sp.TOption(sp.TNat)),
    counter = 0,
    default_expiry = 50000,
    max_expiry = 2628000)
예제 #2
0
 def __init__(self):
     initial_candidates = {'Satoshi': 0, 'Arthur': 0, 'Vitalik': 0}
     self.init(
         owner = sp.address("tz1Kk1jF734jwhK4asf5LWMxWWN5yHiA9h7n"),
         candidates = sp.map(l = initial_candidates, tkey = sp.TString, tvalue = sp.TInt),
         voters = sp.map(tkey = sp.TAddress, tvalue = sp.TBool),
         voting_ended = False
     )
예제 #3
0
 def __init__(self, owner):
     self.init(
         owner = owner,
         isOpen = sp.bool(False),
         ctrs = sp.map(l = {}),
         bids = sp.map(l = {}),
         agents = sp.map(l = {}),
         prices = sp.map(l = {}),
      )
예제 #4
0
    def __init__(self,admin,endCycle,endWithdraw,token):

        self.init(contractBuyer= sp.big_map(),contractSellar = sp.big_map(),
        administrator = admin,buyerSet = sp.set(),poolSet=sp.set(),
            xtzPrice=400,validation=sp.record(cycleEnd=sp.timestamp(endCycle),withdrawTime=sp.timestamp(endWithdraw),totalSupply=sp.nat(0)),
            tokenContract=token,adminAccount=0,model = sp.map()
        )
예제 #5
0
 def __init__(self):
     self.init(
         book=sp.map(
             tkey= sp.TAddress, 
             tvalue=sp.TRecord(memo = sp.TString, result = sp.TInt)
         ),
     )
예제 #6
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))
        )
예제 #7
0
 def __init__(self, admin):
     self.init(
         feed = sp.map(
             tkey = sp.TString,
             tvalue =
                 sp.TRecord(
                     value = sp.TNat,
                     precision = sp.TNat,
                     timestamp = sp.TTimestamp,
                     source = sp.TString
             )),
         feedQueryCost = sp.map(tkey = sp.TString, tvalue = sp.TMutez),
         admin = admin,
         operators = sp.set(),
         registeredPairs = sp.set()
     )
예제 #8
0
 def createSealedBidAuctionInstance(self, asset_id, asset_name):
     sp.verify(sp.sender == self.data.master_auction_contract)
     
     contract_address = sp.some(sp.create_contract(
         storage = sp.record(owner = sp.source,
             master_auction_contract = sp.to_address(sp.self),
             asset_id = asset_id,
             # deposit will get seized if participant tries to cheat
             deposit = 0,
             sealed_bids = sp.map(tkey = sp.TAddress, tvalue = sp.TBytes),
             # TODO: maintain revealed_participants list and only refund those
             # possibly split the money b/w highest bidder and owner
             # enforcing all participants to reveal their bids
             # Then there'll be no need to maintain revealed_count & first_revealed
             revealed_count = 0,
             highest_bid = sp.mutez(0),
             highest_bidder = sp.sender,
             started = sp.bool(False),
             first_revealed = sp.bool(False),
             ended = sp.bool(False),
             start_time = sp.now,
             round_time = 0), 
         contract = self.sealed_bid))
     
     # registerInstance
     c = sp.contract(sp.TRecord(asset_id = sp.TNat, contract_address = sp.TAddress),  self.data.master_auction_contract, entry_point = "registerInstance").open_some()
     sp.transfer(sp.record(asset_id = asset_id, contract_address = contract_address.open_some()), sp.mutez(0), c)
예제 #9
0
파일: crowd.py 프로젝트: lkazmer/ungrund
 def __init__(self):
     self.init(
         parties = sp.map(tkey=sp.TAddress, tvalue=sp.TMutez),
         minAmount = sp.tez(0),
         total = sp.tez(0),
         maxTime = sp.timestamp(0) #  + 345600
         )
예제 #10
0
파일: FA2.py 프로젝트: r4ravi2008/CricTez
    def __init__(self, config, admin):
        self.config = config
        self.error_message = Error_message(self.config)
        self.operator_set = Operator_set(self.config)
        self.operator_param = Operator_param(self.config)
        self.token_id_set = Token_id_set(self.config)
        self.ledger_key = Ledger_key(self.config)
        self.token_meta_data = Token_meta_data(self.config)
        self.permissions_descriptor_ = Permissions_descriptor(self.config)
        self.batch_transfer = Batch_transfer(self.config)
        self.player_meta_data = Player_meta_data(self.config)
        self.player_id_set = Player_id_set(self.config)

        if self.config.add_mutez_transfer:
            self.transfer_mutez = sp.entry_point(mutez_transfer)
        if self.config.add_permissions_descriptor:
            def permissions_descriptor(self, params):
                sp.set_type(params, sp.TContract(
                    self.permissions_descriptor_.get_type()))
                v = self.permissions_descriptor_.make()
                sp.transfer(v, sp.mutez(0), params)
            self.permissions_descriptor = sp.entry_point(
                permissions_descriptor)
        if config.lazy_entry_points:
            self.add_flag("lazy_entry_points")
        if config.lazy_entry_points_multiple:
            self.add_flag("lazy_entry_points_multiple")
        self.exception_optimization_level = "DefaultLine"
        self.init(
            paused=False,
            ledger=self.config.my_map(tvalue=Ledger_value.get_type()),
            tokens=self.config.my_map(tvalue=self.token_meta_data.get_type()),
            operators=self.operator_set.make(),
            administrator=admin,
            all_tokens=self.token_id_set.empty(),
            players=self.config.my_map(
                tkey=sp.TNat, tvalue=self.player_meta_data.get_type()),
            tokens_on_sale=sp.big_map(tkey=sp.TNat, tvalue=sp.TRecord(
                owner=sp.TAddress, price=sp.TMutez)),
            selected_tokens=sp.map(
                tkey=sp.TAddress, tvalue=sp.TRecord(tokens=sp.TSet(sp.TNat))),
            matches=sp.map(tkey=sp.TNat, tvalue=sp.TRecord(
                teamA=sp.TString, teamB=sp.TString, active=sp.TBool, finished=sp.TBool, date=sp.TString, compete=sp.TBool)),
            playerPoints=sp.map(tkey=sp.TNat, tvalue=sp.TRecord(
                points=sp.TNat, rank=sp.TNat)),
            keysset=sp.set([admin]),
        )
예제 #11
0
 def make_metadata(symbol, name, decimals):
     "Helper function to build metadata JSON bytes values."
     return (sp.map(l = {
         # Remember that michelson wants map already in ordered
         "decimals" : sp.utils.bytes_of_string("%d" % decimals),
         "name" : sp.utils.bytes_of_string(name),
         "symbol" : sp.utils.bytes_of_string(symbol)
     }))
예제 #12
0
 def Burn(self, params):
     value = params.value
     sp.verify(sp.sender == self.data.owner,
               message="You must be the owner of the contract to burn tokens")
     owner_account = sp.record(balance=sp.nat(
         0), allowances=sp.map(tkey=sp.TAddress, tvalue=sp.TNat))
     sp.if self.data.ledger.contains(self.data.owner):
         owner_account = self.data.ledger[self.data.owner]
예제 #13
0
파일: petition.py 프로젝트: lkazmer/ungrund
 def __init__(self):
     self.init(
         time_out = sp.timestamp(0),
         signatures = sp.map(tkey = sp.TString, tvalue = sp.TString),
         immutability = False,
         proposal = '',
         ocasion = '',
         description = ''
         )
예제 #14
0
 def __init__(self):
     self.init(
         time_out = sp.timestamp(0),
         votes = sp.map(tkey = sp.TAddress, tvalue = sp.TString),
         parties = sp.list(t=sp.TAddress),
         immutability = False,
         proposal = '',
         ocasion = '',
         ammendment = ''
         )
예제 #15
0
 def Mint(self, params):
     value = params.value
     sp.verify(sp.sender == self.data.owner,
               message="You must be the owner of the contract to mint tokens")
     def_val = sp.record(balance=sp.nat(0), allowances=sp.map(
         tkey=sp.TAddress, tvalue=sp.TNat))
     self.data.ledger[self.data.owner] = self.data.ledger.get(
         self.data.owner, def_val)
     self.data.ledger[self.data.owner].balance += value
     self.data.totalSupply = self.data.totalSupply + value
예제 #16
0
    def test():
        scenario = sp.test_scenario()
        scenario.h1("Update Fails With Bad Signature")

        scenario.h2("GIVEN an Oracle contract")
        assetCode = "XTZ-USD"

        contract = OracleContract(
            publicKey=testAccountPublicKey,
            initialData=sp.big_map(
                l={
                    assetCode: initialOracleData
                },
                tkey=sp.TString,
                tvalue=Harbinger.OracleDataType
            )
        )
        scenario += contract

        scenario.h2("AND an update signed by an alternative key")
        alternativeAccount = sp.test_account("AlternativeAccount")
        alternativeSecretKey = alternativeAccount.secret_key
        start = sp.timestamp(1)
        end = sp.timestamp(2)
        open = 3
        high = 4
        low = 5
        close = 6
        volume = 7
        updateData = (
            start,
            (end,
            (open,
            (high,
            (low,
                (close, volume))))))
        message = sp.pack(updateData)
        signature = sp.make_signature(
            alternativeSecretKey,
            message,
            message_format='Raw'
        )

        scenario.h2("WHEN the oracle is updated")
        update = sp.pair(signature, updateData)
        parameter = sp.map(
            l={
                assetCode: update
            },
            tkey=sp.TString,
            tvalue=SignedOracleDataType
        )

        scenario.h2("THEN the update fails")
        scenario += contract.update(parameter).run(valid=False)
예제 #17
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
        )
예제 #18
0
def test():
    time = sp.timestamp(1571761674)
    # Create test scenario
    scenario = sp.test_scenario()

    scenario.table_of_contents()

    # sp.test_account generates ED25519 key-pairs deterministically:
    alice = sp.test_account("Alice")
    bob = sp.test_account("Robert")

    # Create HTML output for debugging
    scenario.h1("Dutch Auction")

    # Instantiate Auction contract
    auction = DutchAuction(alice.address)
    scenario += auction

    alice_wallet = NFTWallet(alice.address)
    bob_wallet = NFTWallet(bob.address)

    scenario += alice_wallet
    scenario += bob_wallet

    scenario.h2("Create NFT")

    token_metadata = sp.map({"name": sp.bytes_of_string("Nft1")})
    scenario += alice_wallet.createNft(token_metadata).run(sender=alice)

    scenario.h2("Configure and start auction")
    scenario += alice_wallet.configNftAuction(auction_address=auction.address,
                                              opening_price=100,
                                              reserve_price=10,
                                              start_time=time,
                                              round_time=1000,
                                              ticket_id=0).run(source=alice,
                                                               sender=alice,
                                                               now=time)
    scenario.verify(~alice_wallet.data.tickets.contains(0))
    time = time.add_seconds(1)
    scenario += auction.startAuction().run(sender=alice, now=time)

    time = time.add_seconds(6001)

    scenario += auction.dropPrice(90).run(sender=alice, now=time)

    scenario.h2("Bob buys")
    time = time.add_seconds(1)
    scenario += auction.buy(bob_wallet.address).run(sender=bob,
                                                    source=bob,
                                                    now=time,
                                                    amount=sp.mutez(90))
    scenario.verify(bob_wallet.data.tickets.contains(0))
    scenario.verify(~auction.data.ticket.is_some())
예제 #19
0
    def request_fortune(self, params):
        
        self.data.client_requests[self.data.next_request_id] = sp.sender

        self.request_helper(params.payment,   
                            self.data.fortune_job_id,
                            sp.map(l = {"sender": sp.variant("bytes", sp.pack(sp.sender))}), 
                            self.data.oracle, 
                            self.data.waiting_fortune_id, 
                            sp.self_entry_point("receive_fortune"), 
                            params.timeout)
예제 #20
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
         )
예제 #21
0
    def __init__(self,admin,token,oracle):

            self.init(
            Securities= sp.big_map(),LiquidityProvider = sp.big_map(),
            poolSet=sp.set(),
            totalSupply=sp.nat(0),
            adminAccount=sp.nat(0),
            PoolSize = sp.nat(10),
            InterestRate=sp.map(),
            administrator = admin,
            token=token,    
            oracle=oracle)
def make_roles(administrators=sp.set([], t=sp.TAddress), validators=sp.set([], t=sp.TAddress), controllers=sp.set([], t=sp.TAddress)):
    return sp.map(
        {
            ADMIN_ROLE: make_role(ADMIN_ROLE, administrators),
            ALLOWLIST_ADMIN_ROLE: make_role(ADMIN_ROLE, controllers),
            BLOCKLIST_ADMIN_ROLE: make_role(ADMIN_ROLE)
        },
        tkey=sp.TNat, 
        tvalue=sp.TRecord(
            role_admin=sp.TNat,
            members=sp.TSet(t=sp.TAddress)
        )
    )
예제 #23
0
 def initialMint(self):
     sp.verify(self.is_administrator(sp.sender) & ~self.data.initialMint)
     # single asset hence token-id = 0
     user = self.ledger_key.make(sp.sender, 0)
     self.token_id_set.add(self.data.all_tokens, 0)
     self.data.ledger[user] = Ledger_value.make(self.data.total_supply)
     self.data.tokens[0] = sp.record(
         token_id=0,
         symbol="FSCK",
         name="Fishcake",
         decimals=0,
         extras=sp.map()
     )
     self.data.initialMint = True
예제 #24
0
 def __init__(self, manager, registrars):
     
     self.init(
         manager=manager,
         registrars=registrars,
         lands=sp.big_map(tkey=sp.TString, tvalue=sp.TRecord(
             A=sp.TPair(sp.TInt, sp.TInt),
             B=sp.TPair(sp.TInt, sp.TInt),
             C=sp.TPair(sp.TInt, sp.TInt),
             D=sp.TPair(sp.TInt, sp.TInt)
             )),
         
         land_owners=sp.map(tkey=sp.TAddress, tvalue=sp.TSet(sp.TString))
         )
예제 #25
0
 def __init__(self):
     self.english = EnglishAuction()
     self.dutch = DutchAuction()
     # self.sealed_bid = SealedBidAuction()
     # TODO: create seperate counters for asset and auction. Current counter is for asset.
     # TODO: is_available okay ?
     self.init(counter = 1, 
             instances_map = sp.map(
                 tkey = sp.TNat,
                 tvalue = sp.TRecord(
                     asset_name = sp.TString,
                     auction_type = sp.TString,
                     owner = sp.TAddress,
                     contract_address = sp.TAddress,
                     is_available = sp.TBool)))
예제 #26
0
 def __init__(self, owner):
     self.init(counter = 1,
             owner = owner,
             english_factory = owner,
             dutch_factory = owner,
             sealed_bid_factory = owner,
             vickrey_factory = owner,
             instances_map = sp.map(
                 tkey = sp.TNat,
                 tvalue = sp.TRecord(
                     asset_name = sp.TString,
                     auction_type = sp.TString,
                     owner = sp.TAddress,
                     contract_address = sp.TAddress,
                     is_available = sp.TBool)))
예제 #27
0
def make_roles(administrators, validators, controllers, burners, minters):
    return sp.map(
        {
            ADMIN_ROLE: make_role(ADMIN_ROLE, administrators),
            CONTROLLER_ROLE: make_role(ADMIN_ROLE, controllers),
            MINTER_ROLE: make_role(ADMIN_ROLE, minters),
            BURNER_ROLE: make_role(ADMIN_ROLE, burners),
            PAUSER_ROLE: make_role(ADMIN_ROLE),
            VALIDATOR_ROLE: make_role(ADMIN_ROLE, validators)
        },
        tkey=sp.TNat, 
        tvalue=sp.TRecord(
            role_admin=sp.TNat,
            members=sp.TSet(t=sp.TAddress)
        )
    )
예제 #28
0
 def add_pool(self, cryptos):
     # adds exchange request to the tezos open pool
     
     sp.verify(sp.amount > sp.tez(1), 'A minimum of 1 XTZ!')
     
     self.assert_crypto(cryptos.keys())
     
     self.data.open_pool[self.data.pool_counter] = sp.record(
         cryptos = cryptos,
         amount = sp.amount,
         timestamp = sp.now,
         timelock = sp.now.add_days(self.data.min_lock),
         dips = sp.map()
     )
     
     self.data.pool_counter = self.data.pool_counter + sp.nat(1)
예제 #29
0
    def mint(self, params):
        sp.verify(sp.sender == self.data.administrator)
        user = LedgerKey.make(params.address, params.token_id)

        self.data.ledger[user] = self.data.ledger.get(user, 0) + params.amount

        sp.if ~self.data.token_metadata.contains(params.token_id):
            token_metadata = sp.record(
                token_id=params.token_id,
                symbol=params.symbol,
                name=params.name,
                decimals=params.decimals,
                extras=sp.map()
            )
            TokenMetadata.set_type_and_layout(token_metadata)
            self.data.token_metadata[params.token_id] = token_metadata
예제 #30
0
 def __init__(self, admin):
     self.init(
         admin = admin, 
         uuid =0,
         adminBalance =sp.mutez(0),
         oracleAddress = sp.address("KT1NN7B3Wc5vb93wL87Fsu1HJepLkCU5JRHM"),
         # amount in mutez
         betSize = sp.map({5:5000000,10:3000000,15:1000000}),
         earnedAmount = 0,
         tempData = sp.map(tkey=sp.TNat,tvalue=sp.TRecord(seed=sp.TNat,betType=sp.TNat,sender=sp.TAddress)),
         tempCompleteBetData = sp.map(tkey=sp.TNat,tvalue=sp.TRecord(betType=sp.TNat,betId=sp.TNat)),
         # yields are multiplied by 100 to support 2 decimal places
         yields = sp.map({5:50,10:75,15:100}),
         betData = sp.map({
         5:sp.map(tkey=sp.TNat,tvalue= sp.TRecord(seed=sp.TNat,senderList=sp.TList(sp.TAddress))),
         10:sp.map(tkey=sp.TNat,tvalue= sp.TRecord(seed=sp.TNat,senderList=sp.TList(sp.TAddress))),
         15:sp.map(tkey=sp.TNat,tvalue= sp.TRecord(seed=sp.TNat,senderList=sp.TList(sp.TAddress)))
         })
         )