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
26 stars 13 forks source link

Freighter-api is switching horizon/soroban rpc #47

Closed esteblock closed 8 months ago

esteblock commented 9 months ago

We are doing this hack

let server =
          networkDetails &&
          new SorobanClient.Server(networkDetails.networkUrl == "https://horizon-futurenet.stellar.org" ? "https://rpc-futurenet.stellar.org" : networkDetails.networkUrl, {
            allowHttp: networkDetails.networkUrl.startsWith('http://'),
          })

We are waiting for a new freighter api in order to not to do this hack

joaquinsoza commented 8 months ago

Freighter API got an update with the new soroban rpc url

packages/core/src/SorobanReactProvider.tsx Line: 75

The TODO: is mentioned there

let server used to be like this

let server =
          networkDetails &&
          new SorobanClient.Server(networkDetails.networkUrl, {
                      allowHttp: networkDetails.networkUrl.startsWith('http://'),
          })

networkDetails has to be updated to also get the sorobanRpc and horizonRpc, not sure if networkUrl is still in use... from the freighter wallet soroban rpc is sometimes empty or undefined, when using standalone for exmaple we use horizonRpc url and with futurenet we need to use sorobanRpc url, so maybe it could be better to do something like "if sorobanRpc == undefined or empty then use horizonRpc : sorobanRpc or sorobanRpc ?? horizonRpc will depend on the freighter api response i guess

esteblock commented 8 months ago

@benjaminsalon refer to https://github.com/stellar/freighter/issues/990 and https://github.com/stellar/freighter/issues/991

esteblock commented 8 months ago

With the new Freighter Wallet (5.6.4) https://github.com/stellar/freighter/releases/tag/5.6.4 and freighter-api 1.7.1 https://www.npmjs.com/package/@stellar/freighter-api/v/1.7.1

We get something like this:

freighterApi.getNetworkDetails ~ value: 
Object { network: "CUSTOM", networkUrl: "http://horizon.com/", networkPassphrase: "pass", sorobanRpcUrl: "http://soroban.url/" }

Our server object needs to take the "sorobanRpcUrl" @benjaminsalon Please publish a new verision of @soroban-react library with freighter-api 1.7.1