mx-api-service icon indicating copy to clipboard operation
mx-api-service copied to clipboard

transferOwnership via smart contract function might still have cache issue and doesn't update in API request

Open Aero-Labs opened this issue 3 years ago • 2 comments

When calling a smart contract function to change NFT collection ownership it still wont update in the API request although transaction executes successfully. Im assuming its still a cache issue as we have no way of verifying.

Aero-Labs avatar Mar 15 '22 19:03 Aero-Labs

SC function used -

#[endpoint(transferOwner)]
fn transfer_owner(&self, token_ident: TokenIdentifier) {
    let new_owner = self.blockchain().get_caller();
    self.send().esdt_system_sc_proxy().transfer_ownership(&token_ident, &new_owner.to_address()).async_call().call_and_exit();
}

Explorer Link: [https://devnet-explorer.elrond.com/transactions/9d6d614079f6835d9475c138b0594394b376f0f74e0c74345d3f2d9333c091c8]

Aero-Labs avatar Mar 15 '22 19:03 Aero-Labs

hello!

indeed, we have a caching issue here. we cache the collection / token properties (including owner) for 24h for performance reasons, and right now we do not have any invalidation logic.

We could use the transaction processor to invalidate the owner, but TP only interprets transactions and omits smart contract results, as in the transaction depicted above.

A more robust mechanism would be to fetch logs, which we have as a short term plan anyway. Until then, we have the 24h caching issue

tanghel avatar Mar 21 '22 16:03 tanghel

The issue has been fixed with the following PR: https://github.com/multiversx/mx-api-service/pull/912

tanghel avatar Feb 08 '23 07:02 tanghel