diff --git a/NodeView/Components/Config/Validator.razor b/NodeView/Components/Config/Validator.razor index 3c97cee..12b240c 100644 --- a/NodeView/Components/Config/Validator.razor +++ b/NodeView/Components/Config/Validator.razor @@ -34,7 +34,7 @@ diff --git a/NodeView/Pages/Index.razor b/NodeView/Pages/Index.razor index 644218b..9b37949 100644 --- a/NodeView/Pages/Index.razor +++ b/NodeView/Pages/Index.razor @@ -24,7 +24,7 @@ { var copy = i; + @onclick="() => { env = networks[copy].env; networkName = networks[copy].name; chainUrl = networks[copy].url; resolverAddress = networks[copy].resolverAddress; SetAllValues(copy); }"> } @@ -42,6 +42,11 @@ +
+ Environment (Dev = 0, Staging = 1, Production = 2) + +
+
Chain URL @@ -136,6 +141,7 @@ @code { struct LitNetwork { public string name; + public byte env; // 0 = dev, 1 = staging, 2 = prod public string url; public int chainId; public string resolverAddress; @@ -145,16 +151,18 @@ string? chainUrl; string? resolverAddress; string? defaultPrivateKey; - + byte env = 0; LitNetwork[] networks = new LitNetwork[] { - new LitNetwork() { name = "Localhost", url = "https://127.0.0.1:8545", chainId=0 , resolverAddress = "0x5FbDB2315678afecb367f032d93F642f64180aa3" , selected=false }, - new LitNetwork() { name = "DevInternal", url = "https://lit-protocol.calderachain.xyz/http", chainId=175177, resolverAddress = "0xFFb9afC9e8B731CB5d4194ec728657875510a8C8", selected=false }, - new LitNetwork() { name = "Cayenne", url = "https://lit-protocol.calderachain.xyz/http", chainId=175177 , resolverAddress = "0xB0cb99e69c01Bd481aeCc6DD0155d4147e96C746" , selected=false}, - new LitNetwork() { name = "Manzano", url = "https://lit-protocol.calderachain.xyz/http", chainId=175177 , resolverAddress = "0x9F0Ede26261451C5E784DC799D71ECf766EB7562" , selected=false}, - new LitNetwork() { name = "Habanero", url ="https://lit-protocol.calderachain.xyz/http", chainId=175177 , resolverAddress = "0xe5a7C5d908EE8996332F488cE5f636d4EBff8522" , selected=false}, + new LitNetwork() { name = "Localhost", env=0, url = "https://127.0.0.1:8545", chainId=0 , resolverAddress = "0x5FbDB2315678afecb367f032d93F642f64180aa3" , selected=false }, + new LitNetwork() { name = "DevInternal", env=0, url = "https://lit-protocol.calderachain.xyz/http", chainId=175177, resolverAddress = "0xFFb9afC9e8B731CB5d4194ec728657875510a8C8", selected=false }, + new LitNetwork() { name = "Cayenne", env=0, url = "https://lit-protocol.calderachain.xyz/http", chainId=175177 , resolverAddress = "0xB0cb99e69c01Bd481aeCc6DD0155d4147e96C746" , selected=false}, + new LitNetwork() { name = "Manzano", env=0, url = "https://lit-protocol.calderachain.xyz/http", chainId=175177 , resolverAddress = "0x9F0Ede26261451C5E784DC799D71ECf766EB7562" , selected=false}, + new LitNetwork() { name = "Habanero", env=2, url ="https://lit-protocol.calderachain.xyz/http", chainId=175177 , resolverAddress = "0xe5a7C5d908EE8996332F488cE5f636d4EBff8522" , selected=false}, }; protected override async Task OnInitializedAsync() { + if ( await localStorage.ContainKeyAsync("env") ) + env = await localStorage.GetItemAsync("env"); networkName = await localStorage.GetItemAsync("networkName"); if ( string.IsNullOrEmpty( networkName ) ) networkName = "Localhost"; chainUrl = await localStorage.GetItemAsync("url"); @@ -208,4 +216,18 @@ defaultPrivateKey = e.Value.ToString(); await localStorage.SetItemAsync("privateKey", defaultPrivateKey); } + + async void envChanged(ChangeEventArgs e) + { + + if ( e.Value == null ) return; + if ( string.IsNullOrEmpty( e.Value.ToString() ) ) return; + + try { + env = byte.Parse( e.Value.ToString() ); + await localStorage.SetItemAsync("env", env); + } catch (Exception ex) { + Console.WriteLine(ex.Message); + } + } } \ No newline at end of file diff --git a/SharedService/Resolver.cs b/SharedService/Resolver.cs index 5a9ce6d..80e5138 100644 --- a/SharedService/Resolver.cs +++ b/SharedService/Resolver.cs @@ -164,7 +164,8 @@ public async Task GetContractAddress(ContractType contractType) { var typ = GetContractTypKeccak(contractType); var resolverService = await GetContractResolverService(); - var address_bytes = await resolverService.GetContractQueryAsync(typ, env: (byte)Env.Dev); + var env = await localStorage.GetItemAsync("env"); + var address_bytes = await resolverService.GetContractQueryAsync(typ, env); return address_bytes; } @@ -177,7 +178,7 @@ public async Task> GetAllContractAddresses() { foreach (ContractType contractType in Enum.GetValues(typeof(ContractType)) ) { var typ = GetContractTypKeccak(contractType); - var env = (byte)Env.Dev; + var env = await localStorage.GetItemAsync("env"); var contract = await resolverService.GetContractQueryAsync(typ, env); contractAddresses.Add(new ContractAddress { name = contractType.ToString(), address = contract }); }