paletas / cosmosnetwork.net

.NET library to integrate with cosmos sdk blockchains
5 stars 0 forks source link

The "Network" field of the CosmosApiOptions doesn't appear to ever be set #2

Open Reyth3 opened 1 year ago

Reyth3 commented 1 year ago

With the following code in place:

using CosmosNetwork;
using Microsoft.Extensions.DependencyInjection;

var services = new ServiceCollection();
services.AddCosmosNetwork("https://juno-testnet-api.polkachu.com/", new CosmosApiOptions()).SetupJunoTestnet("uni-5");
var serviceProvider = services.BuildServiceProvider();
serviceProvider.UseCosmosNetwork();

var client = serviceProvider.GetRequiredService(typeof(CosmosApi)) as CosmosApi;
var wallet = client?.Wallet.GetWallet("...", new CosmosNetwork.Keys.Sources.MnemonicKeyOptions()).Result;
//wallet?.UpdateAccountInformation().Wait();
var balances = wallet?.GetBalances().Result; // <-- InvalidOperationException thrown in DirectWallet in the getter of the Address property
Console.WriteLine(balances);

Is that intentional? Is there more setup required for this to have the CosmosApiOptions load the NetworkOptions through DI? I haven't yet read through the entirety of the code, but it seems like the options never make it to the WalletApi and subsequently to the IWallet implementation itself.

paletas commented 1 year ago

Sorry, this is something I'm still playing around and have been swamped at work, I have been refactoring quite a bit and it's nowhere near ready to use, but if you still want to, on the CosmosApiOptions you will find the NetworkOptions, give it the address prefix "juno".

Address derivation is chain agnostic at a binary level, so each chain then adds its own prefix mostly so users can easily distinguish.