Skip to content

Commit 4beff93

Browse files
authored
Merge pull request #164 from hyperware-ai/hf/fix-compile-for-hyperwallet-and-hyperapp
fix hyperwallet
2 parents 4705378 + 8ae18fd commit 4beff93

File tree

5 files changed

+58
-56
lines changed

5 files changed

+58
-56
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ license = "Apache-2.0"
1111
[features]
1212
hyperapp = ["dep:futures-util", "dep:uuid", "logging"]
1313
logging = ["dep:color-eyre", "dep:tracing", "dep:tracing-error", "dep:tracing-subscriber"]
14-
hyperwallet = []
14+
hyperwallet = ["dep:hex", "dep:sha3"]
1515
simulation-mode = []
1616

1717
[dependencies]
@@ -48,3 +48,6 @@ color-eyre = { version = "0.6", features = ["capture-spantrace"], optional = tru
4848
tracing = { version = "0.1", optional = true }
4949
tracing-error = { version = "0.2", optional = true }
5050
tracing-subscriber = { version = "0.3", features = ["env-filter", "json", "std"], optional = true }
51+
52+
hex = { version = "0.4.3", optional = true }
53+
sha3 = { version = "0.10.8", optional = true }

src/hyperwallet_client/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::println as kiprintln;
21
use crate::Request;
32
use thiserror::Error;
43

Lines changed: 52 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use super::{
2-
parse_response, vfs_request, FileMetadata, SeekFrom, VfsAction, VfsError, VfsResponse,
3-
};
1+
use super::{vfs_request, FileMetadata, SeekFrom, VfsAction, VfsError, VfsResponse};
42
use crate::{get_blob, hyperapp, PackageId};
53

64
#[derive(serde::Deserialize, serde::Serialize)]
@@ -20,11 +18,11 @@ impl FileAsync {
2018
pub async fn read(&self) -> Result<Vec<u8>, VfsError> {
2119
let request = vfs_request(&self.path, VfsAction::Read).expects_response(self.timeout);
2220

23-
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
21+
let response = hyperapp::send::<VfsResponse>(request)
2422
.await
25-
.map_err(|e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
23+
.map_err(|_e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
2624

27-
match parse_response(&resp_bytes)? {
25+
match response {
2826
VfsResponse::Read => {
2927
let data = match get_blob() {
3028
Some(bytes) => bytes.bytes,
@@ -48,11 +46,11 @@ impl FileAsync {
4846
pub async fn read_into(&self, buffer: &mut [u8]) -> Result<usize, VfsError> {
4947
let request = vfs_request(&self.path, VfsAction::Read).expects_response(self.timeout);
5048

51-
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
49+
let response = hyperapp::send::<VfsResponse>(request)
5250
.await
53-
.map_err(|e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
51+
.map_err(|_e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
5452

55-
match parse_response(&resp_bytes)? {
53+
match response {
5654
VfsResponse::Read => {
5755
let data = get_blob().unwrap_or_default().bytes;
5856
let len = std::cmp::min(data.len(), buffer.len());
@@ -73,11 +71,11 @@ impl FileAsync {
7371
let request =
7472
vfs_request(&self.path, VfsAction::ReadExact { length }).expects_response(self.timeout);
7573

76-
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
74+
let response = hyperapp::send::<VfsResponse>(request)
7775
.await
78-
.map_err(|e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
76+
.map_err(|_e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
7977

80-
match parse_response(&resp_bytes)? {
78+
match response {
8179
VfsResponse::Read => {
8280
let data = get_blob().unwrap_or_default().bytes;
8381
let len = std::cmp::min(data.len(), buffer.len());
@@ -95,11 +93,11 @@ impl FileAsync {
9593
pub async fn read_to_end(&self) -> Result<Vec<u8>, VfsError> {
9694
let request = vfs_request(&self.path, VfsAction::ReadToEnd).expects_response(self.timeout);
9795

98-
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
96+
let response = hyperapp::send::<VfsResponse>(request)
9997
.await
100-
.map_err(|e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
98+
.map_err(|_e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
10199

102-
match parse_response(&resp_bytes)? {
100+
match response {
103101
VfsResponse::Read => Ok(get_blob().unwrap_or_default().bytes),
104102
VfsResponse::Err(e) => Err(e),
105103
_ => Err(VfsError::ParseError {
@@ -113,11 +111,11 @@ impl FileAsync {
113111
let request =
114112
vfs_request(&self.path, VfsAction::ReadToString).expects_response(self.timeout);
115113

116-
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
114+
let response = hyperapp::send::<VfsResponse>(request)
117115
.await
118-
.map_err(|e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
116+
.map_err(|_e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
119117

120-
match parse_response(&resp_bytes)? {
118+
match response {
121119
VfsResponse::ReadToString(s) => Ok(s),
122120
VfsResponse::Err(e) => Err(e),
123121
_ => Err(VfsError::ParseError {
@@ -132,11 +130,11 @@ impl FileAsync {
132130
.blob_bytes(buffer)
133131
.expects_response(self.timeout);
134132

135-
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
133+
let response = hyperapp::send::<VfsResponse>(request)
136134
.await
137-
.map_err(|e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
135+
.map_err(|_e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
138136

139-
match parse_response(&resp_bytes)? {
137+
match response {
140138
VfsResponse::Ok => Ok(()),
141139
VfsResponse::Err(e) => Err(e),
142140
_ => Err(VfsError::ParseError {
@@ -151,11 +149,11 @@ impl FileAsync {
151149
.blob_bytes(buffer)
152150
.expects_response(self.timeout);
153151

154-
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
152+
let response = hyperapp::send::<VfsResponse>(request)
155153
.await
156-
.map_err(|e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
154+
.map_err(|_e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
157155

158-
match parse_response(&resp_bytes)? {
156+
match response {
159157
VfsResponse::Ok => Ok(()),
160158
VfsResponse::Err(e) => Err(e),
161159
_ => Err(VfsError::ParseError {
@@ -170,11 +168,11 @@ impl FileAsync {
170168
.blob_bytes(buffer)
171169
.expects_response(self.timeout);
172170

173-
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
171+
let response = hyperapp::send::<VfsResponse>(request)
174172
.await
175-
.map_err(|e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
173+
.map_err(|_e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
176174

177-
match parse_response(&resp_bytes)? {
175+
match response {
178176
VfsResponse::Ok => Ok(()),
179177
VfsResponse::Err(e) => Err(e),
180178
_ => Err(VfsError::ParseError {
@@ -187,11 +185,11 @@ impl FileAsync {
187185
pub async fn seek(&mut self, pos: SeekFrom) -> Result<u64, VfsError> {
188186
let request = vfs_request(&self.path, VfsAction::Seek(pos)).expects_response(self.timeout);
189187

190-
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
188+
let response = hyperapp::send::<VfsResponse>(request)
191189
.await
192-
.map_err(|e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
190+
.map_err(|_e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
193191

194-
match parse_response(&resp_bytes)? {
192+
match response {
195193
VfsResponse::SeekFrom {
196194
new_offset: new_pos,
197195
} => Ok(new_pos),
@@ -212,11 +210,11 @@ impl FileAsync {
212210
)
213211
.expects_response(self.timeout);
214212

215-
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
213+
let response = hyperapp::send::<VfsResponse>(request)
216214
.await
217-
.map_err(|e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
215+
.map_err(|_e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
218216

219-
match parse_response(&resp_bytes)? {
217+
match response {
220218
VfsResponse::Ok => Ok(FileAsync {
221219
path: path.to_string(),
222220
timeout: self.timeout,
@@ -233,11 +231,11 @@ impl FileAsync {
233231
let request =
234232
vfs_request(&self.path, VfsAction::SetLen(size)).expects_response(self.timeout);
235233

236-
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
234+
let response = hyperapp::send::<VfsResponse>(request)
237235
.await
238-
.map_err(|e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
236+
.map_err(|_e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
239237

240-
match parse_response(&resp_bytes)? {
238+
match response {
241239
VfsResponse::Ok => Ok(()),
242240
VfsResponse::Err(e) => Err(e),
243241
_ => Err(VfsError::ParseError {
@@ -250,11 +248,11 @@ impl FileAsync {
250248
pub async fn metadata(&self) -> Result<FileMetadata, VfsError> {
251249
let request = vfs_request(&self.path, VfsAction::Metadata).expects_response(self.timeout);
252250

253-
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
251+
let response = hyperapp::send::<VfsResponse>(request)
254252
.await
255-
.map_err(|e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
253+
.map_err(|_e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
256254

257-
match parse_response(&resp_bytes)? {
255+
match response {
258256
VfsResponse::Metadata(metadata) => Ok(metadata),
259257
VfsResponse::Err(e) => Err(e),
260258
_ => Err(VfsError::ParseError {
@@ -267,11 +265,11 @@ impl FileAsync {
267265
pub async fn sync_all(&self) -> Result<(), VfsError> {
268266
let request = vfs_request(&self.path, VfsAction::SyncAll).expects_response(self.timeout);
269267

270-
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
268+
let response = hyperapp::send::<VfsResponse>(request)
271269
.await
272-
.map_err(|e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
270+
.map_err(|_e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
273271

274-
match parse_response(&resp_bytes)? {
272+
match response {
275273
VfsResponse::Ok => Ok(()),
276274
VfsResponse::Err(e) => Err(e),
277275
_ => Err(VfsError::ParseError {
@@ -300,11 +298,11 @@ pub async fn create_drive_async(
300298

301299
let request = vfs_request(&path, VfsAction::CreateDrive).expects_response(timeout);
302300

303-
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
301+
let response = hyperapp::send::<VfsResponse>(request)
304302
.await
305-
.map_err(|e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
303+
.map_err(|_e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
306304

307-
match parse_response(&resp_bytes)? {
305+
match response {
308306
VfsResponse::Ok => Ok(path),
309307
VfsResponse::Err(e) => Err(e),
310308
_ => Err(VfsError::ParseError {
@@ -323,11 +321,11 @@ pub async fn open_file_async(
323321

324322
let request = vfs_request(path, VfsAction::OpenFile { create }).expects_response(timeout);
325323

326-
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
324+
let response = hyperapp::send::<VfsResponse>(request)
327325
.await
328-
.map_err(|e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
326+
.map_err(|_e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
329327

330-
match parse_response(&resp_bytes)? {
328+
match response {
331329
VfsResponse::Ok => Ok(FileAsync {
332330
path: path.to_string(),
333331
timeout,
@@ -345,11 +343,11 @@ pub async fn create_file_async(path: &str, timeout: Option<u64>) -> Result<FileA
345343

346344
let request = vfs_request(path, VfsAction::CreateFile).expects_response(timeout);
347345

348-
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
346+
let response = hyperapp::send::<VfsResponse>(request)
349347
.await
350-
.map_err(|e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
348+
.map_err(|_e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
351349

352-
match parse_response(&resp_bytes)? {
350+
match response {
353351
VfsResponse::Ok => Ok(FileAsync {
354352
path: path.to_string(),
355353
timeout,
@@ -367,11 +365,11 @@ pub async fn remove_file_async(path: &str, timeout: Option<u64>) -> Result<(), V
367365

368366
let request = vfs_request(path, VfsAction::RemoveFile).expects_response(timeout);
369367

370-
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
368+
let response = hyperapp::send::<VfsResponse>(request)
371369
.await
372-
.map_err(|e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
370+
.map_err(|_e| VfsError::SendError(crate::SendErrorKind::Timeout))?;
373371

374-
match parse_response(&resp_bytes)? {
372+
match response {
375373
VfsResponse::Ok => Ok(()),
376374
VfsResponse::Err(e) => Err(e.into()),
377375
_ => Err(VfsError::ParseError {

0 commit comments

Comments
 (0)