Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into frontend
Browse files Browse the repository at this point in the history
Mainly to bring ETC nodes.

# Conflicts:
#	snap/snapcraft.yaml
#	src/GWallet.Backend/Config.fs
#	src/GWallet.Backend/Properties/CommonAssemblyInfo.fs
#	src/GWallet.Backend/servers.json
  • Loading branch information
knocte committed Aug 3, 2023
2 parents 41416b8 + 4cf65a7 commit ef89395
Show file tree
Hide file tree
Showing 21 changed files with 185 additions and 78 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ jobs:
run: make update-servers

conventions:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
container:
image: "ubuntu:22.04"
needs:
Expand All @@ -539,10 +539,12 @@ jobs:
submodules: false
- name: Install dependencies of commitlint
run: |
apt update
apt install --yes sudo
which sudo 2>/dev/null || (apt update && apt install --yes sudo)
sudo apt update
sudo apt install --yes git npm
sudo apt install --yes git npm curl
sudo npm install --global n
sudo n lts
# workaround for https://github.com/actions/runner/issues/2033
- name: ownership workaround
run: git config --global --add safe.directory '*'
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ form of PullRequests, you grant the intellectual property of
your contribution under the terms of the MIT licence. If you don't wish to
comply with this policy, you can keep a fork in your github account.

