Empty value of entity after writing with `.save()` and reading with `::find()`
chlenc opened this issue · 0 comments
empty value of entity after writing with .save()
and reading with ::find()
in that case, AccountBalanceChangeEventsBatch
contains only 1 value of 5
We have a very important value in our contracts called open_interest
, it is calculated by the formula open_interest = open_interest - abs(old_account_balance.taker_open_notional) + abs(account_balance.taker_open_notional)
(if account_balance and position are the same thing)
to calculate this value I used OpenInterestEntity::find(OpenInterestEntity::id().eq(open_interest_id.clone()))
in account_balance_change_event_handler
, but judging by the logs it returned a zero value of OpenInterestEntity
when it was not zero, please tell me what can be the matter here.
more logs are here
looks like getting the order by ID returns a zero value
because we are saving value 21074050192 and straight after that we see open_interest_entity isn't None, but value 0 after unwrap
Just for the sake of sanity, could you print
open_interest_entity.save()
info!("{open_interest_entity}");
info!("{}", OpenInterestEntity::find(OpenInterestEntity::id().eq(open_interest_entity.id.clone()).unwrap());
That is, save, print, lookup, print.
This way we’d know if it was saved properly.
The id and market are correct, though. So, it finds a value, but the value has OI zero, just after .save() and even on the next tx handler
My toolchain
Default host: aarch64-apple-darwin
fuelup home: /Users/alexey/.fuelup
installed toolchains
--------------------
latest-aarch64-apple-darwin (default)
beta-4-aarch64-apple-darwin
latest-2023-11-15-aarch64-apple-darwin
my-custom-toolchain
active toolchain
-----------------
latest-aarch64-apple-darwin (default)
forc : 0.46.1
- forc-client
- forc-deploy : 0.46.1
- forc-run : 0.46.1
- forc-doc : 0.46.1
- forc-explore : 0.28.1
- forc-fmt : 0.46.1
- forc-index : 0.24.3
- forc-lsp : 0.46.1
- forc-tx : 0.46.1
- forc-wallet : 0.3.0
fuel-core : 0.20.5
fuel-core-keygen : Error getting version string
fuel-indexer : 0.24.3
fuels versions
---------------
forc : 0.45
forc-wallet : 0.45