def map_candidate(candidate): return { 'address': to_none_if_empty(candidate.address), 'votes': string_utils.base64_string(candidate.votes), 'pub_key': string_utils.base64_string(candidate.pubKey), 'reward_address': to_none_if_empty(candidate.rewardAddress) }
def map_candidate_update(action): candidate_update = action.core.candidateUpdate return { 'action_type': 'candidate_update', 'candidate_update': { 'name': candidate_update.name, 'operator_address': to_none_if_empty(candidate_update.operatorAddress), 'reward_address': to_none_if_empty(candidate_update.rewardAddress), } }
def map_candidate_register(action): candidate_register = action.core.candidateRegister return { 'action_type': 'candidate_register', 'candidate_register': { 'name': candidate_register.candidate.name, 'operator_address': to_none_if_empty(candidate_register.candidate.operatorAddress), 'reward_address': to_none_if_empty(candidate_register.candidate.rewardAddress), 'staked_amount': to_int(candidate_register.stakedAmount), 'staked_duration': candidate_register.stakedDuration, 'auto_stake': candidate_register.autoStake, 'owner_address': to_none_if_empty(candidate_register.ownerAddress), 'payload': string_utils.base64_string(candidate_register.payload), } }
def map_transaction_logs(raw_block, block_transaction_log): for log in block_transaction_log.transactionLogs.logs: for index, transaction in enumerate(log.transactions): yield { 'type': 'transaction_log', 'transaction_log_type': transaction.type, 'height': block_transaction_log.blockIdentifier.height, 'action_hash': log.actionHash.hex(), 'index': index, 'topic': string_utils.base64_string(transaction.topic), 'amount': string_utils.to_int(transaction.amount), 'sender': to_none_if_empty(transaction.sender), 'recipient': to_none_if_empty(transaction.recipient), 'timestamp': raw_block.block.header.core.timestamp.ToJsonString(), }
def map_terminate_plum_chain(action): terminate_plum_chain = action.core.terminatePlumChain return { 'action_type': 'terminate_plum_chain', 'terminate_plum_chain': { 'sub_chain_address': to_none_if_empty(terminate_plum_chain.subChainAddress) } }
def map_receipt(receipt): return { 'status': receipt.status, 'height': receipt.blkHeight, 'hash': receipt.actHash.hex(), 'gas_consumed': to_int(receipt.gasConsumed), 'contract_address': to_none_if_empty(receipt.contractAddress) }
def map_plum_finalize_exit(action): plum_finalize_exit = action.core.finalizeExit return { 'action_type': 'plum_finalize_exit', 'plum_finalize_exit': { 'sub_chain_address': to_none_if_empty(plum_finalize_exit.subChainAddress), 'coin_id': plum_finalize_exit.coinID, } }
def map_stake_transfer_ownership(action): stake_transfer_ownership = action.core.stakeTransferOwnership return { 'action_type': 'stake_transfer_ownership', 'stake_transfer_ownership': { 'bucket_index': stake_transfer_ownership.bucketIndex, 'voter_address': to_none_if_empty(stake_transfer_ownership.voterAddress), 'payload': string_utils.base64_string(stake_transfer_ownership.payload), } }
def map_plum_create_deposit(action): plum_create_deposit = action.core.plumCreateDeposit return { 'action_type': 'plum_create_deposit', 'plum_create_deposit': { 'sub_chain_address': to_none_if_empty(plum_create_deposit.subChainAddress), 'amount': to_int(plum_create_deposit.amount), 'recipient': plum_create_deposit.recipient, } }
def map_put_block(action): put_block = action.core.putBlock return { 'action_type': 'put_block', 'put_block': { 'sub_chain_address': to_none_if_empty(put_block.subChainAddress), 'height': put_block.height, 'roots': [{'name': root.name, 'value': string_utils.base64_string(root.value)} for root in put_block.roots] } }
def map_stop_sub_chain(action): stop_sub_chain = action.core.stopSubChain return { 'action_type': 'stop_sub_chain', 'stop_sub_chain': { 'chain_id': stop_sub_chain.chainID, 'stop_height': stop_sub_chain.stopHeight, 'sub_chain_address': to_none_if_empty(stop_sub_chain.subChainAddress) } }
def map_transfer(action): transfer = action.core.transfer return { 'action_type': 'transfer', 'transfer': { 'amount': to_int(transfer.amount), 'recipient': to_none_if_empty(transfer.recipient), 'payload': string_utils.base64_string(transfer.payload), } }
def map_plum_put_block(action): plum_put_block = action.core.plumPutBlock return { 'action_type': 'plum_put_block', 'plum_put_block': { 'sub_chain_address': to_none_if_empty(plum_put_block.subChainAddress), 'height': plum_put_block.height, 'roots': [{'name': name, 'value': string_utils.base64_string(value)} for name, value in plum_put_block.roots.items()], } }
def map_plum_challenge_exit(action): plum_challenge_exit = action.core.plumChallengeExit return { 'action_type': 'plum_challenge_exit', 'plum_challenge_exit': { 'sub_chain_address': to_none_if_empty(plum_challenge_exit.subChainAddress), 'coin_id': plum_challenge_exit.coinID, 'challenge_transfer': string_utils.base64_string(plum_challenge_exit.challengeTransfer), 'challenge_transfer_block_proof': string_utils.base64_string( plum_challenge_exit.challengeTransferBlockProof), 'challenge_transfer_block_height': plum_challenge_exit.challengeTransferBlockHeight, } }
def map_plum_start_exit(action): plum_start_exit = action.core.plumStartExit return { 'action_type': 'plum_start_exit', 'plum_start_exit': { 'sub_chain_address': to_none_if_empty(plum_start_exit.subChainAddress), 'previous_transfer': string_utils.base64_string(plum_start_exit.previousTransfer), 'previous_transfer_block_proof': string_utils.base64_string(plum_start_exit.previousTransferBlockProof), 'previous_transfer_block_height': plum_start_exit.previousTransferBlockHeight, 'exit_transfer': string_utils.base64_string(plum_start_exit.exitTransfer), 'exit_transfer_block_proof': string_utils.base64_string(plum_start_exit.exitTransferBlockProof), 'exit_transfer_block_height': plum_start_exit.exitTransferBlockHeight, } }