From dc93c764f164f459ab37bb18282cee7250a27582 Mon Sep 17 00:00:00 2001 From: Nikita Khateev Date: Wed, 31 Jul 2019 15:02:46 +0300 Subject: [PATCH 1/5] Fix inner types in libindy Signed-off-by: Nikita Khateev --- libindy/src/api/payments_v2.rs | 2 +- libindy/src/commands/payments.rs | 4 ++-- libindy/src/services/payments.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libindy/src/api/payments_v2.rs b/libindy/src/api/payments_v2.rs index f2fba79c25..9de93ffd7f 100644 --- a/libindy/src/api/payments_v2.rs +++ b/libindy/src/api/payments_v2.rs @@ -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 = if from == -1 { None } else { Some(from as u64) }; + let from: Option = 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); diff --git a/libindy/src/commands/payments.rs b/libindy/src/commands/payments.rs index e682bf4b88..cd8dc06f5c 100644 --- a/libindy/src/commands/payments.rs +++ b/libindy/src/commands/payments.rs @@ -55,7 +55,7 @@ pub enum PaymentsCommand { WalletHandle, Option, //submitter did String, //payment address - Option, //from + Option, //from Box) + Send>), BuildGetPaymentSourcesRequestAck( i32, //handle @@ -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, cb: Box) + Send>) { + fn build_get_payment_sources_request(&self, wallet_handle: WalletHandle, submitter_did: Option<&str>, payment_address: &str, next: Option, cb: Box) + 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!()) { diff --git a/libindy/src/services/payments.rs b/libindy/src/services/payments.rs index 623606fe09..670824f6df 100644 --- a/libindy/src/services/payments.rs +++ b/libindy/src/services/payments.rs @@ -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) -> 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) -> 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; @@ -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(); From f4c2de3a06b3ae1707531079902886b3f95586d3 Mon Sep 17 00:00:00 2001 From: Nikita Khateev Date: Wed, 31 Jul 2019 15:10:25 +0300 Subject: [PATCH 2/5] Update rust wrapper Signed-off-by: Nikita Khateev --- wrappers/rust/src/payments.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wrappers/rust/src/payments.rs b/wrappers/rust/src/payments.rs index 31d1d770f9..b46bcc439c 100644 --- a/wrappers/rust/src/payments.rs +++ b/wrappers/rust/src/payments.rs @@ -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) -> Box> { +pub fn build_get_payment_sources_with_from_request(wallet_handle: WalletHandle, submitter_did: Option<&str>, payment_address: &str, from: Option) -> Box> { let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string_string(); @@ -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, cb: Option) -> ErrorCode { +fn _build_get_payment_sources_with_from_request(command_handle: CommandHandle, wallet_handle: WalletHandle, submitter_did: Option<&str>, payment_address: &str, from: Option, cb: Option) -> 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. From a9076af4f3ec967d99059a6a107afc0f6e72335f Mon Sep 17 00:00:00 2001 From: Nikita Khateev Date: Wed, 31 Jul 2019 15:18:36 +0300 Subject: [PATCH 3/5] Fix types Signed-off-by: Nikita Khateev --- libindy/src/api/payments_v2.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libindy/src/api/payments_v2.rs b/libindy/src/api/payments_v2.rs index 9de93ffd7f..b9ce1520f5 100644 --- a/libindy/src/api/payments_v2.rs +++ b/libindy/src/api/payments_v2.rs @@ -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 = if from == -1 { None } else { Some(from) }; + let from: Option = 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); From 7c77652337672093b7afc17e39cf9257033a9f30 Mon Sep 17 00:00:00 2001 From: Nikita Khateev Date: Wed, 31 Jul 2019 15:21:39 +0300 Subject: [PATCH 4/5] Fix types Signed-off-by: Nikita Khateev --- libindy/tests/utils/payments.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libindy/tests/utils/payments.rs b/libindy/tests/utils/payments.rs index abe7b67dde..2e4acfcce5 100644 --- a/libindy/tests/utils/payments.rs +++ b/libindy/tests/utils/payments.rs @@ -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) -> 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) -> Result<(String, String), IndyError> { payments::build_get_payment_sources_with_from_request(wallet_handle, submitter_did, payment_address, from).wait() } From 4b29c265c5d10e491325458bd065ca58be64cdb8 Mon Sep 17 00:00:00 2001 From: Nikita Khateev Date: Wed, 31 Jul 2019 15:37:18 +0300 Subject: [PATCH 5/5] Fix parse types Signed-off-by: Nikita Khateev --- libindy/tests/utils/payments.rs | 2 +- wrappers/rust/src/payments.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libindy/tests/utils/payments.rs b/libindy/tests/utils/payments.rs index 2e4acfcce5..1e42416b8d 100644 --- a/libindy/tests/utils/payments.rs +++ b/libindy/tests/utils/payments.rs @@ -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), IndyError> { +pub fn parse_get_payment_sources_with_from_response(payment_method: &str, resp_json: &str) -> Result<(String, Option), IndyError> { payments::parse_get_payment_sources_with_from_response(payment_method, resp_json).wait() } diff --git a/wrappers/rust/src/payments.rs b/wrappers/rust/src/payments.rs index b46bcc439c..9709b6248e 100644 --- a/wrappers/rust/src/payments.rs +++ b/wrappers/rust/src/payments.rs @@ -283,12 +283,12 @@ fn _parse_get_payment_sources_response(command_handle: CommandHandle, payment_me /// extra: , // 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), Error=IndyError>> { +pub fn parse_get_payment_sources_with_from_response(payment_method: &str, resp_json: &str) -> Box), 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) -> ErrorCode {