Example #1
0
        public void Load()
        {
            Log.Write("Settings: Loading...");

            var nexusKind = PlayerPrefs.GetString(NexusKindTag, NexusKind.Main_Net.ToString());

            if (!Enum.TryParse <NexusKind>(nexusKind, true, out this.nexusKind))
            {
                this.nexusKind = NexusKind.Unknown;
            }

            //this.phantasmaRPCURL = PlayerPrefs.GetString(PhantasmaRPCTag, GetDefaultValue(PhantasmaRPCTag));
            this.phantasmaBPURL = PlayerPrefs.GetString(PhantasmaBPTag, GetDefaultValue(PhantasmaBPTag));
            this.neoRPCURL      = PlayerPrefs.GetString(NeoRPCTag, GetDefaultValue(NeoRPCTag));
            this.neoscanURL     = PlayerPrefs.GetString(NeoscanAPITag, GetDefaultValue(NeoscanAPITag));
            this.nexusName      = PlayerPrefs.GetString(NexusNameTag, GetDefaultValue(NexusNameTag));

            this.currency = PlayerPrefs.GetString(CurrencyTag, "USD");
            this.sfx      = PlayerPrefs.GetInt(SFXTag, 1) != 0;

            this.phantasmaRPCURL = this.phantasmaBPURL;

            var defaultGasPrice = 100000;

            if (!BigInteger.TryParse(PlayerPrefs.GetString(GasPriceTag, defaultGasPrice.ToString()), out feePrice))
            {
                this.feePrice = 100000;
            }

            LoadLogSettings();

            Log.Write("Settings: Load: Nexus kind: " + this.nexusKind.ToString() + "\n" +
                      "                Phantasma BP: " + this.phantasmaBPURL + "\n" +
                      "                Phantasma RPC: " + this.phantasmaRPCURL + "\n" +
                      "                Neo RPC: " + this.neoRPCURL + "\n" +
                      "                Neoscan: " + this.neoscanURL + "\n" +
                      "                Nexus name: " + this.nexusName + "\n" +
                      "                Currency: " + this.currency + "\n" +
                      "                Sfx: " + this.sfx + "\n" +
                      "                Fee price: " + this.feePrice + "\n" +
                      "                Log level: " + this.logLevel + "\n" +
                      "                Log overwrite: " + this.logOverwriteMode
                      );
        }
