From ac1e9852b8cde168bf5449d8912cbb4ba003cf82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan-=C8=98tefan=20Neac=C5=9Fu?= Date: Wed, 16 Oct 2024 13:16:47 +0300 Subject: [PATCH] Add topup req constructor --- common/authenticator-requests/src/v3/request.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/common/authenticator-requests/src/v3/request.rs b/common/authenticator-requests/src/v3/request.rs index 61e0914c1d..32db17aed2 100644 --- a/common/authenticator-requests/src/v3/request.rs +++ b/common/authenticator-requests/src/v3/request.rs @@ -84,6 +84,22 @@ impl AuthenticatorRequest { ) } + pub fn new_topup_request(top_up_message: TopUpMessage, reply_to: Recipient) -> (Self, u64) { + let request_id = generate_random(); + ( + Self { + protocol: Protocol { + service_provider_type: ServiceProviderType::Authenticator, + version: VERSION, + }, + data: AuthenticatorRequestData::TopUpBandwidth(Box::new(top_up_message)), + reply_to, + request_id, + }, + request_id, + ) + } + pub fn to_bytes(&self) -> Result, bincode::Error> { use bincode::Options; make_bincode_serializer().serialize(self)