Please read our [F# Coding Style](https://github.com/nblockchain/conventions/blob/master/FSharpStyleGuide.md),
our [Workflow guidelines](https://github.com/nblockchain/conventions/blob/master/WorkflowGuidelines.md)
and our [Dev Roadmap](DevRoadmap.md).
Please read our [F# Coding Style](https://github.com/nblockchain/conventions/blob/master/docs/FSharpStyleGuide.md),
our [Workflow guidelines](https://github.com/nblockchain/conventions/blob/master/docs/WorkflowGuidelines.md)
and our [Dev Roadmap](docs/DevRoadmap.md).
5 changes: 3 additions & 2 deletions LICENCE.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
The MIT License

Copyright (c) 2017-2022 Andres G. Aragoneses
Copyright (c) 2017-2023 Andres G. Aragoneses
Copyright (c) 2020-2023 Node Effect Ltd (www.nodeffect.com)
Copyright (c) 2018-2019 Diginex Ltd (www.diginex.com)
Copyright (c) 2019-2021 project contributors
Copyright (c) 2019-2023 project contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
File renamed without changes.
41 changes: 31 additions & 10 deletions scripts/bump.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,19 @@ let replaceScript =

let Replace file fromStr toStr =
let baseReplaceCommand =
#if !LEGACY_FRAMEWORK
{
Command = "dotnet"
Arguments = sprintf "fsi %s" replaceScript.FullName
}
#else
match Misc.GuessPlatform() with
| Misc.Platform.Windows ->
{
Command = Path.Combine(rootDir.FullName, "scripts", "fsi.bat")
Arguments = replaceScript.FullName
}
| _ ->
#if !LEGACY_FRAMEWORK
{
Command = "dotnet"
Arguments = sprintf "fsi %s" replaceScript.FullName
}
#else
{
Command = replaceScript.FullName
Arguments = String.Empty
Expand Down Expand Up @@ -188,18 +188,39 @@ let GitTag (newFullVersion: Version) =
}
Process.Execute(gitCreateTag, Echo.Off).UnwrapDefault() |> ignore<string>

let GitDiff () =

let gitDiff =
let GitDiff() =

let gitDiffCmd =
{
Command = "git"
Arguments = "diff"
}
let gitDiffProc = Process.Execute(gitDiff, Echo.Off)
if gitDiffProc.UnwrapDefault().Length > 0 then

let gitDiff =
Process
.Execute(gitDiffCmd, Echo.Off)
.UnwrapDefault()

let gitDiffStagedCmd =
{
Command = "git"
Arguments = "diff --staged"
}

let gitDiffStaged =
Process
.Execute(gitDiffStagedCmd, Echo.Off)
.UnwrapDefault()

if gitDiff.Length > 0 then
Console.Error.WriteLine "git status is not clean"
Environment.Exit 1

if gitDiffStaged.Length > 0 then
Console.Error.WriteLine "git status is not clean (staged files)"
Environment.Exit 1

let RunUpdateServers () =
let makeCommand =
match Misc.GuessPlatform() with
Expand Down
15 changes: 14 additions & 1 deletion scripts/make.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,21 @@ match maybeTarget with
}
#endif

Process.Execute(runnerCommand, Echo.All).UnwrapDefault()
let procResult = Process.Execute(runnerCommand, Echo.All)
#if !LEGACY_FRAMEWORK
procResult.UnwrapDefault()
|> ignore<string>
#else
// in legacy mode, warnings (output to StdErr) happen even if exitCode=0
match procResult.Result with
| ProcessResultState.Error(_exitCode, _output) ->
Console.WriteLine()
Console.Out.Flush()

failwith "Unit tests failed ^"
| _ ->
()
#endif

| Some("install") ->
let buildConfig = BinaryConfig.Release
Expand Down
7 changes: 5 additions & 2 deletions scripts/snap_release.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,12 @@ else

Console.WriteLine (sprintf "About to start upload of release %s" gitTag)

// if this fails, use `snapcraft export-login` to generate a new token
let loginMsgAdvice =
"There was a problem trying to login with snapcraft, maybe the credentials expired?\r\n" +
"If that is the case, install it in the same way as in install_snapcraft.sh and perform 'snapcraft export-login snapcraft.login', then extract the contents of 'snapcraft.login' file"

Process.Execute({ Command = "snapcraft"; Arguments = "login --with snapcraft.login" }, Echo.All)
.UnwrapDefault() |> ignore<string>
.Unwrap(loginMsgAdvice) |> ignore<string>

Console.WriteLine "Login successfull. Upload starting..."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@
<PackageReference Include="NBitcoin.Altcoins" Version="3.0.8" />
<PackageReference Update="FSharp.Core" Version="4.7.0" />
<PackageReference Include="Nethereum" Version="0.95.0--date20210125-0551.git-05a29e9" />
<PackageReference Include="JsonRpcSharp" Version="0.94.0--date20201018-1119.git-05d4006" />
<PackageReference Include="JsonRpcSharp" Version="0.98.0--date20230731-1252.git-6788e32" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.24" />
<PackageReference Include="DotNetEssentials" Version="1.6.0--date20220814-0324.git-7f6e466" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="Fsdk" Version="0.6.0--date20230118-0634.git-b829db2">
<PackageReference Include="Fsdk" Version="0.6.0--date20230530-1155.git-3bb8d08">
<GeneratePathProperty></GeneratePathProperty>
</PackageReference>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<Name>GWallet.Backend</Name>
</ProjectReference>
<Reference Include="Fsdk">
<HintPath>..\..\packages\Fsdk.0.6.0--date20230118-0634.git-b829db2\lib\netstandard2.0\Fsdk.dll</HintPath>
<HintPath>..\..\packages\Fsdk.0.6.0--date20230530-1155.git-3bb8d08\lib\netstandard2.0\Fsdk.dll</HintPath>
</Reference>
<Reference Include="System.Buffers">
<HintPath>..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
Expand Down
3 changes: 1 addition & 2 deletions src/GWallet.Backend.Tests/MarshallingData.fs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ module MarshallingData =
>> InjectCurrentDir

let private ReadEmbeddedResource resourceName =
let assembly = Assembly.GetExecutingAssembly()
Config.ExtractEmbeddedResourceFileContentsFromAssembly resourceName assembly
Fsdk.Misc.ExtractEmbeddedResourceFileContents resourceName
|> Sanitize

let UnsignedSaiTransactionExampleInJson =
Expand Down
15 changes: 15 additions & 0 deletions src/GWallet.Backend/Caching.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ type CachedNetworkData =
Balances: Map<Currency,Map<PublicAddress,CachedValue<decimal>>>;
OutgoingTransactions: Map<Currency,Map<PublicAddress,Map<string,CachedValue<decimal>>>>;
}
member self.GetLeastOldDate() =
let allDates =
seq {
for KeyValue(_currency, (_price, date)) in self.UsdPrice do
yield date
for KeyValue(_currency, addressesToBalancesMap) in self.Balances do
for KeyValue(_addr, (_price, date)) in addressesToBalancesMap do
yield date
for KeyValue(_currency, addressesToTxsMap) in self.OutgoingTransactions do
for KeyValue(_addr, txHashToAmountsMap) in addressesToTxsMap do
for KeyValue(_txHash, (_amount, date)) in txHashToAmountsMap do
yield date
}
Seq.sort allDates |> Seq.rev |> Seq.tryHead

static member Empty =
{
UsdPrice = Map.empty
Expand Down
35 changes: 0 additions & 35 deletions src/GWallet.Backend/Config.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ open System.Linq
open System.Reflection
open System.Runtime.InteropServices

open Xamarin.Essentials
open Fsdk

open GWallet.Backend.FSharpUtil.UwpHacks
Expand Down Expand Up @@ -161,37 +160,3 @@ module Config =

let RemoveReadOnlyAccount (account: ReadOnlyAccount): unit =
RemoveAccount account

let ExtractEmbeddedResourceFileContentsFromAssembly (resourceName: string) (assembly: Assembly) =
let ress = String.Join(";", assembly.GetManifestResourceNames())

let fullNameOpt =
assembly.GetManifestResourceNames()
|> Seq.filter (fun aResourceName ->
aResourceName = resourceName || aResourceName.EndsWith("." + resourceName)
)
|> Seq.tryExactlyOne

match fullNameOpt with
| Some fullName ->
use stream = assembly.GetManifestResourceStream fullName
if (stream = null) then
let failMsg =
SPrintF3 "Embedded resource %s (%s) not found in assembly %s"
resourceName
fullName
assembly.FullName
failwith failMsg
use reader = new StreamReader(stream)
reader.ReadToEnd()
| None ->
let failMsg =
SPrintF3 "Embedded resource %s not found at all in assembly %s (resource names: %s)"
resourceName
assembly.FullName
ress
failwith failMsg

let ExtractEmbeddedResourceFileContents (resourceName: string) =
let assembly = Assembly.GetExecutingAssembly()
ExtractEmbeddedResourceFileContentsFromAssembly resourceName assembly
2 changes: 1 addition & 1 deletion src/GWallet.Backend/Ether/EtherServer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ module Server =
| ServerSelectionMode.Fast -> 3u
| ServerSelectionMode.Analysis -> 2u

let etcEcosystemIsMomentarilyCentralized = true
let etcEcosystemIsMomentarilyCentralized = false

let private FaultTolerantParallelClientInnerSettings (numberOfConsistentResponsesRequired: uint32)
(mode: ServerSelectionMode)
Expand Down
12 changes: 6 additions & 6 deletions src/GWallet.Backend/GWallet.Backend-legacy.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
</ItemGroup>
<ItemGroup>
<Reference Include="Fsdk">
<HintPath>..\..\packages\Fsdk.0.6.0--date20230118-0634.git-b829db2\lib\netstandard2.0\Fsdk.dll</HintPath>
<HintPath>..\..\packages\Fsdk.0.6.0--date20230530-1155.git-3bb8d08\lib\netstandard2.0\Fsdk.dll</HintPath>
</Reference>
<Reference Include="FSharp.Data">
<HintPath>..\..\packages\FSharp.Data.3.0.0\lib\net45\FSharp.Data.dll</HintPath>
Expand Down Expand Up @@ -238,7 +238,7 @@
<HintPath>..\..\packages\Microsoft.Extensions.Logging.Abstractions.1.0.2\lib\netstandard1.1\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
<Reference Include="JsonRpcSharp.TcpClient">
<HintPath>..\..\packages\JsonRpcSharp.0.94.0--date20201018-1119.git-05d4006\lib\netstandard2.0\JsonRpcSharp.TcpClient.dll</HintPath>
<HintPath>..\..\packages\JsonRpcSharp.0.98.0--date20230731-1252.git-6788e32\lib\netstandard2.0\JsonRpcSharp.TcpClient.dll</HintPath>
</Reference>
<Reference Include="System.IO.Pipes">
<HintPath>..\..\packages\System.IO.Pipes.4.3.0\lib\net46\System.IO.Pipes.dll</HintPath>
Expand All @@ -250,16 +250,16 @@
<HintPath>..\..\packages\System.Net.WebSockets.Client.4.3.2\lib\net46\System.Net.WebSockets.Client.dll</HintPath>
</Reference>
<Reference Include="JsonRpcSharp.Client">
<HintPath>..\..\packages\JsonRpcSharp.0.94.0--date20201018-1119.git-05d4006\lib\netstandard2.0\JsonRpcSharp.Client.dll</HintPath>
<HintPath>..\..\packages\JsonRpcSharp.0.98.0--date20230731-1252.git-6788e32\lib\netstandard2.0\JsonRpcSharp.Client.dll</HintPath>
</Reference>
<Reference Include="JsonRpcSharp.IpcClient">
<HintPath>..\..\packages\JsonRpcSharp.0.94.0--date20201018-1119.git-05d4006\lib\netstandard2.0\JsonRpcSharp.IpcClient.dll</HintPath>
<HintPath>..\..\packages\JsonRpcSharp.0.98.0--date20230731-1252.git-6788e32\lib\netstandard2.0\JsonRpcSharp.IpcClient.dll</HintPath>
</Reference>
<Reference Include="JsonRpcSharp.HttpClient">
<HintPath>..\..\packages\JsonRpcSharp.0.94.0--date20201018-1119.git-05d4006\lib\netstandard2.0\JsonRpcSharp.HttpClient.dll</HintPath>
<HintPath>..\..\packages\JsonRpcSharp.0.98.0--date20230731-1252.git-6788e32\lib\netstandard2.0\JsonRpcSharp.HttpClient.dll</HintPath>
</Reference>
<Reference Include="JsonRpcSharp.WebSocketClient">
<HintPath>..\..\packages\JsonRpcSharp.0.94.0--date20201018-1119.git-05d4006\lib\netstandard2.0\JsonRpcSharp.WebSocketClient.dll</HintPath>
<HintPath>..\..\packages\JsonRpcSharp.0.98.0--date20230731-1252.git-6788e32\lib\netstandard2.0\JsonRpcSharp.WebSocketClient.dll</HintPath>
</Reference>
<Reference Include="Nethereum.ABI">
<HintPath>..\..\packages\Nethereum.0.95.0--date20210125-0551.git-05a29e9\lib\netstandard2.0\Nethereum.ABI.dll</HintPath>
Expand Down
5 changes: 1 addition & 4 deletions src/GWallet.Backend/GWallet.Backend.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,10 @@
<Folder Include="Ether\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Fsdk" Version="0.6.0--date20230118-0634.git-b829db2" />
<PackageReference Include="Fsdk" Version="0.6.0--date20230530-1155.git-3bb8d08" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2">
<GeneratePathProperty></GeneratePathProperty>
</PackageReference>
<PackageReference Include="Xamarin.Essentials" Version="1.0.0">
<GeneratePathProperty></GeneratePathProperty>
</PackageReference>
<PackageReference Include="NBitcoin" Version="6.0.17">
<GeneratePathProperty></GeneratePathProperty>
</PackageReference>
Expand Down
5 changes: 4 additions & 1 deletion src/GWallet.Backend/Server.fs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ module ServerRegistry =
// there was a mistake when adding this server to geewallet's JSON: it was added in the ETC currency instead of ETH
(currency = Currency.ETC && server.ServerInfo.NetworkPath.Contains "ethrpc.mewapi.io")

// there was a typo when adding this server to geewallet's JSON, see commit 69d90fd2fc22a1f3dd9ef8793f0cd42e3b540df1
|| (currency = Currency.ETC && server.ServerInfo.NetworkPath.Contains "ethercluster.comx/")

let currency,servers = cs
Seq.filter (fun server -> not (isBlackListed currency server)) servers

Expand Down Expand Up @@ -191,7 +194,7 @@ module ServerRegistry =
} |> Map.ofSeq

let private ServersRankingBaseline =
Deserialize (Config.ExtractEmbeddedResourceFileContents ServersEmbeddedResourceFileName)
Deserialize (Fsdk.Misc.ExtractEmbeddedResourceFileContents ServersEmbeddedResourceFileName)

let MergeWithBaseline (ranking: ServerRanking): ServerRanking =
Merge ranking ServersRankingBaseline
Expand Down
2 changes: 1 addition & 1 deletion src/GWallet.Backend/ServerManager.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module ServerManager =

let UpdateServersFile () =
Infrastructure.LogInfo "INPUT:"
let baseLineServers = Config.ExtractEmbeddedResourceFileContents ServerRegistry.ServersEmbeddedResourceFileName
let baseLineServers = Fsdk.Misc.ExtractEmbeddedResourceFileContents ServerRegistry.ServersEmbeddedResourceFileName
|> ServerRegistry.Deserialize

let fromElectrumServerToGenericServerDetails (es: UtxoCoin.ElectrumServer) =
Expand Down
4 changes: 2 additions & 2 deletions src/GWallet.Backend/packages.config
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Fsdk" version="0.6.0--date20230118-0634.git-b829db2" targetFramework="net46" />
<package id="Fsdk" version="0.6.0--date20230530-1155.git-3bb8d08" targetFramework="net46" />
<package id="Common.Logging.Core" version="3.4.1" targetFramework="net46" />
<package id="DotNetEssentials" version="1.6.1--date20220823-0234.git-14ad2d3" targetFramework="net471" />
<package id="FSharp.Core" version="4.7.0" targetFramework="net461" />
<package id="FSharp.Data" version="3.0.0" targetFramework="net46" />
<package id="HtmlAgilityPack" version="1.11.24" targetFramework="net471" />
<package id="JsonRpcSharp" version="0.94.0--date20201018-1119.git-05d4006" targetFramework="net461" />
<package id="JsonRpcSharp" version="0.98.0--date20230731-1252.git-6788e32" targetFramework="net461" />
<package id="Microsoft.CSharp" version="4.3.0" targetFramework="net471" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="1.0.2" targetFramework="net46" />
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net46" />
Expand Down
Loading

0 comments on commit ef89395

Please sign in to comment.