Type 'WalletUnlocked' is not assignable to type 'Account'

With the lastest fuel 0.94.0 when trying to deploy a contract with this:

// Create a wallet instance from the address
const wallet = Wallet.fromPrivateKey(process.env.WALLET_PRIVATE_KEY as string);
  
// Connect to the testnet provider
const provider = await Provider.create('https://testnet.fuel.network/v1/graphql');
  
// Set the provider for the wallet
wallet.connect(provider);

const myContract = new MyContract(
  process.env.CONTRACT_ID as string,
  wallet
);

Errors with TS error:
Argument of type ‘WalletUnlocked’ is not assignable to parameter of type ‘Account | Provider’.

According to docs WalletUnlocked is a child of BaseUnlocked is a child of Account

This is copying from the latest docs.
Help appreciated.

Thanks for reporting this, will look into it and get back to you

hey @xpluscal, I think to use the wallet with a contract, you need to connect it to a provider. Can you please try this code?

import { Wallet, Provider } from 'fuels';

// Create a provider, with the Latest Testnet URL.
const provider = await Provider.create('https://testnet.fuel.network/v1/graphql');

// Create a wallet instance from the private key and connect it to the provider
const wallet = Wallet.fromPrivateKey(process.env.WALLET_PRIVATE_KEY as string, provider);

// Instantiate the contract with the wallet
const myContract = new MyContract(
  process.env.CONTRACT_ID as string,
  wallet
);

I’ve tried that too, same result @Nazeeh21

Hey @xpluscal :wave:

I can’t see anything wrong with the code extract you’ve provided, would it be possible to share the generated types for the contract?

Also, how does this error manifest itself: is it via your IDE, or with a type checking command such as tsc?

1 Like

Hey @p.s the issue is both a ts issue in the IDE as well as when compiling the script with TS node, I’ll run it with a ts-ignore once home.

Ps: not having the issue in our tests with launchTestNode, all tests passing there.

I do not have the same error for local or testnet.

You could try upgrading to 0.94.2 but that type inheritance from WalletAccount has been around for many versions.

Could you try creating a reproduction?

1 Like

Yeah hence the confusion, as this has worked smoothly ever since (until last week that is). I’ll dig