Skip to content

Commit

Permalink
Remove vcx_get_proof_msg from libvcx
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Stas <patrik.stas@absa.africa>
  • Loading branch information
Patrik-Stas committed Mar 14, 2023
1 parent e849297 commit e79b011
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 144 deletions.
5 changes: 3 additions & 2 deletions agents/rust/aries-vcx-agent/src/services/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use aries_vcx::messages::protocols::proof_presentation::presentation::Presentati
use aries_vcx::messages::protocols::proof_presentation::presentation_proposal::PresentationProposal;
use aries_vcx::messages::status::Status;
use aries_vcx::protocols::proof_presentation::verifier::state_machine::VerifierState;
use aries_vcx::protocols::proof_presentation::verifier::verification_status::PresentationVerificationStatus;
use aries_vcx::protocols::SendClosure;

use super::connection::ServiceConnections;
Expand Down Expand Up @@ -72,9 +73,9 @@ impl ServiceVerifier {
)
}

pub fn get_presentation_status(&self, thread_id: &str) -> AgentResult<Status> {
pub fn get_presentation_status(&self, thread_id: &str) -> AgentResult<PresentationVerificationStatus> {
let VerifierWrapper { verifier, .. } = self.verifiers.get(thread_id)?;
Ok(verifier.get_presentation_status())
Ok(verifier.get_presentation_verification_status())
}

pub async fn verify_presentation(&self, thread_id: &str, presentation: Presentation) -> AgentResult<()> {
Expand Down
84 changes: 0 additions & 84 deletions libvcx/src/api_c/protocols/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,75 +627,6 @@ pub extern "C" fn vcx_proof_get_request_msg(
SUCCESS_ERR_CODE
}

/// Get Proof Msg
///
/// *Note* This replaces vcx_get_proof. You no longer need a connection handle.
/// #Params
/// command_handle: command handle to map callback to user context.
///
/// proof_handle: Proof handle that was provided during creation. Used to identify proof object
///
/// cb: Callback that provides Proof attributes and error status of sending the credential
///
/// #Returns
/// Error code as a u32
#[no_mangle]
pub extern "C" fn vcx_get_proof_msg(
command_handle: CommandHandle,
proof_handle: u32,
cb: Option<extern "C" fn(xcommand_handle: CommandHandle, err: u32, proof_state: u32, response_data: *const c_char)>,
) -> u32 {
info!("vcx_get_proof_msg >>>");

check_useful_c_callback!(cb, LibvcxErrorKind::InvalidOption);

let source_id = proof::get_source_id(proof_handle).unwrap_or_default();
trace!(
"vcx_get_proof_msg(command_handle: {}, proof_handle: {}) source_id: {}",
command_handle,
proof_handle,
source_id
);

execute_async::<BoxFuture<'static, Result<(), ()>>>(Box::pin(async move {
match proof::get_presentation_msg(proof_handle) {
Ok(proof_msg) => {
trace!(
"vcx_get_proof_cb(command_handle: {}, proof_handle: {}, rc: {}, proof: {}) source_id: {}",
command_handle,
proof_handle,
0,
proof_msg,
source_id
);
let msg = CStringUtils::string_to_cstring(proof_msg);
cb(
command_handle,
SUCCESS_ERR_CODE,
proof::get_presentation_verification_status(proof_handle).unwrap_or(0),
msg.as_ptr(),
);
}
Err(err) => {
set_current_error_vcx(&err);
error!(
"vcx_get_proof_cb(command_handle: {}, proof_handle: {}, rc: {}, proof: {}) source_id: {}",
command_handle, proof_handle, err, "null", source_id
);
cb(
command_handle,
err.into(),
proof::get_presentation_verification_status(proof_handle).unwrap_or(0),
ptr::null_mut(),
);
}
};
Ok(())
}));

SUCCESS_ERR_CODE
}

#[no_mangle]
pub extern "C" fn vcx_mark_presentation_request_msg_sent(
command_handle: CommandHandle,
Expand Down Expand Up @@ -977,21 +908,6 @@ mod tests {
assert_eq!(proof::get_state(proof_handle).unwrap(), VerifierState::Finished as u32);
}

#[test]
#[cfg(feature = "general_test")]
fn test_get_proof_fails_when_not_ready_with_proof() {
let _setup = SetupMocks::init();

let proof_handle = create_proof_util().unwrap();

let cb = return_types_u32::Return_U32_U32_STR::new().unwrap();
assert_eq!(
vcx_get_proof_msg(cb.command_handle, proof_handle, Some(cb.get_callback())),
SUCCESS_ERR_CODE
);
let _ = cb.receive(TimeoutUtils::some_medium()).is_err();
}

#[tokio::test]
#[cfg(feature = "general_test")]
async fn test_vcx_connection_get_state() {
Expand Down
2 changes: 1 addition & 1 deletion libvcx_core/src/api_vcx/api_handle/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde_json;
use aries_vcx::common::proofs::proof_request::PresentationRequestData;
use aries_vcx::handlers::proof_presentation::verifier::Verifier;
use aries_vcx::messages::a2a::A2AMessage;
use aries_vcx::protocols::proof_presentation::verifier::state_machine::PresentationVerificationStatus;
use aries_vcx::protocols::proof_presentation::verifier::verification_status::PresentationVerificationStatus;
use aries_vcx::protocols::SendClosure;

use crate::api_vcx::api_global::profile::get_main_profile;
Expand Down
17 changes: 0 additions & 17 deletions wrappers/ios/vcx/VcxAPI.m
Original file line number Diff line number Diff line change
Expand Up @@ -2228,23 +2228,6 @@ - (void)verifierProofSendRequest:(NSNumber *)proofHandle
});
}

