Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ jobs:
- run: |
cargo install uniffi-bindgen-cs --git https://github.com/NordSecurity/uniffi-bindgen-cs --tag v0.10.0+v0.29.4
uniffi-bindgen-cs --library target/liblwk.so --out-dir target
- run: python3 scripts/patch_csharp_finalize.py target/lwk.cs
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should run this also in gitlab CI

- run: ls -l target
- name: Archive csharp language interface
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -164,7 +165,7 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'

- name: Build the project
working-directory: csharp
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ jobs:
- uses: dtolnay/rust-toolchain@1.85.0
with:
targets: x86_64-apple-ios,aarch64-apple-ios,aarch64-apple-ios-sim,aarch64-apple-darwin
- uses: extractions/setup-just@v2
with:
just-version: 1.5.0 # optional semver specification, otherwise latest
- run: brew install xcodegen
- run: brew install just xcodegen
- run: just swift

csharp:
Expand All @@ -55,15 +52,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: extractions/setup-just@v2
- run: choco install just
- run: just csharp-windows
- run: ls target/release/csharp
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'
- run: cd target/release/csharp && dotnet run && cd -
- uses: actions/upload-artifact@v4
with:
name: csharp-windows
path: target/release/csharp

8 changes: 2 additions & 6 deletions .github/workflows/kotlin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,14 @@ jobs:
- name: "Set up JDK"
uses: actions/setup-java@v5
with:
distribution: jetbrains
distribution: temurin
java-version: 21
token: ${{ secrets.GITHUB_TOKEN }}

- uses: dtolnay/rust-toolchain@1.85.0
with:
targets: x86_64-linux-android, aarch64-linux-android, armv7-linux-androideabi, i686-linux-android, aarch64-apple-ios, aarch64-apple-ios-sim, x86_64-apple-ios

- uses: extractions/setup-just@v2
with:
just-version: 1.5.0 # optional semver specification, otherwise latest
- run: brew install just

- name: "Install NDK"
run: |
Expand All @@ -53,4 +50,3 @@ jobs:
name: lwk-artifact
path: lwk_bindings/android_bindings
retention-days: 1

1 change: 1 addition & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ swift: ios ios-sim
csharp-windows: build-bindings-lib
cargo install uniffi-bindgen-cs --git https://github.com/NordSecurity/uniffi-bindgen-cs --tag v0.10.0+v0.29.4
uniffi-bindgen-cs --library target/release/lwk.dll --out-dir target/release/csharp
python scripts/patch_csharp_finalize.py target/release/csharp/lwk.cs
cp target/release/lwk.dll target/release/csharp
cp lwk_bindings/tests/test_data/test-dotnet.csproj target/release/csharp
cp lwk_bindings/tests/bindings/list_transactions.cs target/release/csharp
Expand Down
1 change: 1 addition & 0 deletions lwk_bindings/csharp/LiquidWalletKit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<Company>Blockstream</Company>
<Description>C# Liquid Wallet Kit</Description>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>12.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
5 changes: 2 additions & 3 deletions lwk_bindings/tests/bindings/list_transactions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ static void Main(string[] args)
Update update = client.FullScan(wollet)!;
wollet.ApplyUpdate(update);

List<WalletTx> txList = wollet.Transactions();
WalletTx[] txList = wollet.Transactions();

Console.WriteLine("Transactions {0}:", txList.Count);
Console.WriteLine("Transactions {0}:", txList.Length);

foreach (WalletTx tx in txList) {
Console.WriteLine(tx.Txid());
}
}
}

1 change: 1 addition & 0 deletions lwk_bindings/tests/test_data/test-dotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>12.0</LangVersion>
<RootNamespace>test_dotnet</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
39 changes: 39 additions & 0 deletions scripts/patch_csharp_finalize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python3

"""Patch generated C# bindings to avoid the special `Finalize` member name."""

# Use Python instead of `sed` because this patch step runs in both Linux and
# Windows CI, and a small cross-platform script is simpler than maintaining
# shell-specific in-place replacement variants.

from __future__ import annotations

import re
import sys
from pathlib import Path


PATTERN = re.compile(r"\bFinalize(\s*\()")
REPLACEMENT = r"FinalizeLwk\1"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should call FinalizeLwk in one of our C# test/ci



def main() -> int:
if len(sys.argv) != 2:
print("usage: patch_csharp_finalize.py <path-to-lwk.cs>", file=sys.stderr)
return 1

path = Path(sys.argv[1])
content = path.read_text(encoding="utf-8")
patched, replacements = PATTERN.subn(REPLACEMENT, content)

if replacements == 0:
print(f"error: no Finalize members found in {path}", file=sys.stderr)
return 1

path.write_text(patched, encoding="utf-8")
print(f"patched {replacements} Finalize occurrences in {path}")
return 0


if __name__ == "__main__":
raise SystemExit(main())
Loading