-
Notifications
You must be signed in to change notification settings - Fork 22
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
[feature request] chain-as-promise support #82
Comments
I have written a simple code snippet that promisify const writeContract = (extrinsic) => {
return new Promise((resolve, reject) => {
extrinsic.signAndSend(this.signer, (result) => {
// or result.status.isFinalized is you want grandpa finalization
if (result.status.isInBlock) {
resolve(result)
}
})
})
}
// call by
async execContract(message, params) {
const contract = await this.getContractInstance()
await this.writeContract(contract.tx[message](
{gasLimit: -1}, ...params
))
} Not an end solution, but I hope this helps a little bit. |
@RoyTimes I thought contract.tx is alrady promisify? This feature is for adding https://www.chaijs.com/plugins/chai-as-promised/ to @redspot/chai plugin and to make the DX (developer experiences) of Redspot similar to web3. |
This is a very good point. But I don't think we won't support |
Error refers to the error types defined in contract by the contract developers. A example as below #[ink(contract)]
mod erc20 {
...
pub enum Errors { ... }
} The types should theoretically be generated if custom type support (#81 ) is done. Type support is not essential. However for contract developers, it is much easier to catch bugs before executing by performing type checking. This is just nice to have. |
Given a smart contract, say erc20,
When a contract developer wants to check a transaction returns any error, He could check if any promise rejection happened.
Expect that he could do as below:
Dependencies
The text was updated successfully, but these errors were encountered: