paltalabs / soroban-react

@soroban-react is a simple, powerful framework for building modern Soroban dApps using React.
https://soroban-react.paltalabs.io/
Apache License 2.0
30 stars 15 forks source link

Read the blockchain even if account does not exist #68

Closed esteblock closed 2 months ago

esteblock commented 10 months ago

Problem: user connects wallet to read info in blockchain but account does not exist yet, to it breaks in https://github.com/paltalabs/soroban-react/blob/e5dc1d288823f4d2a4051f5d0ef787f1b23fb0dc/packages/contracts/src/contractInvoke.tsx#L52

const source = secretKey
    ? await server.getAccount(
        SorobanClient.Keypair.fromSecret(secretKey).publicKey()
      )
    : address
    ? await server?.getAccount(address)
    : new SorobanClient.Account(defaultAddress, '0')

Please do: If signAndSend ==false, try to create source with address if fails, create with defaultAddress

This will allow user to read blockchain even if connects a wallet not funded yet