vechain / vechain-dapp-kit

An SDK for vechain dApp development
MIT License
1.68k stars 8 forks source link

🐛 Test & Solo-Networks fail with VeWorld since 1.0.12 #285

Closed ifavo closed 1 month ago

ifavo commented 1 month ago

I have upgraded dApp-kit to 1.0.13 and it fails to build transactions for TestNet and Solo using VeWorld.

My integration is as simple as:

        <DAppKitProvider
            nodeUrl={NODE_URL}
            genesis={genesis}
            usePersistence
        >
            <DAppKitConsumers>{children}</DAppKitConsumers>
        </DAppKitProvider>
    );

my transaction is done within react:

import { useWallet, useConnex } from '@vechain/dapp-kit-react';

// ..

  const handleSend = async () => {
        try {
            const clauses = [
                {
                    ...clauseBuilder.functionInteraction(Addresses.X2EarnApp, abiFunc, []),
                }
            ]
            // build a transaction for the given clauses
            const tx = connex.vendor.sign('tx', clauses)
                .signer(account)

            // ask the user to sign the transaction
            const { txid } = await tx.request()

            // the resulting transaction id is stored to check for its status later
            setTxId(txid)
        }
        catch (err) {
            setError(String(err))
        }
}

The transaction is prompted for signing in VeWorld and is always built with chainTag 74.

Downgrading to 1.0.11 solves the problem and it works. The issue seems to have started with 1.0.12.

Has the handling changed or is this an issue within the dapp kit?

ifavo commented 1 month ago

I must correct myself, I was able to reproduce and solve the issue by upgrading/downgrading dapp kit in a demo project and somehow it defaults back to 74 also on 1.0.11 again. Sorry for the confusion.

ifavo commented 1 month ago

I can reproduce the problem now within VeWorld:

git clone https://github.com/vechain-energy/example-buy-me-a-coffee
npm install
npm start

Within the App:

  1. connect
  2. send a transaction: this works (sends a transaction on testnet)
  3. reload
  4. send a transaction: this fails (transation is built with chainTag from main net)

The problem seems to happen due the persistence feature in VeWorld, which does seem to lose the network used during connection.

Because I don't have a repository to place this issue for VeWorld, I will re-open it here. Is there a public repo for VeWorld?

davidecarpini commented 1 month ago

we are aware of this bug, guys are working on this on the veworld side, thanks for reporting tho 🙌 I'm going to close this here

ifavo commented 1 month ago

@davidecarpini thanks a lot 🙏