Move View Functions #18
Replies: 3 comments 1 reply
-
Proposal 1 for extending the JSON-RPC Read APIThis proposal is in line with the example and specifications made above. iota_viewExecutes a Move View Function. Which allows for nearly any Move call for a function with a return type and with any arguments. The function results values are provided and decoded using the appropriate Move type. Parameters
Result
|
Beta Was this translation helpful? Give feedback.
-
Proposal 2 for extending the JSON-RPC Read APIThis proposal works in parallel of proposal 1 and it is not meant to replace it. It consists of allowing a more complex query keeping most of the specifications made above about the Move View Function. The motivations for adding a second, more complex RPC Move View Function method are twofold:
In both cases, the usage of a PTB instead of only one move call would serve the scope. This would make the query less ergonomic, because the developer must use something like iota_viewTransactionBlockReturn the result values of the execution of a transaction block, while the effects are not committed to the chain. The function results values are provided and decoded using the appropriate Move type. Parameters
Result
Additional specifications for this proposal
|
Beta Was this translation helpful? Give feedback.
-
Couldn't a 3rd solution be to enrich the response returned by the 3 current RPC (dry-run, dev-inspect and execute), in order to add the JSON representation of the returned values (of the last moveCall in the transaction) ? Which would give, at the TS SDK level for example :
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Proposal
Abstract
This proposal introduces a standardized interface for enabling ergonomic and application-specific queries to the on-chain state. We refer to this as "Move view function" as it will allow developers to write and call Move functions that return values without requiring transaction signing or state mutation (based on the Ethereum's Solidity view function feature concept). The proposal is made to improve developer productivity and simplifying access to on-chain data through RPC, CLI, and SDK interfaces.
Motivation
Currently, developers must write a significant amount of custom client-side logic to inspect on-chain data. This often involves multiple layers of fetching object IDs, deserializing raw bytes, and navigating dynamic fields just to reach an information stored within a Move object. While tools like
dev-inspect
ordry-run
exist, they suffer from limitations such as complexity in usage and difficulty in decoding return values.This proposal to address the following developer pain points:
dev-inspect
can become complicated because the function returned values the developer gets are BCS bytes and then these need to be parsed, assuming the return type is known.Specification
This proposal defines a developer interface to support Move View Functions. The following is a list of specifications related to its implementation:
Backwards Compatibility
This proposal is fully backwards compatible. The implementation of such a developer interface MUST NOT require changes to the Move language. Instead, it:
Reference Implementation and Testing
An initial prototype exists using a variant of the dev-inspect call and CLI tooling. Here miker83z/iota@2081c1c. However, this only focuses on the modification of the execution side. Moreover, the developer experience is still suboptimal because it is still needed the manual decoding of return values.
Example RPC
The following example can be taken as a reference for the API model.
Request:
Response:
Copyright
Copyright and related rights waived via CC0.
Discussion
The discussion should continue to cover at least these points:
CC: @iotaledger/vm-language @iotaledger/dev-tools @iotaledger/tooling
Beta Was this translation helpful? Give feedback.
All reactions