-
Notifications
You must be signed in to change notification settings - Fork 45
Add Relay swap provider and client for evm chains #983
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
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
fc33c22
Add Relay swap provider and client for evm chains
0xh3rman 4cd0051
remove is_evm() check inside asset_to_currency
0xh3rman f618739
Make StepData an enum, simplify quote mapping
0xh3rman fa0cb9f
Merge branch 'main' into relay-evm
0xh3rman 6c91844
fix merge
0xh3rman 6c3cd85
Fix format
0xh3rman 01281f4
code cleanup
0xh3rman f12f40c
remove extra chain asset from vec
0xh3rman ff18e13
lower default swap gas limit for relay
0xh3rman 19b36f3
code cleanup
0xh3rman f60f7e5
Merge branch 'main' into relay-evm
0xh3rman bf186cf
Add relay mapper tests and testdata
gemcoder21 52c530d
more code cleanup
0xh3rman e97fd39
Update mapper.rs
0xh3rman 67d04de
Update mapper.rs
0xh3rman a39ce1c
more fetch -> get
0xh3rman 2826cc6
rename variables
0xh3rman 27f32b0
cleanup tests
0xh3rman bb9552f
fetch permit -> get permit
0xh3rman a177853
Update mod.rs
0xh3rman a737069
Update ViewModel.swift
0xh3rman 7ddc623
add STEP_TRANSACTION
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
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,37 @@ | ||
| use std::{collections::HashMap, fmt::Debug}; | ||
|
|
||
| use gem_client::{CONTENT_TYPE, Client, ClientExt, ContentType}; | ||
|
|
||
| use super::model::{RelayChainsResponse, RelayQuoteRequest, RelayQuoteResponse, RelayRequestsResponse}; | ||
| use crate::SwapperError; | ||
|
|
||
| #[derive(Clone, Debug)] | ||
| pub struct RelayClient<C> | ||
| where | ||
| C: Client + Clone + Send + Sync + Debug + 'static, | ||
| { | ||
| client: C, | ||
| } | ||
|
|
||
| impl<C> RelayClient<C> | ||
| where | ||
| C: Client + Clone + Send + Sync + Debug + 'static, | ||
| { | ||
| pub fn new(client: C) -> Self { | ||
| Self { client } | ||
| } | ||
|
|
||
| pub async fn get_quote(&self, request: RelayQuoteRequest) -> Result<RelayQuoteResponse, SwapperError> { | ||
| let headers = HashMap::from([(CONTENT_TYPE.to_string(), ContentType::ApplicationJson.as_str().into())]); | ||
| self.client.post_with("/quote/v2", &request, headers).await.map_err(SwapperError::from) | ||
| } | ||
|
|
||
| pub async fn get_request(&self, transaction_hash: &str) -> Result<RelayRequestsResponse, SwapperError> { | ||
| let path = format!("/requests/v2?hash={}", transaction_hash); | ||
0xh3rman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| self.client.get(&path).await.map_err(SwapperError::from) | ||
| } | ||
|
|
||
| pub async fn get_chains(&self) -> Result<RelayChainsResponse, SwapperError> { | ||
| self.client.get("/chains").await.map_err(SwapperError::from) | ||
| } | ||
| } | ||
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 |
|---|---|---|
| @@ -1,8 +1,12 @@ | ||
| mod asset; | ||
| mod chain; | ||
| mod client; | ||
| mod mapper; | ||
| pub(crate) mod model; | ||
| mod model; | ||
| mod provider; | ||
| #[cfg(test)] | ||
| mod testkit; | ||
|
|
||
| pub use mapper::map_swap_result; | ||
| const DEFAULT_SWAP_GAS_LIMIT: u64 = 150_000; | ||
|
|
||
| pub use provider::Relay; |
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.
Uh oh!
There was an error while loading. Please reload this page.