Esempio n. 1
0
 def __init__(self, account_number, sequence, source='887'):
     dict.__init__(self,
                   account_number=StringVarInt(account_number),
                   sequence=StringVarInt(sequence),
                   source=StringVarInt(source),
                   msgs=Repeated([]),
                   chain_id=self.chain_id(),
                   memo='',
                   signatures=Repeated([]),
                   data=None)
Esempio n. 2
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] == Send.object_id()
     data = data[4:]
     inputs, data = Repeated.decode(data, bytes([8 | 2]), Input)
     outputs, data = Repeated.decode(data, bytes([16 | 2]), Output)
     return Send(inputs, outputs), data
Esempio n. 3
0
 def from_msg_obj(proposal_data):
     initial_deposit = Repeated([])
     for deposit in proposal_data['initial_deposit']:
         initial_deposit.append(StringToken(deposit['amount'], deposit['denom'])),
     return Proposal(
         proposal_data['title'],
         proposal_data['description'],
         proposal_data['proposal_type'],
         proposal_data['proposer'],
         initial_deposit,
         proposal_data['voting_period']
     )
Esempio n. 4
0
 def decode(klass, data):
     assert data[0:4] == klass.object_id()
     data = data[4:]
     msgs, data = Repeated.decode(data, 1, Msg)
     signatures, data = Repeated.decode(data, 2, BnbSignature)
     memo, data = String.decode(data, 3)
     source, data = StringVarInt.decode(data, 4)
     tx_data, data = String.decode(data, 5)
     account_number = signatures[0]['account_number']
     sequence = signatures[0]['sequence']
     tx = klass(msgs, account_number, sequence, source)
     tx['msgs'] = msgs
     tx['signatures'] = signatures
     tx['chain_id'] = klass.chain_id()
     return tx, data
Esempio n. 5
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. 6
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. 7
0
 def from_msg_obj(send_data):
     inputs = Repeated([])
     outputs = Repeated([])
     for source in send_data['inputs']:
         coins = []
         for coin in source['coins']:
             coins.append(Token(coin['amount'], coin['denom']))
         inputs.append(Input(source['address'], coins))
     for source in send_data['outputs']:
         coins = []
         for coin in source['coins']:
             coins.append(Token(coin['amount'], coin['denom']))
         outputs.append(Output(source['address'], coins))
     return Send(inputs, outputs)
Esempio n. 8
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)
Esempio n. 9
0
 def remove_sig(self):
     self['signatures'] = Repeated([])