- (void)verifierGetProofMessage:(NSNumber *)proofHandle
completion:(void (^)(NSError *, NSNumber *, NSString *))completion {

vcx_command_handle_t handle = [[VcxCallbacks sharedInstance] createCommandHandleFor:completion];

vcx_error_t ret = vcx_get_proof_msg(
handle,
proofHandle.unsignedIntValue,
&VcxWrapperCbResponseUnsignedIntAndString
);

checkErrorAndComplete(ret, handle, ^{
completion([NSError errorFromVcxError:ret], ERROR_RESPONSE_NUMBER, ERROR_RESPONSE_STRING);
});
}


- (void)verifierProofGetRequestMessage:(NSNumber *)proofHandle
completion:(void (^)(NSError *, NSString *))completion {

Expand Down
6 changes: 0 additions & 6 deletions wrappers/ios/vcx/include/libvcx.h
Original file line number Diff line number Diff line change
Expand Up @@ -759,12 +759,6 @@ vcx_error_t vcx_proof_send_request(
void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err)
);

vcx_error_t vcx_get_proof_msg(
vcx_command_handle_t command_handle,
vcx_proof_handle_t proof_handle,
void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, vcx_state_t proof_state, const char *response_data)
);

vcx_error_t vcx_proof_get_request_msg(
vcx_command_handle_t command_handle,
vcx_proof_handle_t proof_handle,
Expand Down
25 changes: 7 additions & 18 deletions wrappers/java/src/main/java/com/evernym/sdk/vcx/LibVcx.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,17 +317,6 @@ public interface API extends Library {
*/
public int vcx_proof_get_request_msg(int command_handle, int proof_handle, Callback cb);

/**
* Populate response_data with the latest proof offer received.
* Todo: This should be depricated, use vcx_get_proof_msg
*/
public int vcx_get_proof(int command_handle, int proof_handle, int connection_handle, Callback cb);

/**
* Populate response_data with the latest proof offer received.
*/
public int vcx_get_proof_msg(int command_handle, int proof_handle, Callback cb);

/**
* Set proof offer as accepted.
*/
Expand Down Expand Up @@ -615,13 +604,13 @@ public interface API extends Library {
/**
* OOB
*/

public int vcx_out_of_band_sender_create(int command_handle, String config, Callback cb);

public int vcx_out_of_band_receiver_create(int command_handle, String message, Callback cb);

public int vcx_out_of_band_sender_get_thread_id(int command_handle, int handle, Callback cb);

public int vcx_out_of_band_receiver_get_thread_id(int command_handle, int handle, Callback cb);

public int vcx_out_of_band_sender_append_message(int command_handle, int handle, String message, Callback cb);
Expand All @@ -639,17 +628,17 @@ public interface API extends Library {
public int vcx_out_of_band_receiver_build_connection(int command_handle, int handle, Callback cb);

public int vcx_out_of_band_sender_serialize(int command_handle, int handle, Callback cb);

public int vcx_out_of_band_receiver_serialize(int command_handle, int handle, Callback cb);

public int vcx_out_of_band_sender_deserialize(int command_handle, String oob_json, Callback cb);

public int vcx_out_of_band_receiver_deserialize(int command_handle, String oob_json, Callback cb);

public int vcx_out_of_band_sender_release(int command_handle);

public int vcx_out_of_band_receiver_release(int command_handle);

public int vcx_get_verkey_from_ledger(int command_handle, String did, Callback cb);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,6 @@ public static CompletableFuture<GetProofResult> getProof(
return future;
}

public static CompletableFuture<GetProofResult> getProofMsg(
int proofHandle
) throws VcxException {
ParamGuard.notNull(proofHandle, "proofHandle");
logger.debug("getProof() called with: proofHandle = [" + proofHandle + "]");
CompletableFuture<GetProofResult> future = new CompletableFuture<>();
int commandHandle = addFuture(future);

int result = LibVcx.api.vcx_get_proof_msg(commandHandle, proofHandle, vcxGetProofCB);
checkResult(result);

return future;
}


// vcx_proof_accepted
public static CompletableFuture<Integer> proofAccepted(
int proofHandle,
Expand Down
2 changes: 1 addition & 1 deletion wrappers/vcx-napi-rs/src/api/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn proof_get_state(handle: u32) -> napi::Result<u32> {

#[napi]
fn proof_get_presentation_verification_status(handle: u32) -> napi::Result<u32> {
proof::get_presentation_verification_status(handle).map_err(to_napi_err)
proof::get_presentation_verification_status(handle).map_err(to_napi_err).map(|status| status.code())
}

#[napi]
Expand Down

0 comments on commit e79b011

Please sign in to comment.