Esempio n. 1
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)
Esempio n. 2
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)
Esempio n. 3
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)
     )
Esempio n. 4
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)
Esempio n. 5
0
 def __init__(self, from_address, symbol, amount):
     dict.__init__(
         self,
         amount=VarInt(amount),
         symbol=String(symbol)
     )
     self['from'] = Address(from_address)
Esempio n. 6
0
 def __init__(self, from_address, description, amount, lock_time):
     dict.__init__(
         self,
         description=String(description),
         amount=Repeated(amount),
         lock_time=VarInt(lock_time)
     )
     self['from'] = from_address
Esempio n. 7
0
 def from_obj(klass, transaction_data):
     tx = klass(StringVarInt(transaction_data['account_number']),
                StringVarInt(transaction_data['sequence']),
                StringVarInt(transaction_data.get('source', 0)))
     tx['memo'] = String(transaction_data['memo'])
     for msg in transaction_data['msgs']:
         tx.add_msg(Msg.from_msg_obj(msg))
     return tx
Esempio n. 8
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
Esempio n. 9
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'])
     )
Esempio n. 10
0
 def from_msg_obj(timerelock_data):
     amounts = []
     for amount in timerelock_data['amount']:
         amounts.append(Token(VarInt(amount['amount']), String(amount['denom'])))
     return TimeRelock(
         timerelock_data['from'],
         timerelock_data['time_lock_id'],
         timerelock_data['description'],
         amounts,
         timerelock_data['lock_time']
     )
Esempio n. 11
0
def test_decode_str():
    for val in ["", "TrueUSD"]:
        encoded = String(val).encode()
        decoded, remaining = String.decode(encoded)
        assert decoded == val
        assert remaining == b''
Esempio n. 12
0
 def chain_id():
     return String("Binance-Chain-Tigris")
Esempio n. 13
0
 def chain_id():
     return String("Binance-Chain-Nile")
Esempio n. 14
0
 def from_msg_obj(cancel_data):
     return CancelOrder(Address(cancel_data['sender']),
                        String(cancel_data['symbol']),
                        String(cancel_data['refid']))