-
Discord user IDNo response Describe your question in detail.I have implemented a dispatchable_fungible_asset based on In my unit test:
According to the documentation, I should be able to use What error, if any, are you getting?No response What have you tried or looked at? Or how can we reproduce the error?No response Which operating system are you using?Windows Which SDK or tool are you using? (if any)TypeScript SDK Describe your environment or tooling in detailNo response |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
Thanks for the question! The important thing here is in the dispatch function hook (the withdraw/deposit function you implemented), make sure it will not call into |
Beta Was this translation helpful? Give feedback.
-
I see.. Then the first paragraph in https://aptos.dev/en/build/smart-contracts/fungible-asset#interacting-with-dispatchable-fungible-asset is not accurate then. Is it possible for users to use |
Beta Was this translation helpful? Give feedback.
-
No. There is a pretty complex reason for this that. If you are interested in that you should probably look at the aip. The tl;dr is |
Beta Was this translation helpful? Give feedback.
-
Looking at the doc it does seem accurate? It does suggest the following:
|
Beta Was this translation helpful? Give feedback.
@runtian-zhou perhaps we can make this clearer given the complexity.
@ariesgun, the issue is possibly that your hooks call into primary_fungible_store.move, please let me know if this is not the case.
the distinction lies in the fact that:
a) contracts interacting with an asset (say FAcoin) can continue to call into
primary_fungible_store::withdraw/deposit
, since there is no risk of reentrancy.i.e.
pfs::withdraw
->dfa::withdraw
->fa_coin::withdraw
->fa::withdraw_with_ref
, so we're good.b) contracts that define their asset and hook (so you, the person deploying the FACoin module), can't call into ANY function in pfs WITHIN your hook logic. this causes a potential reentrancy, which you…