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
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 0.12.0

### Breaking changes

- **Upstream `@novasamatech/*` → `^0.9.1`; the wire is incompatible with `0.8.x`.** A product on `@novasamatech/host-api-wrapper@^0.8.x` will no longer talk to this test host, and vice versa. Upgrade both sides in lockstep, the same way 0.9.0 required. The break is RFC-0022: `DerivationIndex` — the selector identifying an account inside a product's subtree — changed from a bare `u32` to `Enum{Index(u32), Raw([u8; 32])}`, one extra tag byte on every request carrying a product account.
- **`ProductAccount` no longer carries `name`.** `handleAccountGet` used to return `{ publicKey, name }`, but the protocol struct only has `publicKey`, so the encoder dropped the name and it was never on the wire. The field is gone from the response; `productAccounts: { "myapp.dot/0": { name, uri } }` still accepts `name`, it just documents the mapping rather than reaching the product.
- **`handleAccountGetAlias` now rejects with `GetAliasErr`, not `RequestCredentialsErr`.** Upstream split the alias errors out into their own enum, with `RingNotFound` / `NotMember` / `Rejected` / `Unknown`. An unsigned host (`accounts: []`) now answers unmapped alias requests with `GetAliasErr.Unknown`.

### Changed

- **`@parity/truapi` → `^0.6.0`** for the truapi-product integration coverage, matching what [product-sdk 0.20.0](https://github.com/paritytech/product-sdk/pull/271) ships. truapi 0.6 encodes the selector tag as `Left`/`Right` where `@novasamatech/host-api` decodes it as `Index`/`Raw` — different names, identical SCALE wire, so both connect to the same container.
- **Product-account resolution accepts either selector form.** `Index(n)` resolves exactly as the plain `n` did before, so `productAccounts` keys (`"myapp.dot/0"`) and derived addresses (`//Bob//myapp.dot/0`) are **unchanged** — no test that asserts an address needs updating. `Raw(bytes)`, previously inexpressible, is keyed and derived by its hex. Products calling through `host-api-wrapper` need no code change either: it takes the ergonomic `AccountSelector` (`number | Uint8Array`) and normalises internally. Only code that builds protocol requests by hand has to wrap its index in `derivationIndexOf()`.
- **`handleAccountGetAlias` request shape.** Now `[ProductProofContext, RingLocation]` instead of a bare `ProductAccountId`. The context is `[productId, suffix]` — structurally the same as a product account id, and the identity mapping on it — so the account a request resolves to is unchanged. `RingLocation` also changed (`{ genesisHash, ringRootHash, hints }` → `{ chainId, junctions }`); this host ignores it.
- **`handleAccountCreateProof` response shape.** Now `{ proof, contextualAlias: { context, alias }, ringIndex, ringRevision }` instead of bare proof bytes. It remains a deterministic stand-in — an sr25519 signature over the message rather than a real ring VRF, as before — with `contextualAlias` matching what `handleAccountGetAlias` returns for the same account, and `ringIndex` / `ringRevision` fixed at `0`.
- **`AllocatableResource.SmartContractAllowance` carries a selector**, so `requestResourceAllocation([{ tag: 'SmartContractAllowance', value: 0 }])` becomes `value: { tag: 'Index', value: 0 }`.

## 0.11.0

### Added
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

Lightweight test host for E2E testing embedded Polkadot dapps that use the Spektr host-container protocol (`@novasamatech/host-container`).

> **Upstream contract:** `0.9.x` tracks `@novasamatech/host-api`, `host-container`, and `host-api-wrapper` at `^0.8.0`. v0.8 is wire-incompatible with v0.7 — your product side must be on the same major as the test host.
> **Upstream contract:** `0.12.x` tracks `@novasamatech/host-api`, `host-container`, and `host-api-wrapper` at `^0.9.1`, and serves products on `@parity/truapi` `^0.6.0`. v0.9 is wire-incompatible with v0.8 (RFC-0022 changed the product-account selector on the wire) — your product side must be on the same minor as the test host.

## Why

Expand Down Expand Up @@ -277,7 +277,9 @@ createTestHostFixture({
> });
> ```
>
> Unmapped identities fall back to production-style derivation (`//Bob//dotnsId/index`). If `accounts: []` (unsigned host), unmapped `getProductAccount` / `getProductAccountAlias` calls return `err(RequestCredentialsErr.NotConnected)`, matching `polkadot-desktop`. Pre-mapped entries in `productAccounts` are still served.
> Unmapped identities fall back to production-style derivation (`//Bob//dotnsId/index`). If `accounts: []` (unsigned host), unmapped `getProductAccount` calls return `err(RequestCredentialsErr.NotConnected)` and `getProductAccountAlias` returns `err(GetAliasErr.Unknown)`, matching `polkadot-desktop`. Pre-mapped entries in `productAccounts` are still served.
>
> **Selector keys**: since RFC-0022 a product addresses its accounts with `Index(n)` or `Raw(32 bytes)` rather than a bare number. `productAccounts` keys are unchanged for plain indices — `"myapp.dot/0"` still means `Index(0)`, and the derived address is the same as before. A raw selector is keyed by its hex, e.g. `"myapp.dot/0x1234…"`.

### Payment control

Expand Down
47 changes: 47 additions & 0 deletions forum-post.md
Original file line number Diff line number Diff line change
Expand Up @@ -702,3 +702,50 @@ permission model.

1. Upgrade to `0.11.0`.
2. Nothing else — both product generations connect without configuration.

---

# host-api-test-sdk 0.12.0

Tracks upstream `@novasamatech/*@^0.9.1` ([triangle-js-sdks#239](https://github.com/paritytech/triangle-js-sdks/pull/239)) and serves products on `@parity/truapi@^0.6.0`. v0.9 is **wire-incompatible** with v0.8: RFC-0022 changes `DerivationIndex` from a bare `u32` to `Enum{Index(u32), Raw([u8; 32])}`, so your product side has to move in the same commit.

Against `0.11.0` a truapi-0.6 product fails quietly: the wrong account for any index other than `0`, `signRaw` over a different payload than the one requested, and `createTransaction` dropped without a reply. `product-sdk`'s E2E suite goes from 2 failed to 54 passed on this release.

## What changed on our side

### Product accounts take a selector, not a number (breaking)

`Index(n)` resolves exactly as the plain `n` did, so `productAccounts` keys and derived addresses are unchanged. Raw 32-byte selectors are new, keyed by hex (`"myapp.dot/0x1234…"`). The wrapper takes `number | Uint8Array` and normalises for you; hand-built requests wrap the index:

```diff
-hostApi.signRaw(enumValue("v1", { account: [dotnsId, 0], payload }));
+hostApi.signRaw(enumValue("v1", { account: [dotnsId, derivationIndexOf(0)], payload }));
```

### `accountCreateProof` returns a struct (breaking)

```diff
-const proofHex = u8aToHex(result.value);
+const proofHex = u8aToHex(result.value.proof);
```

Plus `contextualAlias`, `ringIndex`, `ringRevision`.

### `accountGetAlias` rejects with `GetAliasErr` (breaking)

Alias errors moved out of `RequestCredentialsErr` into their own enum (`RingNotFound` / `NotMember` / `Rejected` / `Unknown`).

### `SmartContractAllowance` carries a selector (breaking)

```diff
-{ tag: "SmartContractAllowance", value: 0 }
+{ tag: "SmartContractAllowance", value: { tag: "Index", value: 0 } }
```

`handleAccountSignVrf` (RFC-0023, new upstream) is not implemented — the container answers `SignVrfErr.Unknown`.

## What you need to do

1. Upgrade to `0.12.0` and move your product side to `@parity/truapi@^0.6.0` or `@novasamatech/host-api-wrapper@^0.9.1` in the same commit.
2. Through the wrapper, nothing else. Hand-built requests: wrap indices in `derivationIndexOf()` and adjust the three shapes above.
3. If your fixtures still pass `chain:`, see 0.10.0 — it is silently ignored, so any `rpcUrl` override you set is being dropped.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@parity/host-api-test-sdk",
"version": "0.11.0",
"version": "0.12.0",
"description": "Lightweight test host for Spektr product E2E testing — embeds dapps with auto-signing dev accounts, no Docker needed",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -42,12 +42,12 @@
}
},
"dependencies": {
"@novasamatech/host-api": "^0.8.8"
"@novasamatech/host-api": "^0.9.1"
},
"devDependencies": {
"@novasamatech/host-api-wrapper": "^0.8.8",
"@novasamatech/host-container": "^0.8.8",
"@parity/truapi": "^0.4.1",
"@novasamatech/host-api-wrapper": "^0.9.1",
"@novasamatech/host-container": "^0.9.1",
"@parity/truapi": "^0.6.0",
"@polkadot/keyring": "^14.0.0",
"@polkadot/types": "^16.0.0",
"@polkadot/util": "^14.0.0",
Expand Down
76 changes: 38 additions & 38 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading