Skip to content

Commit

Permalink
Merge pull request hyperledger-archives#1773 from KitHat/rc
Browse files Browse the repository at this point in the history
Fix inner types in libindy
  • Loading branch information
Artemkaaas authored Jul 31, 2019
2 parents e61f73f + 4b29c26 commit a583838
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion libindy/src/api/payments_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub extern fn indy_build_get_payment_sources_with_from_request(command_handle: C
check_useful_c_str!(payment_address, ErrorCode::CommonInvalidParam4);
check_useful_c_callback!(cb, ErrorCode::CommonInvalidParam5);

let from: Option<u64> = if from == -1 { None } else { Some(from as u64) };
let from: Option<i64> = if from == -1 { None } else { Some(from) };

trace!("indy_build_get_payment_sources_with_from_request: entities >>> wallet_handle: {:?}, submitter_did: {:?}, payment_address: {:?}, from: {:?}", wallet_handle, submitter_did, payment_address, from);

Expand Down
4 changes: 2 additions & 2 deletions libindy/src/commands/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub enum PaymentsCommand {
WalletHandle,
Option<String>, //submitter did
String, //payment address
Option<u64>, //from
Option<i64>, //from
Box<Fn(IndyResult<(String, String)>) + Send>),
BuildGetPaymentSourcesRequestAck(
i32, //handle
Expand Down Expand Up @@ -447,7 +447,7 @@ impl PaymentsCommandExecutor {
trace!("parse_response_with_fees_ack <<<");
}

fn build_get_payment_sources_request(&self, wallet_handle: WalletHandle, submitter_did: Option<&str>, payment_address: &str, next: Option<u64>, cb: Box<Fn(IndyResult<(String, String)>) + Send>) {
fn build_get_payment_sources_request(&self, wallet_handle: WalletHandle, submitter_did: Option<&str>, payment_address: &str, next: Option<i64>, cb: Box<Fn(IndyResult<(String, String)>) + Send>) {
trace!("build_get_payment_sources_request >>> wallet_handle: {:?}, submitter_did: {:?}, payment_address: {:?}", wallet_handle, submitter_did, payment_address);
if let Some(did) = submitter_did {
match self.crypto_service.validate_did(did).map_err(map_err_err!()) {
Expand Down
4 changes: 2 additions & 2 deletions libindy/src/services/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl PaymentsService {
res
}

pub fn build_get_payment_sources_request(&self, cmd_handle: i32, type_: &str, wallet_handle: WalletHandle, submitter_did: Option<&str>, address: &str, next: Option<u64>) -> IndyResult<()> {
pub fn build_get_payment_sources_request(&self, cmd_handle: i32, type_: &str, wallet_handle: WalletHandle, submitter_did: Option<&str>, address: &str, next: Option<i64>) -> IndyResult<()> {
trace!("build_get_payment_sources_request >>> type_: {:?}, wallet_handle: {:?}, submitter_did: {:?}, address: {:?}", type_, wallet_handle, submitter_did, address);
let build_get_payment_sources_request: BuildGetPaymentSourcesRequestCB = self.methods.borrow().get(type_)
.ok_or(err_msg(IndyErrorKind::UnknownPaymentMethodType, format!("Unknown payment method {}", type_)))?.build_get_payment_sources_request;
Expand All @@ -158,7 +158,7 @@ impl PaymentsService {
wallet_handle,
submitter_did.as_ref().map(|s| s.as_ptr()).unwrap_or(null()),
address.as_ptr(),
next.map(|a| a as i64).unwrap_or(-1),
next.unwrap_or(-1),
cb);

let res = err.into();
Expand Down
4 changes: 2 additions & 2 deletions libindy/tests/utils/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ pub fn build_get_payment_sources_request(wallet_handle: i32, submitter_did: Opti
payments::build_get_payment_sources_request(wallet_handle, submitter_did, payment_address).wait()
}

pub fn build_get_payment_sources_with_from_request(wallet_handle: i32, submitter_did: Option<&str>, payment_address: &str, from: Option<u64>) -> Result<(String, String), IndyError> {
pub fn build_get_payment_sources_with_from_request(wallet_handle: i32, submitter_did: Option<&str>, payment_address: &str, from: Option<i64>) -> Result<(String, String), IndyError> {
payments::build_get_payment_sources_with_from_request(wallet_handle, submitter_did, payment_address, from).wait()
}

Expand All @@ -381,7 +381,7 @@ pub fn parse_get_payment_sources_response(payment_method: &str, resp_json: &str)
payments::parse_get_payment_sources_response(payment_method, resp_json).wait()
}

pub fn parse_get_payment_sources_with_from_response(payment_method: &str, resp_json: &str) -> Result<(String, Option<u64>), IndyError> {
pub fn parse_get_payment_sources_with_from_response(payment_method: &str, resp_json: &str) -> Result<(String, Option<i64>), IndyError> {
payments::parse_get_payment_sources_with_from_response(payment_method, resp_json).wait()
}

Expand Down
10 changes: 5 additions & 5 deletions wrappers/rust/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ fn _build_get_payment_sources_request(command_handle: CommandHandle, wallet_hand
/// # Returns
/// * `get_utxo_txn_json` - Indy request for getting UTXO list for payment address
/// * `payment_method`
pub fn build_get_payment_sources_with_from_request(wallet_handle: WalletHandle, submitter_did: Option<&str>, payment_address: &str, from: Option<u64>) -> Box<Future<Item=(String, String), Error=IndyError>> {
pub fn build_get_payment_sources_with_from_request(wallet_handle: WalletHandle, submitter_did: Option<&str>, payment_address: &str, from: Option<i64>) -> Box<Future<Item=(String, String), Error=IndyError>> {
let (receiver, command_handle, cb) =
ClosureHandler::cb_ec_string_string();

Expand All @@ -228,11 +228,11 @@ pub fn build_get_payment_sources_with_from_request(wallet_handle: WalletHandle,
ResultHandler::str_str(command_handle, err, receiver)
}

fn _build_get_payment_sources_with_from_request(command_handle: CommandHandle, wallet_handle: WalletHandle, submitter_did: Option<&str>, payment_address: &str, from: Option<u64>, cb: Option<ResponseStringStringCB>) -> ErrorCode {
fn _build_get_payment_sources_with_from_request(command_handle: CommandHandle, wallet_handle: WalletHandle, submitter_did: Option<&str>, payment_address: &str, from: Option<i64>, cb: Option<ResponseStringStringCB>) -> ErrorCode {
let submitter_did_str = opt_c_str!(submitter_did);
let payment_address = c_str!(payment_address);

ErrorCode::from(unsafe { payments::indy_build_get_payment_sources_with_from_request(command_handle, wallet_handle, opt_c_ptr!(submitter_did, submitter_did_str), payment_address.as_ptr(), from.map(|a| a as i64).unwrap_or(-1), cb) })
ErrorCode::from(unsafe { payments::indy_build_get_payment_sources_with_from_request(command_handle, wallet_handle, opt_c_ptr!(submitter_did, submitter_did_str), payment_address.as_ptr(), from.unwrap_or(-1), cb) })
}

/// Parses response for Indy request for getting UTXO list.
Expand Down Expand Up @@ -283,12 +283,12 @@ fn _parse_get_payment_sources_response(command_handle: CommandHandle, payment_me
/// extra: <str>, // optional data from payment transaction
/// }]
/// next -- pointer to the next slice of payment sources
pub fn parse_get_payment_sources_with_from_response(payment_method: &str, resp_json: &str) -> Box<Future<Item=(String, Option<u64>), Error=IndyError>> {
pub fn parse_get_payment_sources_with_from_response(payment_method: &str, resp_json: &str) -> Box<Future<Item=(String, Option<i64>), Error=IndyError>> {
let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string_i64();

let err = _parse_get_payment_sources_with_from_response(command_handle, payment_method, resp_json, cb);

Box::new(ResultHandler::str_i64(command_handle, err, receiver).map(|(s, i)| (s, if i >= 0 {Some(i as u64)} else {None})).into_future())
Box::new(ResultHandler::str_i64(command_handle, err, receiver).map(|(s, i)| (s, if i >= 0 {Some(i)} else {None})).into_future())
}

fn _parse_get_payment_sources_with_from_response(command_handle: CommandHandle, payment_method: &str, resp_json: &str, cb: Option<ResponseStringI64CB>) -> ErrorCode {
Expand Down

0 comments on commit a583838

Please sign in to comment.