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(tangle-dapp): Use TX relayer for EVM accounts with no balance #2758

Merged
merged 17 commits into from
Jan 31, 2025

Conversation

yurixander
Copy link
Member

@yurixander yurixander commented Jan 26, 2025

Summary of changes

Provide a detailed description of proposed changes.

  • ➕ Added the ability for EVM accounts to use TX relayer, which relays transactions for free.
  • 🔧 Removed legacy Restaking Parachain code & hooks; LST pallet replaced most functionality.
  • 🐛 Fixed LST creation flow which was failing due to updates on the ABI.
  • 🐛 Fixed some bugs with the useContractRead and usePolling hooks.

Proposed area of change

Put an x in the boxes that apply.

  • apps/tangle-dapp
  • apps/tangle-cloud
  • libs/tangle-shared-ui
  • libs/webb-ui-components

Associated issue(s)

Specify any issues that can be closed from these changes (e.g. Closes #233).

Screen Recording

If possible provide screenshots and/or a screen recording of proposed change.

Screenshot.2025-01-28.at.23.23.17.mp4

@yurixander yurixander self-assigned this Jan 26, 2025
Copy link

netlify bot commented Jan 26, 2025

Deploy Preview for tangle-dapp ready!

Name Link
🔨 Latest commit c895520
🔍 Latest deploy log https://app.netlify.com/sites/tangle-dapp/deploys/6796b74e421b71000837ba86
😎 Deploy Preview https://deploy-preview-2758--tangle-dapp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 26, 2025

Deploy Preview for tangle-cloud ready!

Name Link
🔨 Latest commit c895520
🔍 Latest deploy log https://app.netlify.com/sites/tangle-cloud/deploys/6796b74e03b96a000803bf38
😎 Deploy Preview https://deploy-preview-2758--tangle-cloud.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 26, 2025

Deploy Preview for tangle-dapp ready!

Name Link
🔨 Latest commit 12f2cd9
🔍 Latest deploy log https://app.netlify.com/sites/tangle-dapp/deploys/679bf5c4bcef0e0008e48f11
😎 Deploy Preview https://deploy-preview-2758--tangle-dapp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 26, 2025

Deploy Preview for tangle-cloud ready!

Name Link
🔨 Latest commit 12f2cd9
🔍 Latest deploy log https://app.netlify.com/sites/tangle-cloud/deploys/679bf5c4bed1e50008d6831f
😎 Deploy Preview https://deploy-preview-2758--tangle-cloud.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@yurixander
Copy link
Member Author

yurixander commented Jan 28, 2025

What's left here:

  • Integrate into the useEvmPrecompileCall hook, ensuring that all precompile calls automatically integrate this feature.
  • Estimate contract call gas to provide to relayer as gaslimit param.
  • Check if the active account is an EVM account and has no balance before attempting to relay TX.
  • Check whether the extrinsic that the EVM account is using is elegible for TX relayer subsidy (not all are).
  • Fix CORS error which occurs when making requests from localhost to testnet relayer (CC @shekohex)
  • Fix VM Exception while processing transaction: revert Invalid permit that might be caused by mismatching chain ID on the Tangle node's code/logic (CC @shekohex)
  • Read the nonce from the CallPermit smart contract.

@yurixander yurixander marked this pull request as ready for review January 29, 2025 04:37
@yurixander yurixander changed the title feat(tangle-dapp): Use TX relayers for EVM accounts with no balance feat(tangle-dapp): Use TX relayer for EVM accounts with no balance Jan 29, 2025
Copy link
Member

@AtelyPham AtelyPham left a comment

Choose a reason for hiding this comment

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

Left some comments.

Copy link
Member

Choose a reason for hiding this comment

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

Why don't we use useWalletClient from and usePublicClient from wagmi out of curiosity?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is integrated with useNetworkStore's active network, so that when the active network is changed, this also reflects the changes. Is it the same for useWalletClient & usePublicClient?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, you can pass the chain id as the parameter into those hooks.

Copy link
Member Author

@yurixander yurixander Jan 30, 2025

Choose a reason for hiding this comment

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

How would you obtain that chain id? Something like this would be needed wherever we use useWalletClient & usePublicClient:

import {useWalletClient} from "wagmi"

const MyComponent = () => {
  const {network} = useNetworkStore()
  
  // ... check if the current network has an evm id ...
  
  const client = useWalletClient({ chainId: network.evmChainId, ... other config ... })
}

If that's the case, then that would be exactly why the custom useViemWalletClient hook is useful: It saves you the time to having to repeat all those checks wherever you'd use the wagmi variant.

@AtelyPham AtelyPham self-requested a review January 30, 2025 13:55
@yurixander yurixander requested a review from AtelyPham January 30, 2025 21:57
@drewstone
Copy link
Contributor

@yurixander after depositing does your balance instantly update or not in that tooltip display?

@drewstone
Copy link
Contributor

Cause if not we're just leaving more "BUG"s that @monaiuu is going to have us point out. Remember these features don't exist in a vacuum we have to be implementing updates for all the effects they trigger.

@yurixander
Copy link
Member Author

@yurixander after depositing does your balance instantly update or not in that tooltip display?

@drewstone It does not instantly update after depositing, the reason likely being that the code fetches the balances periodically. It is not fixed in this PR because this one is solely intended to implement the TX relayer feature though.

@drewstone
Copy link
Contributor

Ok, is this bug reported anywhere?

@drewstone
Copy link
Contributor

drewstone commented Jan 30, 2025

I think if we don't change this culture of how we build where we're so focused on implementing a feature and not in a way that fixes things in the process or addressing all aspects of the work, we will continue to have issues like this.

@yurixander
Copy link
Member Author

Ok, is this bug reported anywhere?

Yes: #2780

@yurixander yurixander merged commit 5ef6c42 into develop Jan 31, 2025
16 checks passed
@yurixander yurixander deleted the yuri/relayer-subsidized-txs branch January 31, 2025 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Completed ✅
Development

Successfully merging this pull request may close these issues.

[FEAT] Add Transaction Relayer Support for EVM Users on dApp
3 participants