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)
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)
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) )
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)
def __init__(self, from_address, symbol, amount): dict.__init__( self, amount=VarInt(amount), symbol=String(symbol) ) self['from'] = Address(from_address)
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
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
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
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']) )
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'] )
def test_decode_str(): for val in ["", "TrueUSD"]: encoded = String(val).encode() decoded, remaining = String.decode(encoded) assert decoded == val assert remaining == b''
def chain_id(): return String("Binance-Chain-Tigris")
def chain_id(): return String("Binance-Chain-Nile")
def from_msg_obj(cancel_data): return CancelOrder(Address(cancel_data['sender']), String(cancel_data['symbol']), String(cancel_data['refid']))