Skip to content
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 useTransaction hook #134

Merged
merged 5 commits into from
Dec 21, 2021
Merged

Add useTransaction hook #134

merged 5 commits into from
Dec 21, 2021

Conversation

naz3eh
Copy link
Member

@naz3eh naz3eh commented Dec 20, 2021

Closes #126

Description

I've added a useTransaction hook. This hook takes the function and an array of arguments to this function as an argument.
This hook returns an object containing the execute method, loading state, and error state. On calling this execute method, the function passed in the hook as an argument will get executed.

@changeset-bot
Copy link

changeset-bot bot commented Dec 20, 2021

🦋 Changeset detected

Latest commit: 51ae6ba

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@web3-ui/hooks Minor
@web3-ui/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@naz3eh naz3eh requested a review from Dhaiwat10 December 20, 2021 10:18
Comment on lines 11 to 13
const giveAlert = (name, greeting) => {
alert('Hello ' + name + '! ' + greeting);
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hook is meant to be for Ethereum contract calls. Can you add an example that actually calls an Ethereum contract? You can use useContract

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove these current stories

Copy link
Member Author

@naz3eh naz3eh Dec 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll use useContract and remove current stories

alert(await contract.greet())
);

// @ts-expect-error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you paste the error that you are seeing here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting this typescript type error Property 'setGreeting' does not exist on type '{}'.

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's expected since the useContract does not return any type defs as of now

@Dhaiwat10 Dhaiwat10 merged commit da536ed into main Dec 21, 2021
@Dhaiwat10 Dhaiwat10 deleted the fix/issue-126 branch December 21, 2021 13:16
@github-actions github-actions bot mentioned this pull request Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useTransaction hook
2 participants