def map_base_action(block, action): return { 'type': 'action', 'version': action.core.version, 'nonce': action.core.nonce, 'gas_limit': to_int(action.core.gasLimit), 'gas_price': to_int(action.core.gasPrice), 'sender': iotex_utils.pubkey_to_address(action.senderPubKey), 'timestamp': block.header.core.timestamp.ToJsonString() }
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_claim_from_rewarding_fund(action): claim_from_rewarding_fund = action.core.claimFromRewardingFund return { 'action_type': 'claim_from_rewarding_fund', 'claim_from_rewarding_fund': { 'amount': to_int(claim_from_rewarding_fund.amount), 'data': string_utils.base64_string(claim_from_rewarding_fund.data), } }
def map_deposit_to_rewarding_fund(action): deposit_to_rewarding_fund = action.core.depositToRewardingFund return { 'action_type': 'deposit_to_rewarding_fund', 'deposit_to_rewarding_fund': { 'amount': to_int(deposit_to_rewarding_fund.amount), 'data': string_utils.base64_string(deposit_to_rewarding_fund.data), } }
def map_stake_add_deposit(action): stake_add_deposit = action.core.stakeAddDeposit return { 'action_type': 'stake_add_deposit', 'stake_add_deposit': { 'bucket_index': stake_add_deposit.bucketIndex, 'amount': to_int(stake_add_deposit.amount), 'payload': string_utils.base64_string(stake_add_deposit.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_settle_deposit(action): settle_deposit = action.core.settleDeposit return { 'action_type': 'settle_deposit', 'settle_deposit': { 'amount': to_int(settle_deposit.amount), 'recipient': settle_deposit.recipient, 'index': settle_deposit.index } }
def map_create_deposit(action): create_deposit = action.core.createDeposit return { 'action_type': 'create_deposit', 'create_deposit': { 'chain_id': create_deposit.chainID, 'amount': to_int(create_deposit.amount), 'recipient': create_deposit.recipient, } }
def map_execution(action): execution = action.core.execution return { 'action_type': 'execution', 'execution': { 'amount': to_int(execution.amount), 'contract': execution.contract, 'data': string_utils.base64_string(execution.data), } }
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_stake_create(action): stake_create = action.core.stakeCreate return { 'action_type': 'stake_create', 'stake_create': { 'candidate_name': stake_create.candidateName, 'staked_amount': to_int(stake_create.stakedAmount), 'staked_duration': stake_create.stakedDuration, 'auto_stake': stake_create.autoStake, 'payload': string_utils.base64_string(stake_create.payload), } }
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(), }