-
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
fix(nft): add token_id field to the tx history primary key, fix balance #2209
base: dev
Are you sure you want to change the base?
Conversation
dfaa2fd
to
a667af9
Compare
… sql transfer history
01b9974
to
51eb543
Compare
…t amount of token without any decimals or scaling factors
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.
Thanks, NFT history and 1155 withdraws confirmed working.
Note: Withdraws of a spammy NFT were throwing gas errrors, but a good NFT was fine. I assume the spammy one was trying to scalp gas.
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.
Thanks for the fix! First review iteration!
@@ -103,7 +103,7 @@ fn create_transfer_history_table_sql(chain: &Chain) -> Result<String, SqlError> | |||
image_domain TEXT, | |||
token_name TEXT, | |||
details_json TEXT, | |||
PRIMARY KEY (transaction_hash, log_index) | |||
PRIMARY KEY (transaction_hash, log_index, token_id) |
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.
What about already created tables? Shouldn't we do a migration for these tables?
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.
hmm yeah, need to do it
I think it’s worth considering the use of sql client (eg SQLx) or ORM (eg Diesel) in the future, if we decide to fully refactor KDF. These sql tools natively support migrations.
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 think it’s worth considering the use of sql client (eg SQLx) or ORM (eg Diesel) in the future, if we decide to fully refactor KDF. These sql tools natively support migrations.
Do we have an issue open for this? If not, please open one.
68062f8
to
48a7f5b
Compare
44ca4a5
to
a5c612c
Compare
a5c612c
to
041f99c
Compare
@borngraced can you please review the wasm / indexeddb changes? |
ps right now it doesnt work as expected. We use web-sys to access Web APIs available in the browser. Despite the fact that web-sys functions are sync, the actuall process in browser can be async (that what happens with IndexedDB). I suppose thats why I got UPD: I also suggest to check for wasm db clients which support migrations. |
Have checked the cursor implementation example on how async and channels are used? |
yes, in the end cursor usage requires to call "await" somewhere to wait for the end of the process. async fn init(db_id: DbIdentifier) -> InitDbResult<Self> {
let inner = IndexedDbBuilder::new(db_id)
.with_version(...)
.with_table::<...>()
.build()
.await?;
Ok(Self { inner })
} The other idea is that, the current migration fails, bcz it started earlier than upgrade permission was granted in build function komodo-defi-framework/mm2src/mm2_db/src/indexed_db/drivers/builder.rs Lines 87 to 91 in e8be556
UPD: may be it worth trying to reuse our cursor driver implementation withour making |
I will dedicate some time to this later today/tomorrow morning and get back to you for sure! |
@laruh have you seen this yet? komodo-defi-framework/mm2src/mm2_main/src/lp_swap/saved_swap.rs Lines 274 to 340 in 35e9239
|
fixes #2208
also in this commit 2bdee4f fixes withdarw_erc1155 decimal issue. ERC1155 "balanceOf" method started returning exact Nft amount owned by wallet without any scaling, so we dont need to use
self.decimals
shift when we convert U256 type to BigDecimal