Example #2
0
        public void Load()
        {
            Log.Write("Settings: Loading...");

            var nexusKind = PlayerPrefs.GetString(NexusKindTag, NexusKind.Main_Net.ToString());

            if (!Enum.TryParse <NexusKind>(nexusKind, true, out this.nexusKind))
            {
                this.nexusKind = NexusKind.Unknown;
            }

            //this.phantasmaRPCURL = PlayerPrefs.GetString(PhantasmaRPCTag, GetDefaultValue(PhantasmaRPCTag));
            this.phantasmaBPURL = PlayerPrefs.GetString(PhantasmaBPTag, GetDefaultValue(PhantasmaBPTag));
            this.neoRPCURL      = PlayerPrefs.GetString(NeoRPCTag, GetDefaultValue(NeoRPCTag));
            this.neoscanURL     = PlayerPrefs.GetString(NeoscanAPITag, GetDefaultValue(NeoscanAPITag));
            this.nexusName      = PlayerPrefs.GetString(NexusNameTag, GetDefaultValue(NexusNameTag));

            this.currency = PlayerPrefs.GetString(CurrencyTag, "USD");
            this.sfx      = PlayerPrefs.GetInt(SFXTag, 0) != 0;

            this.phantasmaRPCURL = this.phantasmaBPURL;

            var defaultGasPrice = 100000;

            if (!BigInteger.TryParse(PlayerPrefs.GetString(GasPriceTag, defaultGasPrice.ToString()), out feePrice))
            {
                this.feePrice = 100000;
            }

            // Doing it in a bit more complex way to avoid decimal parsing problem for different cultures.
            var neoGasFeeString = PlayerPrefs.GetString(NeoGasFeeTag, null);

            if (!String.IsNullOrEmpty(neoGasFeeString))
            {
                if (!Decimal.TryParse(neoGasFeeString, out neoGasFee))
                {
                    this.neoGasFee = 0.001m;
                }
            }
            else
            {
                this.neoGasFee = 0.001m;
            }

            // Ethereum
            var ethereumNetwork = PlayerPrefs.GetString(EthereumNetworkTag, EthereumNetwork.Main_Net.ToString());

            if (!Enum.TryParse <EthereumNetwork>(ethereumNetwork, true, out this.ethereumNetwork))
            {
                this.ethereumNetwork = EthereumNetwork.Unknown;
            }

            this.ethereumLocalnetSoulContract = PlayerPrefs.GetString(EthereumLocalnetSoulContractTag, GetDefaultValue(EthereumLocalnetSoulContractTag));
            this.ethereumLocalnetKcalContract = PlayerPrefs.GetString(EthereumLocalnetKcalContractTag, GetDefaultValue(EthereumLocalnetKcalContractTag));

            this.ethereumRPCURL = PlayerPrefs.GetString(EthereumRPCTag, GetDefaultValue(EthereumRPCTag));
            if (!BigInteger.TryParse(PlayerPrefs.GetString(EthereumGasPriceGweiTag, "100"), out ethereumGasPriceGwei))
            {
                this.ethereumGasPriceGwei = 100;
            }
            if (!BigInteger.TryParse(PlayerPrefs.GetString(EthereumTransferGasLimitTag, "21000"), out ethereumTransferGasLimit))
            {
                this.ethereumTransferGasLimit = 21000;
            }
            if (!BigInteger.TryParse(PlayerPrefs.GetString(EthereumTokenTransferGasLimitTag, "100000"), out ethereumTokenTransferGasLimit))
            {
                this.ethereumTokenTransferGasLimit = 100000;
            }

            this.uiThemeName = PlayerPrefs.GetString(UiThemeNameTag, UiThemes.Phantasia.ToString());

            LoadLogSettings();

            this.ttrsNftSortMode  = PlayerPrefs.GetInt(TtrsNftSortModeTag, 0);
            this.nftSortDirection = PlayerPrefs.GetInt(NftSortDirectionTag, 0);

            Log.Write("Settings: Load: Nexus kind: " + this.nexusKind.ToString() + "\n" +
                      "                Phantasma BP: " + this.phantasmaBPURL + "\n" +
                      "                Phantasma RPC: " + this.phantasmaRPCURL + "\n" +
                      "                Fee price: " + this.feePrice + "\n" +
                      "                Neo RPC: " + this.neoRPCURL + "\n" +
                      "                Neoscan: " + this.neoscanURL + "\n" +
                      "                Neo GAS fee: " + this.neoGasFee + "\n" +
                      "                Ethereum network: " + this.ethereumNetwork + "\n" +
                      "                Ethereum localnet SOUL contract: " + this.ethereumLocalnetSoulContract + "\n" +
                      "                Ethereum localnet KCAL contract: " + this.ethereumLocalnetKcalContract + "\n" +
                      "                Ethereum RPC: " + this.ethereumRPCURL + "\n" +
                      "                Ethereum gas price (Gwei): " + this.ethereumGasPriceGwei + "\n" +
                      "                Ethereum transfer gas limit: " + this.ethereumTransferGasLimit + "\n" +
                      "                Ethereum token transfer gas limit: " + this.ethereumTokenTransferGasLimit + "\n" +
                      "                Nexus name: " + this.nexusName + "\n" +
                      "                Currency: " + this.currency + "\n" +
                      "                Sfx: " + this.sfx + "\n" +
                      "                UI theme: " + this.uiThemeName + "\n" +
                      "                Log level: " + this.logLevel + "\n" +
                      "                Log overwrite: " + this.logOverwriteMode + "\n" +
                      "                TTRS NFT sort mode: " + this.ttrsNftSortMode + "\n" +
                      "                NFT sort direction: " + this.nftSortDirection
                      );
        }
