Skip to content

Upgrade to uniffi 0.32.0 - #98

Open
kixelated wants to merge 1 commit into
NordSecurity:mainfrom
kixelated:uniffi-0.32
Open

Upgrade to uniffi 0.32.0#98
kixelated wants to merge 1 commit into
NordSecurity:mainfrom
kixelated:uniffi-0.32

Conversation

@kixelated

Copy link
Copy Markdown

(AI generated, human reviewed)

The metadata encoding changed in uniffi 0.32 even though the contract version did not, so v0.7.1+v0.31.0 cannot read a 0.32-built cdylib at all: it fails with "Invalid string data" while extracting the first constructor's metadata.

Three things needed porting:

  • Config now loads through GlobalConfig (uniffi #2866). --config takes a global config file with [defaults], [crates.<name>], and [crate-roots] sections rather than a flat uniffi.toml-shaped override, and BindgenLoader::new takes the parsed config. fixtures/uniffi.toml moves to the new shape.
  • Type::Set is new. Go has no set type, so a HashSet<T> renders as the idiomatic map[T]struct{}; the wire format is identical to a sequence.
  • Type::Box is new. It exists only for scaffolding, so it renders as its inner type.

The uniffi example and fixture crates move to the v0.32.0 tag so the fixture library carries one metadata version rather than a 0.31/0.32 mix.

MSRV goes to 1.91, which uniffi 0.32 requires.

impl_code_type_for_compound!(SequenceCodeType, "[]{}", "Sequence{}");
// Go has no set type, so a `HashSet<T>` becomes the idiomatic `map[T]struct{}`. Rust's
// `Hash + Eq` is wider than Go's comparable types, so an inner type rendering as a slice
// or map produces Go that does not compile. `MapCodeType` keys have the same bound and

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

specifically, HashSet<Vec<u8>> is problematic in Go.

The metadata encoding changed in uniffi 0.32 even though the contract version
did not, so v0.7.1+v0.31.0 cannot read a 0.32-built cdylib at all: it fails with
"Invalid string data" while extracting the first constructor's metadata.

Three things needed porting:

- Config now loads through `GlobalConfig` (uniffi #2866). `--config` takes a
  global config file with `[defaults]`, `[crates.<name>]`, and `[crate-roots]`
  sections rather than a flat `uniffi.toml`-shaped override, and
  `BindgenLoader::new` takes the parsed config. `fixtures/uniffi.toml` moves to
  the new shape.
- `Type::Set` is new. Go has no set type, so a `HashSet<T>` renders as the
  idiomatic `map[T]struct{}`; the wire format is identical to a sequence.
- `Type::Box` is new. It exists only for scaffolding, so it renders as its
  inner type.

The uniffi example and fixture crates move to the v0.32.0 tag so the fixture
library carries one metadata version rather than a 0.31/0.32 mix.

The generator's own `toml` dependency widens to `>=0.9, <2`, matching what
uniffi_bindgen declares. That range spans two semver-incompatible majors, so a
narrower range here lets cargo resolve a second `toml` and `toml::Value` stops
being one type. This is what a `cargo install` without `--locked` hits, and it
is the `new_config` build error reported in NordSecurity#96 rather than an API change.

MSRV goes to 1.91, which uniffi 0.32 requires.

Signed-off-by: Luke Curley <kixelated@gmail.com>
@poljar

poljar commented Aug 31, 2026

Copy link
Copy Markdown

For what it's worth, I tested this out and nothing seems to be broken:
matrix-org/complement-crypto#275

Though we don't use any of the new types.

maksym-neboha added a commit to UTEXO-Protocol/rgb-lib-go that referenced this pull request Sep 3, 2026
- Switch uniffi-bindgen-go to kixelated's fork (uniffi 0.32 support,
  NordSecurity/uniffi-bindgen-go#98) while upstream hasn't released +v0.32.0
- Add SSH host-alias setup with IdentitiesOnly so Cargo fetches
  rgb-consensus-s-bfa, rgb-ops-s-bfa, rgb-schemas-s-bfa using the
  correct per-repo deploy key (no key ambiguity)
- Rewrite HTTPS BFA URLs to SSH aliases via git url.insteadOf
- Set CARGO_NET_GIT_FETCH_WITH_CLI=true so system git respects SSH config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants