Beispiel #1
0
 def __init__(self, from_address, symbol, amount):
     dict.__init__(
         self,
         amount=VarInt(amount),
         symbol=String(symbol)
     )
     self['from'] = Address(from_address)
Beispiel #2
0
 def __init__(self, proposal_id, voter, option):
     dict.__init__(
         self,
         proposal_id=StringVarInt(proposal_id),
         voter=Address(voter),
         option=VoteOption(option)
     )
Beispiel #3
0
 def __init__(self, from_address, proposal_id, base_asset_symbol,
              quote_asset_symbol, init_price):
     dict.__init__(self,
                   proposal_id=VarInt(proposal_id),
                   base_asset_symbol=String(base_asset_symbol),
                   quote_asset_symbol=String(quote_asset_symbol),
                   init_price=VarInt(init_price))
     self['from'] = Address(from_address)
Beispiel #4
0
 def __init__(self, from_address, name, symbol, total_supply, mintable):
     dict.__init__(
         self,
         name=String(name),
         symbol=String(symbol),
         total_supply=VarInt(total_supply),
         mintable=bool(mintable))
     self['from'] = Address(from_address)
Beispiel #5
0
 def encode(self, field_id=None):
     buf = self.object_id()
     buf += Address(self['from']).encode(1)
     buf += String(self['symbol']).encode(2)
     buf += VarInt(self['amount']).encode(3)
     if field_id is None:
         return buf
     else:
         return make_prefix(field_id, 2) + VarInt(len(buf)).encode() + buf
Beispiel #6
0
 def __init__(self, from_address, time_lock_id, description, amount, lock_time):
     dict.__init__(
         self,
         time_lock_id=VarInt(time_lock_id),
         description=String(description),
         amount=Repeated(amount),
         lock_time=VarInt(lock_time)
     )
     self['from'] = Address(from_address)
Beispiel #7
0
 def from_msg_obj(timelock_data):
     coins = []
     for amount in timelock_data['amount']:
         coins.append(Token(VarInt(amount['amount']), amount['denom']))
     return TimeLock(
         Address(timelock_data['from']),
         String(timelock_data.get('description', '')),
         Repeated(coins),
         VarInt(timelock_data['lock_time'])
     )
Beispiel #8
0
 def __init__(self, title, description, proposal_type, proposer, initial_deposit, voting_period):
     dict.__init__(
         self,
         title=String(title),
         description=String(description),
         proposal_type=String(proposal_type),
         proposer=Address(proposer),
         initial_deposit=initial_deposit,
         voting_period=StringVarInt(voting_period)
     )
Beispiel #9
0
 def __init__(self, sender, order_id, symbol, ordertype, side, price,
              quantity, timeinforce):
     dict.__init__(self,
                   sender=Address(sender),
                   symbol=String(symbol),
                   ordertype=VarInt(ordertype),
                   side=VarInt(side),
                   price=VarInt(price),
                   quantity=VarInt(quantity),
                   timeinforce=VarInt(timeinforce))
     self['id'] = String(order_id)
Beispiel #10
0
 def decode(data, field_id=None):
     if field_id is not None:
         prefix = make_prefix(field_id, 2)
         for i in range(len(prefix)):
             if prefix[i] != data[i]:
                 return None, data
         data = data[len(field_id):]
     from_address, data = Address.decode(data, 1)
     symbol, data = String.decode(data, 2)
     amount, data = VarInt.decode(data, 3)
     return Mint(from_address, symbol, amount)
Beispiel #11
0
 def decode(klass, data, field_id=None):
     if field_id is not None:
         prefix = make_prefix(field_id, 2)
         for i in range(len(prefix)):
             if prefix[i] != data[i]:
                 return None, data
         data = data[len(field_id):]
     assert data[0:4] == klass.object_id()
     data = data[4:]
     from_address, data = Address.decode(data, 1)
     symbol, data = String.decode(data, 2)
     amount, data = VarInt.decode(data, 3)
     return klass(from_address, symbol, amount), data
Beispiel #12
0
 def decode(data, field_id=None):
     if field_id is not None:
         prefix = make_prefix(field_id, 2)
         for i in range(len(prefix)):
             if prefix[i] != data[i]:
                 return None, data
         data = data[len(field_id):]
     assert data[0:4] == Proposal.object_id()
     data = data[4:]
     title, data = String.decode(data, 1)
     description, data = String.decode(data, 2)
     proposal_type, data = VarInt.decode(data, 3)
     proposer, data = Address.decode(data, 4)
     initial_deposit, data = Repeated.decode(data, 5, Token)
     voting_period, data = StringVarInt.decode(data, 6)
     return Proposal(title, description, proposal_type, proposer, initial_deposit, voting_period)
Beispiel #13
0
 def decode(data, field_id=None):
     if field_id is not None:
         prefix = make_prefix(field_id, 2)
         for i in range(len(prefix)):
             if prefix[i] != data[i]:
                 return None, data
         data = data[len(field_id):]
     assert data[0:4] == DexList.object_id()
     data = data[4:]
     from_address, data = Address.decode(data, 1)
     proposal_id, data = VarInt.decode(data, 2)
     base_asset_symbol, data = String.decode(data, 3)
     quote_asset_symbol, data = String.decode(data, 4)
     init_price, data = VarInt.decode(data, 5)
     return DexList(from_address, proposal_id, base_asset_symbol,
                    quote_asset_symbol, init_price)
Beispiel #14
0
 def decode(data, field_id=None, hrp='bnb'):
     if field_id is not None:
         prefix = make_prefix(field_id, 2)
         for i in range(len(prefix)):
             if prefix[i] != data[i]:
                 return None, data
         data = data[len(field_id):]
     assert data[0:4] == Issue.object_id()
     data = data[4:]
     address, data = Address.decode(data, 1, hrp)
     name, data = String.decode(data, 2)
     symbol, data = String.decode(data, 3)
     total_supply, data = VarInt.decode(data, 4)
     mintable, data = Bool.decode(data, 5)
     mintable = True if mintable else 0
     return Issue(address, name, symbol, total_supply, mintable), data
Beispiel #15
0
 def from_msg_obj(vote_data):
     return Vote(
         StringVarInt(vote_data['proposal_id']),
         Address(vote_data['voter']),
         VoteOption(vote_data['option'])
     )
Beispiel #16
0
 def from_msg_obj(cancel_data):
     return CancelOrder(Address(cancel_data['sender']),
                        String(cancel_data['symbol']),
                        String(cancel_data['refid']))
Beispiel #17
0
 def __init__(self, from_address, time_lock_id):
     dict.__init__(
         self,
         time_lock_id=VarInt(time_lock_id)
     )
     self['from'] = Address(from_address)