0xMiden / 0xMiden/wallet-adapter

`MidenFiSignerProvider` + `MidenProvider` dont work with fresh wallets and render error instead of dApp

Aperta
#86 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
2
Fork
9
Merge medio
25m
PR unite (30g)
1

Descrizione

### Packages versions

0.14.10

### Bug description

Connecting with a "new" wallet causes `MidenProvider` with `MidenFiSignerProvider` to throw an error:

`failed to import public account: account with id 0xfa33ca750261b2106bbd8aaa35a6fe not found on the network`

While it is true that account is not found on the network (as the account is fresh) we are also prevented from actually using the account as this errors out the `MidenProvider`. Since the app is wrapped in MidenProvider this then prevents the user to do anything on the dApp.

I dont think this should cause the whole provider to be errored out as then we cant use it to create say first transaction to register the account on the network and its a catch22 situation when new users need to first go to the faucet to use any dApps.

Solution would be for `MidenProvider` with `MidenFiSignerProvider` to get the state/account from wallet to which its connected.

### How can this be reproduced?

1. Create a new wallet on Miden Wallet
2. Run this small example:

```tsx
import { WalletAdapterNetwork } from '@miden-sdk/miden-wallet-adapter-base';
import { MidenFiSignerProvider } from '@miden-sdk/miden-wallet-adapter-react';
import { MidenProvider, useMiden, useSigner } from '@miden-sdk/react';

export default function App() {
return (

loading…

}
errorComponent={(e) =>

{e.message}

}
>
{/* Components here wont render upon error */}



);
}

function Connect() {
const signer = useSigner();
const { signerAccountId } = useMiden();
if (!signer) return null;
const connected = signer.isConnected && !!signerAccountId;
return (
<>
{connected && (
<>

connected ({signer.name})


{signerAccountId}



)}
{
try {
if (connected) {
await signer.disconnect();
} else {
await signer.connect();
}
} catch (e) {
console.error(e);
}
}}
>
{connected ? 'Disconnect' : 'Connect'}


);
}

```

3. Click connect and accept with Miden Wallet
4. observe error:

Image

### Relevant log output

```shell
failed to import public account: account with id 0xfa33ca750261b2106bbd8aaa35a6fe not found on the network
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Look at the MidenProvider and MidenFiSignerProvider implementations, likely in the @miden-sdk/react and @miden-sdk/miden-wallet-adapter-react packages. The error occurs when importing a public account for a fresh wallet. Start by examining the account import logic and error handling in the provider. The fix likely involves checking if the account exists on the network and allowing the provider to proceed without erroring, perhaps by setting a placeholder state. Test with the provided reproduction example to verify the fix.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
react, typescript
Ambito
backend-api-design, mobile-dev
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
65/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.