-
Notifications
You must be signed in to change notification settings - Fork 42
Read swapper's suggested gas limit if available #954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7ea9596
Respect provider non approval gas_limit for solana swaps
0xh3rman 2555c47
Preserve provider gas_limit and add tests
0xh3rman d554a4b
format code
0xh3rman 09b57bf
code cleanup
0xh3rman 98e0dc7
merge solana gas limit test
0xh3rman 009ca84
move MockClient to gem_client/testkit
0xh3rman 5d41b69
Update testkit.rs
0xh3rman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| use crate::{Client, ClientError}; | ||
| use async_trait::async_trait; | ||
| use serde::{de::DeserializeOwned, Serialize}; | ||
| use std::{ | ||
| collections::HashMap, | ||
| fmt::{Debug, Formatter}, | ||
| sync::Arc, | ||
| }; | ||
|
|
||
| type GetHandler = Arc<dyn Fn(&str) -> Result<Vec<u8>, ClientError> + Send + Sync>; | ||
| type PostHandler = Arc<dyn Fn(&str, &[u8]) -> Result<Vec<u8>, ClientError> + Send + Sync>; | ||
|
|
||
| #[derive(Clone, Default)] | ||
| pub struct MockClient { | ||
| get_handler: Option<GetHandler>, | ||
| post_handler: Option<PostHandler>, | ||
| } | ||
|
|
||
| impl MockClient { | ||
| pub fn new() -> Self { | ||
| Self::default() | ||
| } | ||
|
|
||
| pub fn with_get<F>(mut self, handler: F) -> Self | ||
| where | ||
| F: Fn(&str) -> Result<Vec<u8>, ClientError> + Send + Sync + 'static, | ||
| { | ||
| self.get_handler = Some(Arc::new(handler)); | ||
| self | ||
| } | ||
|
|
||
| pub fn with_post<F>(mut self, handler: F) -> Self | ||
| where | ||
| F: Fn(&str, &[u8]) -> Result<Vec<u8>, ClientError> + Send + Sync + 'static, | ||
| { | ||
| self.post_handler = Some(Arc::new(handler)); | ||
| self | ||
| } | ||
| } | ||
|
|
||
| impl Debug for MockClient { | ||
| fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
| f.debug_struct("MockClient").finish() | ||
| } | ||
| } | ||
|
|
||
| #[async_trait] | ||
| impl Client for MockClient { | ||
| async fn get<R>(&self, path: &str) -> Result<R, ClientError> | ||
| where | ||
| R: DeserializeOwned, | ||
| { | ||
| let handler = self.get_handler.as_ref().ok_or(ClientError::Http { status: 404, body: vec![] })?; | ||
| let bytes = handler(path)?; | ||
| serde_json::from_slice(&bytes).map_err(|e| ClientError::Serialization(e.to_string())) | ||
| } | ||
|
|
||
| async fn post<T, R>(&self, path: &str, body: &T, _headers: Option<HashMap<String, String>>) -> Result<R, ClientError> | ||
| where | ||
| T: Serialize + Send + Sync, | ||
| R: DeserializeOwned, | ||
| { | ||
| let handler = self.post_handler.as_ref().ok_or(ClientError::Http { status: 404, body: vec![] })?; | ||
| let body_bytes = serde_json::to_vec(body).map_err(|e| ClientError::Serialization(e.to_string()))?; | ||
| let bytes = handler(path, &body_bytes)?; | ||
| serde_json::from_slice(&bytes).map_err(|e| ClientError::Serialization(e.to_string())) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default-features = falseshould not be here