def _check_payment_op( operation: Operation, want_asset: str, want_amount: Decimal ) -> bool: # TODO: Add test cases! issuer = operation.asset.issuer code = operation.asset.code asset = settings.ASSETS.get(code, {}) return ( operation.type_code() == Xdr.const.PAYMENT and str(operation.destination) == asset.get("DISTRIBUTION_ACCOUNT_ADDRESS") and str(code) == want_asset and # TODO: Handle multiple possible asset issuance accounts str(issuer) == asset.get("ISSUER_ACCOUNT_ADDRESS") and Decimal(operation.amount) == want_amount )
def _cast_operation_and_result( cls, operation: Operation, op_result: Xdr.types.OperationResult ) -> Tuple[Optional[PaymentOp], Optional[PaymentOpResult]]: code = operation.type_code() op_xdr_obj = operation.to_xdr_object() if code == Xdr.const.PAYMENT: return ( Payment.from_xdr_object(op_xdr_obj), op_result.tr.paymentResult, ) elif code == Xdr.const.PATH_PAYMENT_STRICT_SEND: return ( PathPaymentStrictSend.from_xdr_object(op_xdr_obj), op_result.tr.pathPaymentStrictSendResult, ) elif code == Xdr.const.PATH_PAYMENT_STRICT_RECEIVE: return ( PathPaymentStrictReceive.from_xdr_object(op_xdr_obj), op_result.tr.pathPaymentStrictReceiveResult, ) else: return None, None
def _check_payment_op(operation: Operation, want_asset: Asset) -> bool: return (operation.type_code() == Xdr.const.PAYMENT and str( operation.destination) == want_asset.distribution_account and str(operation.asset.code) == want_asset.code and str(operation.asset.issuer) == want_asset.issuer)