-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add get actions to network API #788
Conversation
I would approach this similar to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look great! Approving in advance with one comment that needs to be addressed
const actionData = fetchedActions | ||
.map((action) => { | ||
return { | ||
hash: Ledger.fieldToBase58(Field(action.actionState)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't need to be fixed here, but it seems to me the field => base58 conversion is done both and in the local blockchain version, and would save computation to just leave the hash as a field element in both cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's a good idea, but I have to change a bunch of type definitions to make that work :/ I'll create an issue so it can be addressed later.
Description
Adds
getActions
to the network API. Uses a GraphQL server implements the following schemagetActions
is used inmethods,
so it cannot be asynchronous. Instead, we use the caching system already wired up to fetch account and network data. We create a new action cache and add it to the promises executed infetchMissingData
. WhenfetchMissingData
is called,fetchActions
queries the GraphQL schema and then caches the results, which can then be used bymethod
s of a smart contract in a non-asynchronous way.Tested
Manual Testing at these addresses:
https://berkeley.minaexplorer.com/wallet/B62qnL4b3wuAPwFb5E7ChYgDJFdxZgmud2kkx2N8RzNaq4ykagfzumy
https://berkeley.minaexplorer.com/wallet/B62qp7bmbYVpuhqRFmmMDGWcZQBavf9T5Lo1Jfj7yjSaPx2awYcTTvF
https://berkeley.minaexplorer.com/wallet/B62qp2SfYeLBo3p1ZwMS33qtqn6qCnAjAMXzTy6ZAYzYG8DLTr8xqhS
Discussion
Do we want to change the return types for actions to include the extra data returned from the GraphQL server? I left the data inside the query, but if it's not essential, I will remove it to save on network traffic.
Example Code