MeshJS / mesh

An open-source library to advance Web3 development on Cardano
https://meshjs.dev
Apache License 2.0
200 stars 55 forks source link

BUG: cannot build Transaction using AppWallet after updating SDK #246

Closed BenElferink closed 1 week ago

BenElferink commented 2 months ago

EDIT: Refer to this comment for up-to-date info on this issue.


PRE-EDIT: I use App Wallets for my web tools.

I used to be able to transact, mint, and burn, with no problems at all, this was with SDK versions:

    "@meshsdk/core": "^1.5.11-beta.7",
    "@meshsdk/react": "^1.1.10-beta.4",

However, after updating recently to:

    "@meshsdk/core": "^1.5.25",
    "@meshsdk/react": "^1.1.12",

My App Wallet errored consistently with:

Error: [Transaction] An error occurred during build: Insufficient input in transaction. shortage: {ada in inputs: 0, ada in outputs: 1189560, fee 219489
NOTE! "ada in inputs" must be >= ("ada in outputs" + fee) before adding change
and  "ada in inputs" must be == ("ada in outputs" + fee) after adding change
 }.

The wallet had at least 100 ADA, and no assets in it. Only after downgrading back to the old beta versions, was I able to mint/transact again.

HinsonSIDAN commented 3 weeks ago

Can you try 1.6.4 see if the issue persists?

BenElferink commented 1 week ago

Can you try 1.6.4 see if the issue persists?

I upgraded to the latest:

{
    "@meshsdk/core": "^1.6.9",
    "@meshsdk/react": "^1.6.9"
}

I can't create a new TX at all now. I get the following error:

Error: [Transaction] An error occurred during build: TypeError: this.initiator.getUtxos is not a function.

And yes, TypeScript too isn't happy with the AppWallet and Transaction combo after updating Mesh. Here is my code:

const provider = new BlockfrostProvider(BLOCKFROST_API_KEY)

const wallet = new AppWallet({
  networkId: 1,
  fetcher: provider,
  submitter: provider,
  key: {
    type: 'mnemonic',
    words: TRADE_APP_MNEMONIC,
  },
})

const tx = new Transaction({ initiator: wallet }) // <--- TypeScript angry
BenElferink commented 1 week ago

I'm now using the following version:

{
    "@meshsdk/core": "^1.6.12",
    "@meshsdk/react": "^1.6.12"
}

Still unable to use AppWallet as initiator in new Transaction.

HinsonSIDAN commented 1 week ago

Just checked the class type signature, AppWallet is no longer a IInitiator, please use MeshWallet instead (same way of initiating)

BenElferink commented 1 week ago

Just checked the class type signature, AppWallet is no longer a IInitiator, please use MeshWallet instead (same way of initiating)

Thanks that worked!