-
Notifications
You must be signed in to change notification settings - Fork 203
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
docs: update create-type md for clearer instructions #455
Conversation
docs/api/start/types.create.md
Outdated
You may want to construct a `Call` type given a specific tx. This can be done via `api.createType('Call', foo)`. It can be useful if you intend on only needing the call hex. | ||
|
||
```js | ||
const tx = await api.tx.balances.transfer(BOB, 12345); | ||
const call = api.createType('Call', { | ||
callIndex: tx.callIndex, | ||
args: tx.args, | ||
}); | ||
|
||
console.log('Call Hex: ', call.toHex()); | ||
``` |
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.
The recommended approach here is -
console.log(
'hex = ',
api.tx.balances.transfer(BOB, 123).method.toHex()
);
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.
Really good to know, I actually thought wrong about how to create a call for a while then! Thanks for letting me know and I will have it corrected above!
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.
Thanks for the suggestion, i just applied the fix. I went with the direction of advising using api.tx.balances.transfer(BOB, 123).method.toHex()
instead of a createType('Call', foo)
. If you would like as well I can also remove that whole section all together. It might be useful though since even I didnt realize you can grab the method
from the tx
itself.
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.
Thank you.
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR focuses on bringing some clarity based on this comment. We thought it would be beneficial to be a bit more explicit in the docs about not using createType for calls such as
api.tx...
,api.query...
etc.I also added an example where createType can be used to create a
Call
.