-
Notifications
You must be signed in to change notification settings - Fork 94
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
Add proxy support #1775
Add proxy support #1775
Conversation
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.
thank you for taking the previous notes serious, I have a few notes regarding to changes
@@ -169,9 +173,16 @@ pub struct WithdrawErc721 { | |||
pub(crate) fee: Option<WithdrawFee>, | |||
} | |||
|
|||
#[derive(Clone, Deserialize)] | |||
pub struct WithdrawNftReq { | |||
pub(crate) url: String, |
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.
In what scenarios we would need this field?
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.
It is needed to withdraw erc1155 token type in current implementation.
As amount of erc1155 NFT could be > 1, we need to check that owner has enough "NFT" balance. So I created find_wallet_amount function to access info about all nfts owned by the user.
ps: I cant use get_nft_metadata function, bcz it returns info about the latest owner. ERC1155 can have more than 1 owners, it is fine to call this finction to get the info about name
, token_uri
, metadata
etc since they are common to erc1155 tokens with identical token_id, but owner in response could be different, so amount could be different.
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.
I mean why it's not hardcoded in the mm2 side? We don't really need to change the url as far as I know. I don't know how this field can be useful ever. If we migrate to gui-auth, all we need to do update the DNS for current proxy address.
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.
I just thought that hard coding is a bad practice and providing url in request enable people to use their own proxy if they want. But if you ok with hard coded endpoint as it was I can return it.
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.
Yeah, this seems reasonable. But as far as I see this is send for each withdraw request, unlike other urls
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.
btw I don't have hard feeling on this - we can ship this with it. It just didn't look quite right to me(sending url with each request)
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.
It just didn't look quite right to me(sending url with each request)
No worry when db support will be added only update_nft
and refresh_metadata
API methods will use url, bcz only these methods will be sending requests to moralis to get new info.
GUI told that its fine for them to change requests a little bit I will just need to ping them and provide up to date info about req and res forms.
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.
But as far as I see this is send for each withdraw request, unlike other urls
Well yeah I ask url for all erc types in withdraw method, but use it only for "type":"withdraw_erc1155", I just didnt want to add new param in withdraw_erc1155 structure. Once db will be added I just remove url, other fields will be the same.
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.
Usually RPC urls should be included in the enable calls and saved in the coin's fields as part of a client struct, but NFT is a special case since we don't have an enable call for them and defining a coin configuration to an NFT or NFTs in general makes no sense. I still think defining an enable call for NFTs, and some kind of context/coin or client to save the url/s on enable and maybe other important configs in the future if needed is the optimal solution to this url problem. This enable call can be even part of enable_eth_with_tokens
if needed.
@laruh please consider this in future PRs if you think it will make things easier.
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.
@shamardy nice hint, thanks.
personally I dont see using urls in couple future NFT methods as a problem, as NFT is a special case right now.
But yeah I think we cant avoid making some nft configs or adding some enable actions in NFT swaps implementation (related to this thread in previous pr).
I will safe this hint for swaps implementation.
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.
thank you for the fixes, have some non-blocker small notes
@shamardy please take a look on this PR as well
@@ -11,7 +11,7 @@ use crate::{mm2::lp_stats::{add_node_to_version_stat, remove_node_from_version_s | |||
mm2::rpc::lp_commands::{get_public_key, get_public_key_hash, get_shared_db_id, trezor_connection_status}}; | |||
use coins::eth::EthCoin; | |||
use coins::my_tx_history_v2::my_tx_history_v2_rpc; | |||
#[cfg(feature = "enable-nft-integration")] use coins::nft; | |||
use coins::nft; |
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.
future note: we will need to create it's own crate for nft
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.
will need to create it's own crate for nft
should think about it, in the future there are swaps with nfts. wouldn't it be strange that nfts are not a part of the coins in this case?
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.
It can inherit from coins, but it's not really a coin
. Majority part of the coins modules needs to be seperated to different/their own crates. e.g eth
module has amazingly much than what it should have. Which takes development/maintanince/compilation costs to much higher levels.
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.
🚀
@@ -236,7 +230,7 @@ async fn send_moralis_request(uri: &str, api_key: &str) -> MmResult<Json, GetNft | |||
} | |||
|
|||
#[cfg(target_arch = "wasm32")] | |||
async fn send_moralis_request(uri: &str, api_key: &str) -> MmResult<Json, GetNftInfoError> { |
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.
We should allow API users to use their own API key if they want in the future, this is not a priority now though.
#900
possible_spam
field was added inNft
andNftTransferHistory
structuresrequest examples
get_nft_list
get_nft_transfers
get_nft_metadata
withdraw erc721
withdraw erc1155
Note: after adding db support "url" param will be removed from requests above and will be added into new
update_nft
andrefresh_metadata