From 8be43726e69cbf0bd8b05e8f2c7806b40c74aa5e Mon Sep 17 00:00:00 2001 From: Will Qiu Date: Thu, 23 Apr 2020 15:13:21 +0800 Subject: [PATCH] transaction with deploy info --- rchain/client.py | 10 +++++++--- rchain/report.py | 9 +++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/rchain/client.py b/rchain/client.py index b825b0d..4403576 100644 --- a/rchain/client.py +++ b/rchain/client.py @@ -24,7 +24,7 @@ from .pb.ProposeServiceV1_pb2 import ProposeResponse from .pb.ProposeServiceV1_pb2_grpc import ProposeServiceStub from .pb.RhoTypes_pb2 import Expr, GDeployId, GUnforgeable, Par -from .report import Report, Transaction +from .report import Report, Transaction, DeployWithTransaction from .util import create_deploy_data GRPC_Response_T = Union[ProposeResponse, @@ -202,7 +202,7 @@ def get_event_data(self, block_hash: str) -> EventInfoResponse: self._check_response(response) return response - def get_transaction(self, block_hash: str) -> List[Transaction]: + def get_transaction(self, block_hash: str) -> List[DeployWithTransaction]: if self.param is None: raise ValueError("You haven't install your network param.") transactions = [] @@ -219,7 +219,11 @@ def get_transaction(self, block_hash: str) -> List[Transaction]: user = deploy.report[1] refund = deploy.report[2] report = Report(precharge, user, refund) - transactions.extend(find_transfer_comm(report.user, self.param.transfer_unforgeable)) + transactions.append( + DeployWithTransaction( + deploy.deployInfo, + find_transfer_comm(report.user, self.param.transfer_unforgeable)) + ) return transactions diff --git a/rchain/report.py b/rchain/report.py index 4ec8691..401787a 100644 --- a/rchain/report.py +++ b/rchain/report.py @@ -1,7 +1,7 @@ from dataclasses import dataclass -from typing import Optional, Tuple +from typing import Optional, Tuple, List -from .pb.DeployServiceCommon_pb2 import SingleReport +from .pb.DeployServiceCommon_pb2 import SingleReport, DeployInfo from .pb.RhoTypes_pb2 import Par, ParWithRandom @@ -18,3 +18,8 @@ class Transaction: amount: int ret_unforgeable: Par success: Optional[Tuple[bool, str]] + +@dataclass +class DeployWithTransaction: + deploy_info: DeployInfo + transactions: List[Transaction]