Example #3
0
        public void Load()
        {
            Log.Write("Settings: Loading...");

            var nexusKind = PlayerPrefs.GetString(NexusKindTag, NexusKind.Main_Net.ToString());

            if (!Enum.TryParse <NexusKind>(nexusKind, true, out this.nexusKind))
            {
                this.nexusKind = NexusKind.Unknown;
            }

            if (this.nexusKind == NexusKind.Main_Net || this.nexusKind == NexusKind.Test_Net || this.nexusKind == NexusKind.Mankini_Test_Net)
            {
                // For mainnet/testnet we always load defaults for hidden settings,
                // to avoid dealing with "stuck" values from old PG version that had different defaults.
                this.phantasmaRPCURL      = GetDefaultValue(PhantasmaRPCTag);
                this.phantasmaExplorer    = GetDefaultValue(PhantasmaExplorerTag);
                this.phantasmaNftExplorer = GetDefaultValue(PhantasmaNftExplorerTag);
                this.neoRPCURL            = GetDefaultValue(NeoRPCTag);
                this.neoscanURL           = GetDefaultValue(NeoscanAPITag);
                this.nexusName            = GetDefaultValue(NexusNameTag);
            }
            else
            {
                this.phantasmaRPCURL      = PlayerPrefs.GetString(PhantasmaRPCTag, GetDefaultValue(PhantasmaRPCTag));
                this.phantasmaExplorer    = PlayerPrefs.GetString(PhantasmaExplorerTag, GetDefaultValue(PhantasmaExplorerTag));
                this.phantasmaNftExplorer = PlayerPrefs.GetString(PhantasmaNftExplorerTag, GetDefaultValue(PhantasmaNftExplorerTag));
                this.neoRPCURL            = PlayerPrefs.GetString(NeoRPCTag, GetDefaultValue(NeoRPCTag));
                this.neoscanURL           = PlayerPrefs.GetString(NeoscanAPITag, GetDefaultValue(NeoscanAPITag));
                this.nexusName            = PlayerPrefs.GetString(NexusNameTag, GetDefaultValue(NexusNameTag));
            }

            this.currency = PlayerPrefs.GetString(CurrencyTag, "USD");
            this.sfx      = PlayerPrefs.GetInt(SFXTag, 0) != 0;

            var defaultGasPrice = 100000;

            if (!BigInteger.TryParse(PlayerPrefs.GetString(GasPriceTag, defaultGasPrice.ToString()), out feePrice))
            {
                this.feePrice = defaultGasPrice;
            }

            var defaultGasLimit = 1600;

            if (!BigInteger.TryParse(PlayerPrefs.GetString(GasLimitTag, defaultGasLimit.ToString()), out feeLimit))
            {
                this.feeLimit = defaultGasLimit;
            }

            // Doing it in a bit more complex way to avoid decimal parsing problem for different cultures.
            var neoGasFeeString = PlayerPrefs.GetString(NeoGasFeeTag, null);

            if (!String.IsNullOrEmpty(neoGasFeeString))
            {
                if (!Decimal.TryParse(neoGasFeeString, out neoGasFee))
                {
                    this.neoGasFee = 0.001m;
                }
            }
            else
            {
                this.neoGasFee = 0.001m;
            }

            // Ethereum
            var ethereumNetwork = PlayerPrefs.GetString(EthereumNetworkTag, EthereumNetwork.Main_Net.ToString());

            if (!Enum.TryParse <EthereumNetwork>(ethereumNetwork, true, out this.ethereumNetwork))
            {
                this.ethereumNetwork = EthereumNetwork.Unknown;
            }

            this.ethereumLocalnetSoulContract = PlayerPrefs.GetString(EthereumLocalnetSoulContractTag, GetDefaultValue(EthereumLocalnetSoulContractTag));
            this.ethereumLocalnetKcalContract = PlayerPrefs.GetString(EthereumLocalnetKcalContractTag, GetDefaultValue(EthereumLocalnetKcalContractTag));
            this.ethereumLocalnetDankContract = PlayerPrefs.GetString(EthereumLocalnetDankContractTag, GetDefaultValue(EthereumLocalnetDankContractTag));
            this.ethereumLocalnetDytContract  = PlayerPrefs.GetString(EthereumLocalnetDytContractTag, GetDefaultValue(EthereumLocalnetDytContractTag));

            if (this.ethereumNetwork == EthereumNetwork.Main_Net || this.ethereumNetwork == EthereumNetwork.Ropsten)
            {
                // For mainnet/testnet we always load defaults for hidden settings,
                // to avoid dealing with "stuck" values from old PG version that had different defaults.
                this.ethereumRPCURL = GetDefaultValue(EthereumRPCTag);
            }
            else
            {
                this.ethereumRPCURL = PlayerPrefs.GetString(EthereumRPCTag, GetDefaultValue(EthereumRPCTag));
            }

            if (!BigInteger.TryParse(PlayerPrefs.GetString(EthereumGasPriceGweiTag, "100"), out ethereumGasPriceGwei))
            {
                this.ethereumGasPriceGwei = 100;
            }
            if (!BigInteger.TryParse(PlayerPrefs.GetString(EthereumTransferGasLimitTag, "21000"), out ethereumTransferGasLimit))
            {
                this.ethereumTransferGasLimit = 21000;
            }
            if (!BigInteger.TryParse(PlayerPrefs.GetString(EthereumTokenTransferGasLimitTag, "100000"), out ethereumTokenTransferGasLimit))
            {
                this.ethereumTokenTransferGasLimit = 100000;
            }

            this.uiThemeName = PlayerPrefs.GetString(UiThemeNameTag, UiThemes.Phantasia.ToString());

            LoadLogSettings();

            this.ttrsNftSortMode  = PlayerPrefs.GetInt(TtrsNftSortModeTag, 0);
            this.nftSortMode      = PlayerPrefs.GetInt(NftSortModeTag, 0);
            this.nftSortDirection = PlayerPrefs.GetInt(NftSortDirectionTag, 0);

            var documentFolderPath = GetDocumentPath();

            this.lastVisitedFolder = PlayerPrefs.GetString(LastVisitedFolderTag, documentFolderPath);
            if (!System.IO.Directory.Exists(this.lastVisitedFolder))
            {
                this.lastVisitedFolder = documentFolderPath;
            }

            Log.Write("Settings: Load: " + ToString());
        }