def __init__(self): self.init( auctions=sp.big_map(tkey=sp.TNat, tvalue = Auction.get_type()), token_royalties=sp.big_map( tkey=LedgerKey.get_type(), tvalue=Royalty.get_type()), accumulated_royalties = sp.big_map(tkey=sp.TAddress, tvalue=sp.TMutez) )
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)) )
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) }))
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() )
def __init__(self,tijoriadmin): self.init( admin=tijoriadmin, projecttoken=sp.address("KT1GuH9jvwcWjkx2M8RzUQw2JgQgUPnkdEUh"), DAO_id=0, project_id=0, proposal_id=0, addDAOdata = sp.big_map( tkey = sp.TInt, tvalue = sp.TRecord( serialno=sp.TInt, admin=sp.TAddress, strength= sp.TInt, maxtoken=sp.TInt, min_contribution=sp.TMutez, winproposalid=sp.TInt, winprojectid=sp.TInt, maxmember=sp.TNat, currentcount=sp.TInt, disputevotecount=sp.TNat, proposedproposalid=sp.TInt, proposedprojectid=sp.TInt, disputestatus=sp.TInt, votestart=sp.TTimestamp, voteend=sp.TTimestamp, disputeend=sp.TTimestamp, rewardstatus=sp.TInt, contri= sp.TNat ) ), addmemberdata = sp.big_map( tkey = sp.TAddress, tvalue = sp.TRecord( tokenbalance=sp.TInt, contribution=sp.TMutez, DAO= sp.TInt ) ), addprojectdata = sp.big_map( tkey = sp.TInt, tvalue = sp.TRecord( serialno=sp.TInt, proowner=sp.TAddress, vote = sp.TInt, DAO = sp.TInt, cat=sp.TInt ) ), addpropoasldata = sp.big_map( tkey = sp.TInt, tvalue = sp.TRecord( proposer=sp.TAddress, cat=sp.TInt, serialno=sp.TInt, vote = sp.TInt, DAO = sp.TInt ) ) )
def __init__(self, initial_auction_house_address): self.init( initial_auction_house_address = initial_auction_house_address, ledger = sp.big_map(tkey=LedgerKey.get_type(), tvalue=sp.TNat), token_metadata = sp.bytes('0x697066733a2f2f516d5477794e383547667a6942354247684632454c6f67654a527436437765765a5937323962616851714b486944'), total_supply=sp.big_map(tkey=sp.TNat, tvalue = sp.TNat), allowances = sp.big_map(tkey=AllowanceKey.get_type(), tvalue=sp.TBool) )
def __init__(self, administrator): self.init( ledger=sp.big_map(tvalue=sp.TNat), nonces=sp.big_map(tvalue=sp.TNat), token_metadata=sp.big_map(tvalue=TokenMetadata.get_type()), administrator=administrator, proposed_administrator=administrator )
def get_init_storage(self): """Returns the initial storage of the contract""" return dict( ledger = sp.big_map(tkey=LedgerKey.get_type(), tvalue=sp.TNat), token_metadata = sp.big_map(tkey=sp.TNat, tvalue = TokenMetadata.get_type()), total_supply = sp.big_map(tkey=sp.TNat, tvalue = sp.TNat), operators = sp.big_map(tkey=OperatorKey.get_type(), tvalue = sp.TBool) )
def __init__(self, initial_auction_house_address, minter): self.init( initial_auction_house_address = initial_auction_house_address, ledger = sp.big_map(tkey=LedgerKey.get_type(), tvalue=sp.TNat), token_metadata = sp.big_map(tkey=sp.TNat, tvalue=TokenMetadata.get_type()), total_supply=sp.big_map(tkey=sp.TNat, tvalue=sp.TNat), allowances = sp.big_map(tkey=AllowanceKey.get_type(), tvalue=sp.TBool), minter = minter, token_royalties = sp.big_map(tkey=sp.TNat, tvalue=sp.TUnit), )
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 ) ) )
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 )
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({}))
def __init__(self, _name, _symbol, _admin): self.init( name = _name, symbol = _symbol, admin = _admin, tokensMinted = sp.set( t= sp.TString), tokenHolderToID = sp.big_map(tkey = sp.TAddress, tvalue = sp.TSet(sp.TString)), ownerToBalance = sp.big_map(tkey = sp.TAddress, tvalue = sp.TInt), tokenIdToOwner = sp.big_map(tkey = sp.TString, tvalue = sp.TAddress), tokenApprovals = sp.big_map(tkey = sp.TString, tvalue = sp.TAddress), )
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 __init__(self, big_map_first, big_map_second): self.init( big_map_first = sp.big_map( tkey = sp.TString, tvalue = sp.TInt, l = big_map_first ), big_map_second = sp.big_map( tkey = sp.TString, tvalue = sp.TString, l = big_map_second ) )
def __init__( self, assetCodes=["XTZ-USD", "BTC-USD"], oracleContractAddress=sp.address( "KT1QLPABNCD4z1cSYVv3ntYDYgtWTed7LkYr"), numDataPoints=sp.int(3) ): # Set last update timestamp to unix epoch. lastUpdateTime = sp.timestamp(0) initialValues = {} for assetCode in assetCodes: # Populate the queues with an initial zero elements pricesQueue = fifoDT() volumesQueue = fifoDT() assetRecord = sp.record( prices= pricesQueue, volumes= volumesQueue, lastUpdateTime= lastUpdateTime, computedPrice= 0 ) initialValues[assetCode] = assetRecord assetMap = sp.big_map( l=initialValues, ) self.init( assetMap=assetMap, assetCodes=assetCodes, oracleContract=oracleContractAddress, numDataPoints=numDataPoints )
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 )
def __init__(self, objkt, hdao, manager, metadata, curate): self.fee = 0 self.amount = 0 self.royalties = 0 self.init( swaps = sp.big_map(tkey=sp.TNat, tvalue=sp.TRecord(issuer=sp.TAddress, xtz_per_objkt=sp.TMutez, objkt_id=sp.TNat, objkt_amount=sp.TNat)), royalties = sp.big_map(tkey=sp.TNat, tvalue=sp.TRecord(issuer=sp.TAddress, royalties=sp.TNat)), swap_id = 0, objkt_id = 152, objkt = objkt, hdao = hdao, manager = manager, metadata = metadata, genesis = sp.timestamp(0), curate = curate, locked = False )
def __init__(self, admin, token_contract, token_address = None, min_timeout_minutes = 5, min_amount = 0): self.token_contract = token_contract if token_address is None: token_address = token_contract.address self.init(admin = admin, active = True, min_timeout_minutes = min_timeout_minutes, min_amount = min_amount, token = token_address, next_id = 0, requests = sp.big_map(tkey = sp.TNat, tvalue = request_type.with_fields(client = sp.TAddress)), reverse_requests = sp.big_map(tkey = sp.TRecord(client = sp.TAddress, client_request_id = sp.TNat), tvalue = sp.TNat) )
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.pair(0, self.normalize_metadata(metadata)) }) )
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)
def __init__(self, objkt, ung, manager, metadata): self.init( swaps = sp.big_map(tkey=sp.TNat, tvalue=sp.TRecord(issuer=sp.TAddress, ung_per_objkt=sp.TNat, objkt_id=sp.TNat, objkt_amount=sp.TNat)), swap_id = 0, objkt_id = 0, objkt = objkt, ung = ung, manager = manager, balance = sp.tez(0), metadata = metadata )
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 )
def __init__(self, _registry): self.init( receivedNames = sp.big_map( tkey = sp.TString, tvalue = sp.TRecord( name = sp.TString, owner = sp.TAddress, resolver = sp.TAddress, registeredAt = sp.TTimestamp, registrationPeriod = sp.TInt, modified = sp.TBool)), registry = _registry)
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)) ) )
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)) )
def __init__(self, initOwners): # Owners are locked at initialization in this iteration # Future iterations could have dynamic owners self.init( owners=sp.set(initOwners), numOwners=sp.len(initOwners), locked=False, closed=False, lock_votes=sp.set([], sp.TAddress), close_votes=sp.set([], sp.TAddress), total_contributed=sp.mutez(0), total_liquidated=sp.mutez(0), liquidated_ledger=sp.big_map({}, sp.TAddress, sp.TMutez), equity=sp.big_map({}, sp.TAddress, sp.TMutez), buy_proposals=sp.big_map({}, sp.TNat, sp.TRecord(votes=sp.TSet(sp.TAddress), passed=sp.TBool)), swap_proposals=sp.big_map({}), cancel_swap_proposals=sp.big_map({}, sp.TNat, sp.TRecord(votes=sp.TSet(sp.TAddress), passed=sp.TBool)), swap_proposal_id=0, # Used for collect/swap/cancel_swap hen_address = sp.address("KT1HbQepzV1nVGg8QVznG7z4RcHseD5kwqBn"), # Used for update_operators hen_nft_address = sp.address("KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton") )
def __init__(self, discountSchedule, duration, interval, baker, issuer): self.init( discountSchedule = discountSchedule, startTime = sp.timestamp_from_utc_now(), duration = duration, interval = interval, baker = baker, totalSupply = 0, availableSupply = 0, administrator = issuer, availableXTZCollateral = 0, lockedXTZAmount = 0, balances = sp.big_map() )
def __init__(self, feeRate: sp.TNat, tokenAddress: sp.TAddress, factoryAddress: sp.TAddress, delegated: sp.TKeyHash): self.init( feeRate=sp.nat(feeRate), tezPool=sp.mutez(0), tokenPool=sp.nat(0), invariant=sp.mutez(0), totalShares=sp.nat(0), tokenAddress=tokenAddress, factoryAddress=factoryAddress, # sp.TAddress, sp.TNat shares=sp.big_map(tkey=sp.TAddress, tvalue=sp.TNat), # sp.TAddress, sp.TKeyHash candidates=sp.big_map(tkey=sp.TAddress, tvalue=sp.TKeyHash), # sp.TKeyHash, sp.TNat votes=sp.big_map(tkey=sp.TKeyHash, tvalue=sp.TNat), delegated=delegated, address=tokenAddress ) self.data.address = sp.to_address(sp.self)
def __init__(self, token, oracle, fortune_job_id, admin): self.init(admin = admin, oracle = oracle, token = token, fortune = '', next_request_id = 1, waiting_fortune_id = sp.none, fortune_job_id = fortune_job_id, totalTokens = 0, depositBalances = sp.big_map( tkey = sp.TString, tvalue = sp.TNat ), withdrawBalances = sp.big_map( tkey = sp.TAddress, tvalue = sp.TInt ), client_requests = sp.big_map( tkey = sp.TNat, tvalue = sp.TAddress ) )