Closed cold-briu closed 8 months ago
This is happening because Fuelet is not exporting the Wallet and Provider on the latest versions of the Fuels-TS, causing some methods not to exist.
The reason it works when disabling the Fuelet, is because the first wallet to load injects the window.fuel object, and its version of the SDK been exported is the one that is going to be used for all connectors.
The best way to solve this is to install the @fuel-wallet/sdk
on version 0.13.3
directly and instantiate it. In this way, the user has control over what version of the TS-SDK he is going to use.
import { Fuel } from '@fuel-wallet/sdk';
// Create a single instance of the fuel SDK for the application.
const fuel = new Fuel();
const connectionStatus = await fuel.isConnected();
console.log('Connection status:', connectionStatus);
We are working to completely removewindow.fuel
#896. Enforcing users to migrate to the SDK directly.
What version of fuels-ts are you using?
0.62
Steps to Reproduce
npx fuels typegen -i ../blog-contract/out/debug/*-abi.json -o ./src/contracts
window.fuel
as seen here:contract.provider.getGasConfig();
with the following content:TypeError: contract.provider.getGasConfig is not a function
.console.log("contract provider as JSON...", JSON.stringify(contract.provider));
and shows that the user has multiple connectors"connectors":[{"name":"Fuelet Wallet"},{"name":"Fuel Wallet"}]
contract.provider.getGasConfig()
Expected Behavior
I think there's a wider issue on how the sdk handles multiple connectors in the same scope.
For this specific case, I think that the Contract's constructor should do a stricter type enforcement in the constructor:
As seen above, the real issue is coming from the wallet provider, which is coming from
window.fuel.getWallet
but the constructor is not catching it.👉 The expected behavior is to get an exception after
BlogContractAbi__factory.connect
with some explanation such as "Can't create contract: given ProviderOrAccount is invalid"Actual Behavior
The contract instance is created even when the given provider won't work in some situations.