Skip to content

Commit 04ff501

Browse files
authored
Merge pull request #64 from spacesprotocol/kot
Update jvm build
2 parents 518e69e + e83d6c3 commit 04ff501

17 files changed

Lines changed: 186 additions & 94 deletions

File tree

.github/workflows/publish-go.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,13 @@ jobs:
6565
run: |
6666
uniffi-bindgen-go \
6767
--library target/release/liblibveritas_uniffi.so \
68-
--out-dir go-publish/
68+
--out-dir go-gen/
69+
# Move from subdirectory to repo root so import is github.com/spacesprotocol/libveritas-go
70+
mkdir -p go-publish
71+
mv go-gen/libveritas_uniffi/* go-publish/
72+
rm -rf go-gen
73+
# Rename Go package from libveritas_uniffi to libveritas
74+
sed -i 's/^package libveritas_uniffi$/package libveritas/' go-publish/*.go
6975
7076
- name: Download all static libraries
7177
uses: actions/download-artifact@v4
@@ -90,7 +96,7 @@ jobs:
9096
echo "Patching $GO_FILE"
9197
9298
# Insert #cgo LDFLAGS before the #include line
93-
sed -i 's|// #include <libveritas_uniffi.h>|// #cgo linux,amd64 LDFLAGS: ${SRCDIR}/../native/linux-amd64/liblibveritas_uniffi.a -lm -ldl -lpthread\n// #cgo darwin,arm64 LDFLAGS: ${SRCDIR}/../native/darwin-arm64/liblibveritas_uniffi.a -framework Security -framework CoreFoundation -lm\n// #cgo windows,amd64 LDFLAGS: ${SRCDIR}/../native/windows-amd64/libveritas_uniffi.lib -lws2_32 -lbcrypt -luserenv -lntdll\n// #include <libveritas_uniffi.h>|' "$GO_FILE"
99+
sed -i 's|// #include <libveritas_uniffi.h>|// #cgo linux,amd64 LDFLAGS: ${SRCDIR}/native/linux-amd64/liblibveritas_uniffi.a -lm -ldl -lpthread\n// #cgo darwin,arm64 LDFLAGS: ${SRCDIR}/native/darwin-arm64/liblibveritas_uniffi.a -framework Security -framework CoreFoundation -lm\n// #cgo windows,amd64 LDFLAGS: ${SRCDIR}/native/windows-amd64/libveritas_uniffi.lib -lws2_32 -lbcrypt -luserenv -lntdll\n// #include <libveritas_uniffi.h>|' "$GO_FILE"
94100
95101
- name: Setup Go module
96102
run: |

.github/workflows/publish-kotlin-android.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,4 @@ jobs:
8383
AUTH=$(echo -n "${{ secrets.CENTRAL_PORTAL_USERNAME }}:${{ secrets.CENTRAL_PORTAL_PASSWORD }}" | base64)
8484
curl -f -X POST \
8585
-H "Authorization: Bearer $AUTH" \
86-
"https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/org.spacesprotocol"
86+
"https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/org.spacesprotocol?publishing_type=automatic"

.github/workflows/publish-kotlin-jvm.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,18 @@ jobs:
2626
target: x86_64-apple-darwin
2727
artifact: darwin-x86-64
2828
lib: liblibveritas_uniffi.dylib
29+
- runner: windows-latest
30+
target: x86_64-pc-windows-msvc
31+
artifact: win32-x86-64
32+
lib: libveritas_uniffi.dll
2933
runs-on: ${{ matrix.runner }}
3034
steps:
3135
- uses: actions/checkout@v4
3236

3337
- name: Install Rust
3438
uses: dtolnay/rust-toolchain@stable
39+
with:
40+
targets: ${{ matrix.target }}
3541

3642
- uses: Swatinem/rust-cache@v2
3743
with:
@@ -77,10 +83,12 @@ jobs:
7783
mkdir -p kotlin-publish/src/main/resources/linux-x86-64
7884
mkdir -p kotlin-publish/src/main/resources/darwin-aarch64
7985
mkdir -p kotlin-publish/src/main/resources/darwin-x86-64
86+
mkdir -p kotlin-publish/src/main/resources/win32-x86-64
8087
8188
cp artifacts/linux-x86-64/liblibveritas_uniffi.so kotlin-publish/src/main/resources/linux-x86-64/
8289
cp artifacts/darwin-aarch64/liblibveritas_uniffi.dylib kotlin-publish/src/main/resources/darwin-aarch64/
8390
cp artifacts/darwin-x86-64/liblibveritas_uniffi.dylib kotlin-publish/src/main/resources/darwin-x86-64/
91+
cp artifacts/win32-x86-64/libveritas_uniffi.dll kotlin-publish/src/main/resources/win32-x86-64/
8492
8593
- name: Set version
8694
run: |
@@ -115,6 +123,11 @@ jobs:
115123
jvmToolchain(17)
116124
}
117125
126+
java {
127+
withSourcesJar()
128+
withJavadocJar()
129+
}
130+
118131
publishing {
119132
publications {
120133
register<MavenPublication>("release") {
@@ -212,16 +225,13 @@ jobs:
212225
AUTH=$(echo -n "${{ secrets.CENTRAL_PORTAL_USERNAME }}:${{ secrets.CENTRAL_PORTAL_PASSWORD }}" | base64)
213226
curl -f -X POST \
214227
-H "Authorization: Bearer $AUTH" \
215-
"https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/org.spacesprotocol"
228+
"https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/org.spacesprotocol?publishing_type=automatic"
216229
217230
- name: Publish to libveritas-kotlin repo
218231
env:
219232
GH_TOKEN: ${{ secrets.KOTLIN_PUBLISH_TOKEN }}
220233
run: |
221-
VERSION="${GITHUB_REF_NAME}"
222-
if [[ ! "$GITHUB_REF" == refs/tags/* ]]; then
223-
VERSION="v0.0.0-dev.$(date +%Y%m%d%H%M%S)"
224-
fi
234+
VERSION="v${VERSION}"
225235
226236
cd kotlin-publish
227237

.github/workflows/publish-pypi.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,34 @@ permissions:
1010
contents: read
1111

1212
jobs:
13+
version:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
version: ${{ steps.ver.outputs.version }}
17+
py_version: ${{ steps.ver.outputs.py_version }}
18+
steps:
19+
- id: ver
20+
run: |
21+
VERSION="${GITHUB_REF_NAME#v}"
22+
if [[ ! "$GITHUB_REF" == refs/tags/* ]]; then
23+
VERSION="0.0.0-dev.$(date +%Y%m%d%H%M%S)"
24+
fi
25+
PY_VERSION=$(echo "$VERSION" | sed 's/-dev\./\.dev/')
26+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
27+
echo "py_version=$PY_VERSION" >> "$GITHUB_OUTPUT"
28+
1329
build:
30+
needs: version
1431
runs-on: ${{ matrix.os }}
1532
strategy:
1633
matrix:
1734
os: [ubuntu-latest, macos-latest, windows-latest]
1835
include:
1936
- os: ubuntu-latest
20-
args: ""
2137
manylinux: auto
2238
- os: macos-latest
23-
args: ""
2439
manylinux: "off"
2540
- os: windows-latest
26-
args: ""
2741
manylinux: "off"
2842
steps:
2943
- uses: actions/checkout@v4
@@ -37,15 +51,12 @@ jobs:
3751
with:
3852
python-version: "3.12"
3953

40-
- name: Set version from tag
54+
- name: Set version
4155
shell: bash
4256
run: |
43-
VERSION="${GITHUB_REF_NAME#v}"
44-
if [[ ! "$GITHUB_REF" == refs/tags/* ]]; then
45-
VERSION="0.0.0-dev.$(date +%Y%m%d%H%M%S)"
46-
fi
57+
VERSION="${{ needs.version.outputs.version }}"
58+
PY_VERSION="${{ needs.version.outputs.py_version }}"
4759
sed -i.bak "s/^version = \"0.1.0\"/version = \"$VERSION\"/" bindings/python/Cargo.toml
48-
PY_VERSION=$(echo "$VERSION" | sed 's/-dev\./\.dev/')
4960
sed -i.bak "s/^version = \"0.1.0\"/version = \"$PY_VERSION\"/" bindings/python/pyproject.toml
5061
5162
- name: Build wheels
@@ -80,4 +91,4 @@ jobs:
8091
twine upload dist/*
8192
env:
8293
TWINE_USERNAME: __token__
83-
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
94+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}

.github/workflows/publish-swift.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ jobs:
4444
- name: Prepare headers and modulemap
4545
run: |
4646
mkdir -p headers
47-
cp swift-bindings/libveritas_uniffiFFI.h headers/
48-
cp swift-bindings/libveritas_uniffiFFI.modulemap headers/module.modulemap
47+
cp swift-bindings/LibveritasFFI.h headers/
48+
cp swift-bindings/LibveritasFFI.modulemap headers/module.modulemap
4949
5050
- name: Create fat binaries with lipo
5151
run: |
@@ -97,7 +97,7 @@ jobs:
9797
CHECKSUM="${{ steps.checksum.outputs.checksum }}"
9898
9999
mkdir -p swift-publish/Sources/Libveritas
100-
cp swift-bindings/libveritas_uniffi.swift swift-publish/Sources/Libveritas/
100+
cp swift-bindings/Libveritas.swift swift-publish/Sources/Libveritas/
101101
102102
# Generate Package.swift pointing to the release asset on the main repo
103103
cat > swift-publish/Package.swift << EOF

bindings/python/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2024"
55

66
[lib]
77
crate-type = ["cdylib"]
8-
name = "libveritas_python"
8+
name = "libveritas"
99

1010
[dependencies]
1111
libveritas-uniffi = { path = "../uniffi" }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from libveritas_python import * # noqa: F401, F403
1+
from .libveritas import * # noqa: F401, F403

bindings/uniffi/src/lib.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ pub struct Zone {
114114
pub anchor: u32,
115115
pub sovereignty: String,
116116
pub handle: String,
117+
pub canonical: String,
117118
pub alias: Option<String>,
118119
pub script_pubkey: Vec<u8>,
119120
pub records: Option<Vec<u8>>,
@@ -127,6 +128,7 @@ fn zone_from_inner(z: &libveritas::Zone) -> Zone {
127128
anchor: z.anchor,
128129
sovereignty: z.sovereignty.to_string(),
129130
handle: z.handle.to_string(),
131+
canonical: z.canonical.to_string(),
130132
alias: z.alias.as_ref().map(|a| a.to_string()),
131133
script_pubkey: z.script_pubkey.as_bytes().to_vec(),
132134
records: z.records.as_ref().map(|d| d.as_slice().to_vec()),
@@ -158,6 +160,9 @@ fn zone_to_inner(z: &Zone) -> Result<libveritas::Zone, VeritasError> {
158160
let handle = SName::from_str(&z.handle).map_err(|e| VeritasError::InvalidInput {
159161
msg: format!("invalid handle: {e}"),
160162
})?;
163+
let canonical = SName::from_str(&z.canonical).map_err(|e| VeritasError::InvalidInput {
164+
msg: format!("invalid canonical: {e}"),
165+
})?;
161166
let alias = z.alias.as_ref()
162167
.map(|a| SLabel::from_str_unprefixed(a))
163168
.transpose()
@@ -217,6 +222,7 @@ fn zone_to_inner(z: &Zone) -> Result<libveritas::Zone, VeritasError> {
217222
_ => libveritas::SovereigntyState::Dependent,
218223
},
219224
handle,
225+
canonical,
220226
alias,
221227
script_pubkey: ScriptBuf::from_bytes(z.script_pubkey.clone()),
222228
records: z.records.as_ref().map(|d| sip7::RecordSet::new(d.clone())),
@@ -584,7 +590,7 @@ impl Veritas {
584590
self.inner.sovereignty_for(commitment_height).to_string()
585591
}
586592

587-
/// Verify a message with default options (expand_names: true, dev_mode: false).
593+
/// Verify a message with default options.
588594
pub fn verify(
589595
&self,
590596
ctx: &QueryContext,
@@ -603,20 +609,19 @@ impl Veritas {
603609
Ok(Arc::new(VerifiedMessage { inner }))
604610
}
605611

606-
/// Verify a message with explicit options.
612+
/// Verify a message with option flags (combine with bitwise OR).
607613
pub fn verify_with_options(
608614
&self,
609615
ctx: &QueryContext,
610616
msg: &Message,
611-
expand_names: bool,
612-
dev_mode: bool,
617+
options: u32,
613618
) -> Result<Arc<VerifiedMessage>, VeritasError> {
614619
let ctx_guard = ctx.inner.read().unwrap();
615620
let msg_inner = msg.inner.read().unwrap();
616621

617622
let inner = self
618623
.inner
619-
.verify_with_options(&ctx_guard, msg_inner.clone(), expand_names, dev_mode)
624+
.verify_with_options(&ctx_guard, msg_inner.clone(), options)
620625
.map_err(|e| VeritasError::VerificationFailed {
621626
msg: e.to_string(),
622627
})?;
@@ -715,6 +720,15 @@ impl Lookup {
715720

716721
// -- Free functions --
717722

723+
#[uniffi::export]
724+
pub fn verify_default() -> u32 { libveritas::VERIFY_DEFAULT }
725+
726+
#[uniffi::export]
727+
pub fn verify_dev_mode() -> u32 { libveritas::VERIFY_DEV_MODE }
728+
729+
#[uniffi::export]
730+
pub fn verify_enable_snark() -> u32 { libveritas::VERIFY_ENABLE_SNARK }
731+
718732
/// Hash a message with the Spaces signed-message prefix (SHA256).
719733
/// Returns the 32-byte digest suitable for Schnorr signing/verification.
720734
#[uniffi::export]

bindings/uniffi/uniffi.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[bindings.kotlin]
2+
package_name = "org.spacesprotocol.libveritas"
3+
4+
[bindings.swift]
5+
module_name = "Libveritas"
6+
7+
[bindings.python]
8+
module_name = "libveritas"

bindings/wasm/src/lib.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ use libveritas::sname::SName;
77
use serde::Serialize;
88
use spaces_nums::RootAnchor;
99

10+
#[wasm_bindgen(js_name = "VERIFY_DEFAULT")]
11+
pub fn verify_default() -> u32 { libveritas::VERIFY_DEFAULT }
12+
13+
#[wasm_bindgen(js_name = "VERIFY_DEV_MODE")]
14+
pub fn verify_dev_mode() -> u32 { libveritas::VERIFY_DEV_MODE }
15+
16+
#[wasm_bindgen(js_name = "VERIFY_ENABLE_SNARK")]
17+
pub fn verify_enable_snark() -> u32 { libveritas::VERIFY_ENABLE_SNARK }
18+
1019
/// Serialize through JSON to get human-readable serde output
1120
/// (hex hashes, string names, etc.) as a native JS object.
1221
fn to_js<T: Serialize>(val: &T) -> Result<JsValue, JsError> {
@@ -305,7 +314,7 @@ impl Veritas {
305314
self.inner.sovereignty_for(commitment_height).to_string()
306315
}
307316

308-
/// Verify a message with default options (expand_names: true, dev_mode: false).
317+
/// Verify a message with default options.
309318
pub fn verify(
310319
&self,
311320
ctx: &QueryContext,
@@ -318,18 +327,17 @@ impl Veritas {
318327
Ok(VerifiedMessage { inner })
319328
}
320329

321-
/// Verify a message with explicit options.
330+
/// Verify a message with option flags (combine with bitwise OR).
322331
#[wasm_bindgen(js_name = "verifyWithOptions")]
323332
pub fn verify_with_options(
324333
&self,
325334
ctx: &QueryContext,
326335
msg: &Message,
327-
expand_names: bool,
328-
dev_mode: bool,
336+
options: u32,
329337
) -> Result<VerifiedMessage, JsError> {
330338
let inner = self
331339
.inner
332-
.verify_with_options(&ctx.inner, msg.inner.clone(), expand_names, dev_mode)
340+
.verify_with_options(&ctx.inner, msg.inner.clone(), options)
333341
.map_err(|e| JsError::new(&e.to_string()))?;
334342
Ok(VerifiedMessage { inner })
335343
}

0 commit comments

Comments
 (0)