-
Notifications
You must be signed in to change notification settings - Fork 117
fix(nft): fix notes for 1.0.6-beta #1914
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
Changes from 8 commits
990e1e4
d3a26d3
e7c5c55
eaed80e
4781b28
e8eaa20
1323818
bb8dee1
ab0d49c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,17 @@ | ||
| use crate::nft::eth_add_to_hex; | ||
| use crate::{TransactionType, TxFeeDetails, WithdrawFee}; | ||
| use common::ten; | ||
| use ethereum_types::Address; | ||
| use futures::lock::Mutex as AsyncMutex; | ||
| use mm2_core::mm_ctx::{from_ctx, MmArc}; | ||
| use mm2_number::BigDecimal; | ||
| use rpc::v1::types::Bytes as BytesJson; | ||
| use serde::Deserialize; | ||
| use serde_json::Value as Json; | ||
| use std::fmt; | ||
| use std::num::NonZeroUsize; | ||
| use std::str::FromStr; | ||
| use std::sync::Arc; | ||
| use url::Url; | ||
|
|
||
| #[derive(Debug, Deserialize)] | ||
|
|
@@ -41,7 +45,7 @@ pub struct RefreshMetadataReq { | |
|
|
||
| #[derive(Debug, Display)] | ||
| pub enum ParseChainTypeError { | ||
| UnsupportedCainType, | ||
| UnsupportedChainType, | ||
| } | ||
|
|
||
| #[derive(Clone, Copy, Debug, Deserialize, Serialize)] | ||
|
|
@@ -93,7 +97,7 @@ impl FromStr for Chain { | |
| "ETH" => Ok(Chain::Eth), | ||
| "FANTOM" => Ok(Chain::Fantom), | ||
| "POLYGON" => Ok(Chain::Polygon), | ||
| _ => Err(ParseChainTypeError::UnsupportedCainType), | ||
| _ => Err(ParseChainTypeError::UnsupportedChainType), | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -188,10 +192,10 @@ impl UriMeta { | |
| /// [`NftCommon`] structure contains common fields from [`Nft`] and [`NftFromMoralis`] | ||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||
| pub struct NftCommon { | ||
| pub(crate) token_address: String, | ||
| pub(crate) token_address: Address, | ||
| pub(crate) token_id: BigDecimal, | ||
| pub(crate) amount: BigDecimal, | ||
| pub(crate) owner_of: String, | ||
| pub(crate) owner_of: Address, | ||
| pub(crate) token_hash: Option<String>, | ||
| #[serde(rename = "name")] | ||
| pub(crate) collection_name: Option<String>, | ||
|
|
@@ -368,10 +372,10 @@ pub struct NftTransferCommon { | |
| pub(crate) log_index: Option<u64>, | ||
| pub(crate) value: Option<BigDecimal>, | ||
| pub(crate) transaction_type: Option<String>, | ||
| pub(crate) token_address: String, | ||
| pub(crate) token_address: Address, | ||
| pub(crate) token_id: BigDecimal, | ||
| pub(crate) from_address: String, | ||
| pub(crate) to_address: String, | ||
| pub(crate) from_address: Address, | ||
| pub(crate) to_address: Address, | ||
| pub(crate) amount: BigDecimal, | ||
| pub(crate) verified: Option<u64>, | ||
| pub(crate) operator: Option<String>, | ||
|
|
@@ -446,7 +450,7 @@ pub struct TxMeta { | |
| impl From<Nft> for TxMeta { | ||
| fn from(nft_db: Nft) -> Self { | ||
| TxMeta { | ||
| token_address: nft_db.common.token_address, | ||
| token_address: eth_add_to_hex(&nft_db.common.token_address), | ||
| token_id: nft_db.common.token_id, | ||
| token_uri: nft_db.common.token_uri, | ||
| collection_name: nft_db.common.collection_name, | ||
|
|
@@ -455,3 +459,17 @@ impl From<Nft> for TxMeta { | |
| } | ||
| } | ||
| } | ||
|
|
||
| pub(crate) struct NftCtx { | ||
| pub(crate) guard: Arc<AsyncMutex<()>>, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think instead of a
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
without mutex guard, we will have the same mm2 problem due to race condition. PS: I also caught this problem in native target. Sql propagates the error that you are trying to add item with identical primary key. I mean if we just move We need to lock the whole function before using storage and sending the moralis request. So I believe it doesn't mater, where we have But yeah, it is a good idea, bcz
yep, I have it in my plans. Actually I was trying to move the process of
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved |
||
| } | ||
|
|
||
| impl NftCtx { | ||
| pub(crate) fn from_ctx(ctx: &MmArc) -> Result<Arc<NftCtx>, String> { | ||
| Ok(try_s!(from_ctx(&ctx.nft_ctx, move || { | ||
| Ok(NftCtx { | ||
| guard: Arc::new(AsyncMutex::new(())), | ||
| }) | ||
| }))) | ||
| } | ||
| } | ||

Uh oh!
There was an error while loading. Please reload this page.