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

feat(common): add viem actions that work the same as the current wrappers #2347

Merged
merged 20 commits into from
Feb 29, 2024

Conversation

tash-2s
Copy link
Contributor

@tash-2s tash-2s commented Feb 28, 2024

This code is pulled out from #2309 and got some modifications.

This PR introduces viem client actions into the common library. These actions work the same as MUD's getContract, writeContract, and sendTransaction, but this enables the use of the functions through client (e.g., client.writeContract(...)).

We've decided to include the simulation code in these overridden viem actions, so now the same code as the wrappers is used. If we decide to deprecate the wrapper functions, I can reorganize the code for these actions. (While getContract might be deprecated, do we want to use the writeContract and sendTransaction wrappers independently?)

Including simulation in transaction sending actions is especially necessary for further enhancements that require precise control over simulation.

Additionally, I've updated a template for testing/demonstration purposes, which can be removed prior to merging.

Copy link

changeset-bot bot commented Feb 28, 2024

🦋 Changeset detected

Latest commit: dcdcdee

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

This PR includes changesets to release 30 packages
Name Type
@latticexyz/common Major
create-mud Major
@latticexyz/block-logs-stream Major
@latticexyz/cli Major
@latticexyz/config Major
@latticexyz/dev-tools Major
@latticexyz/faucet Major
@latticexyz/protocol-parser Major
@latticexyz/store-indexer Major
@latticexyz/store-sync Major
@latticexyz/store Major
@latticexyz/world-modules Major
@latticexyz/world Major
@latticexyz/react Major
@latticexyz/abi-ts Major
@latticexyz/ecs-browser Major
@latticexyz/gas-report Major
@latticexyz/network Major
@latticexyz/noise Major
@latticexyz/phaserx Major
@latticexyz/recs Major
@latticexyz/schema-type Major
@latticexyz/services Major
@latticexyz/solecs Major
solhint-config-mud Major
solhint-plugin-mud Major
@latticexyz/std-client Major
@latticexyz/std-contracts Major
@latticexyz/store-cache Major
@latticexyz/utils Major

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

@tash-2s tash-2s changed the title WIP: add viem custom actions in common feat(common): add viem actions that work the same as the current wrappers Feb 29, 2024
@tash-2s tash-2s marked this pull request as ready for review February 29, 2024 02:13
packages/common/src/viemActions.ts Outdated Show resolved Hide resolved
packages/common/src/viemActions.ts Outdated Show resolved Hide resolved
Copy link
Member

@holic holic left a comment

Choose a reason for hiding this comment

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

Looking great!

A few more requests:

  • add // @deprecated Use `walletClient.extend(transactionQueue())` instead. to the top of each of getContract, writeContract, sendTransaction wrapper functions
  • set up the new actions in the rest of the templates
  • add a changeset (pnpm changeset from root, or via the link in the bot comment above)

@tash-2s
Copy link
Contributor Author

tash-2s commented Feb 29, 2024

Thanks for the reviews! I'll address these requests.

set up the new actions in the rest of the templates

OK, I'll apply the same changes as the current react template got to other templates in this PR.

@holic holic merged commit 5926765 into main Feb 29, 2024
10 of 11 checks passed
@holic holic deleted the tash-2s/viem-custom branch February 29, 2024 19:21
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.

2 participants