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

Feature Request: Fallback to multicall if not a cb smart wallet #1108

Open
mykcryptodev opened this issue Aug 20, 2024 · 0 comments
Open

Feature Request: Fallback to multicall if not a cb smart wallet #1108

mykcryptodev opened this issue Aug 20, 2024 · 0 comments

Comments

@mykcryptodev
Copy link
Contributor

Describe the solution you'd like

When executing a multiple transactions inside of one transaction component, I would like the behavior to remain unchanged for coinbase smart wallets (a batch tx) however, for EOAs and other wallets that do not support batched transactions, I would like the transaction component to automatically fallback to a multicall.

This would allow me as a developer to write the transaction button once and support multiple transactions for all wallets.

This example code will work for a coinbase smart wallet but not an EOA like metamask:

export const Pay: FC<Props> = ({ split, id }) => {
  const { address } = useAccount();
 
  const contracts = [
    {
      address: USDC_ADDRESS,
      abi: erc20Abi,
      functionName: 'approve',
      args: [SPLIT_IT_CONTRACT_ADDRESS, split.amountPerPerson],
    },
    {
      address: SPLIT_IT_CONTRACT_ADDRESS,
      abi: splitItAbi,
      functionName: 'pay',
      args: [
        BigInt(id),
        address,
        address,
        "test name",
        "test comment"
      ],
    },
  ];
 
  return address ? (
    <Transaction
      address={SPLIT_IT_CONTRACT_ADDRESS}
      chainId={CHAIN.id}
      contracts={contracts}
    >
      <TransactionButton text="Pay" />
      <TransactionSponsor />
      <TransactionStatus>
        <TransactionStatusLabel />
        <TransactionStatusAction />
      </TransactionStatus>
    </Transaction>  
  ) : (
    <Wallet>
      <ConnectWallet>
        <Avatar className='h-6 w-6' />
        <Name />
      </ConnectWallet>
    </Wallet>
  );
}

Describe alternatives you've considered.

To accomplish this today, I will need to detect if the user is not connected with a cb smart wallet and then write a new transaction component for the multicall. This means that if I make a change to how the transactions work, I will need to remember to update the logic in multiple places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant