Post
Share your knowledge.
How can I obtain a comprehensive list of Move module (s) within the 0x2 Move package?
How can I obtain a comprehensive list of modules within the 0x2
package that can send SUI, apart from the known Move modules like 'pay
', 'pay_sui
', 'transfer
', and 'sui
'? I initially checked the explorer.sui.io platform and used the provider.getNormalizedMoveModulesByPackage('0x2')
method, but I noticed discrepancies, such as the transfer_object
Move module not appearing in the list provided by the explorer and the method. Also, I am struggling with filtering events correctly using provider.getEvents
due to stability issues on the devnet, resulting in frequent timeouts. Can someone guide me on the correct approach to obtain this information and handle event filtering more effectively?
- Move Module
Answers
2To filter events more effectively, you can use the And filter with EventQuery. The correct syntax might look something like this (although the exact syntax might vary in TypeScript):
And({
MoveModule: { package: '0x2', module: 'pay' },
Any[{ EventType: 'MoveEvent' }, { EventType: 'CoinBalanceChange' }]
})
Please note that EventQuery
and EventFilter
serve different purposes. EventQuery
is used with the sui_getEvents
method to query events stored in the database, while EventFilter
is used for real-time event subscriptions in Sui. As of now, EventQuery
does not support combinators like Any/And/Or. It's important to keep this distinction in mind while working with event queries and filters in the Sui ecosystem. Additionally, there are plans to move these functionalities to the indexer in the future.
To obtain a comprehensive list of modules within the 0x2 package that can send SUI, you would typically use the provider.getNormalizedMoveModulesByPackage('0x2') method, as you mentioned. However, you've noticed discrepancies between the list provided by the explorer and the method. This could be due to the fact that the explorer and the provider might not always be in sync, especially in a devnet environment where changes are frequent.
Unfortunately, without more information about the SUI framework and its API, it's hard to provide a more specific solution. However, here are a few general suggestions:
Check for updates: Make sure that both the explorer and the provider are up-to-date. If the explorer is providing a more accurate list of modules, it might be because it has more recent information. Retry on failure: If you're frequently encountering timeouts when calling provider.getEvents, you could implement a retry mechanism. This would involve catching the timeout error and retrying the request a certain number of times before giving up. Filter events more effectively: To filter events more effectively, you could try to narrow down the parameters of your filter. For example, you could filter by event type, block number, or transaction hash. This might help to reduce the number of events that need to be processed and avoid timeouts. Consult the documentation: If you're still having trouble, you should consult the SUI documentation or reach out to the SUI community for help. They might be able to provide more specific advice or solutions. As for the discrepancy with the 'transfer_object' module, it's possible that this module is part of a different package, or it might not be included in the public API of the 0x2 package. You could try to verify this by checking the source code of the 0x2 package or by asking the SUI community.
Remember that the SUI framework is still under development, and its API might change over time. Therefore, it's important to keep up-to-date with the latest changes and updates.
Please note that these are general suggestions, and the actual solution might depend on the specific requirements of your application and the specific behavior of the SUI framework and its API.
Do you know the answer?
Please log in and share it.
Move is an executable bytecode language used to implement custom transactions and smart contracts.