@parity/product-sdk 0.0.0-dev.329.1 → 0.0.0-dev.407.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,10 @@
1
1
  export * from '@parity/product-sdk-address';
2
- import '@parity/product-sdk-chain-client';
3
2
  import '@parity/product-sdk-cloud-storage';
3
+ import '@parity/product-sdk-chain-client';
4
4
  import '@parity/product-sdk-contracts';
5
5
  import '@parity/product-sdk-crypto';
6
6
  import '@parity/product-sdk-host';
7
7
  import '@parity/product-sdk-individuality';
8
8
  import '@parity/product-sdk-local-storage';
9
- import '@parity/product-sdk-nfts';
10
9
  import '@parity/product-sdk-renderer';
11
10
  import '@parity/product-sdk-signer';
@@ -1,6 +1,6 @@
1
+ export { createApp } from '../index.js';
1
2
  export { LogEntry, LogHandler, LogLevel, Logger, LoggerConfig, configure, createLogger } from '@parity/product-sdk-logger';
2
- import { c as AppConfig, b as App } from '../types-BpWw-OJl.js';
3
- export { A as Account, d as AppInfo, C as ChainApi, a as CloudStorageApi, e as CloudStorageConfig, D as DotNsIdentitySignature, L as LocalStorageApi, S as SignMessageWithDotNsIdentityArgs, W as WalletApi } from '../types-BpWw-OJl.js';
3
+ export { A as Account, b as App, c as AppConfig, d as AppInfo, C as ChainApi, a as CloudStorageApi, e as CloudStorageConfig, D as DotNsIdentitySignature, L as LocalStorageApi, S as SignMessageWithDotNsIdentityArgs, W as WalletApi } from '../types-BpWw-OJl.js';
4
4
  export { ChainClient } from '@parity/product-sdk-chain-client';
5
5
  export { ChainDefinition, PolkadotClient, TypedApi } from 'polkadot-api';
6
6
  import '@parity/result';
@@ -10,50 +10,3 @@ import '@parity/product-sdk-signer';
10
10
  import '@parity/product-sdk-local-storage';
11
11
  import '@parity/product-sdk-cloud-storage';
12
12
  import '../dotns-CtmOwVQW.js';
13
-
14
- /**
15
- * createApp - Main entry point for the Product SDK
16
- *
17
- * Creates an App instance with wallet, storage, chain, and cloud storage APIs.
18
- */
19
-
20
- /**
21
- * Create a new Product SDK app instance
22
- *
23
- * @param config - Application configuration
24
- * @returns App instance with all APIs
25
- *
26
- * @example
27
- * ```ts
28
- * import { createApp } from '@parity/product-sdk';
29
- *
30
- * // Default: cloud storage enabled with paseo environment
31
- * const app = await createApp({
32
- * logLevel: 'info',
33
- * });
34
- *
35
- * // Custom cloud storage environment
36
- * const prodApp = await createApp({
37
- * cloudStorage: { environment: 'polkadot' },
38
- * });
39
- *
40
- * // Disable cloud storage entirely
41
- * const noCloudStorageApp = await createApp({
42
- * cloudStorage: false,
43
- * });
44
- *
45
- * // Connect wallet
46
- * const { accounts } = await app.wallet.connect();
47
- *
48
- * // Use storage
49
- * await app.localStorage.set('key', 'value');
50
- *
51
- * // Use cloud storage (check for null if it might be disabled)
52
- * if (app.cloudStorage) {
53
- * const cid = await app.cloudStorage.upload('hello world');
54
- * }
55
- * ```
56
- */
57
- declare function createApp(config?: AppConfig): Promise<App>;
58
-
59
- export { App, AppConfig, createApp };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { createApp } from './core/index.js';
2
1
  export { LogEntry, LogHandler, LogLevel, Logger, LoggerConfig, configure, createLogger } from '@parity/product-sdk-logger';
3
- export { A as Account, b as App, c as AppConfig, d as AppInfo, C as ChainApi, a as CloudStorageApi, D as DotNsIdentitySignature, L as LocalStorageApi, S as SignMessageWithDotNsIdentityArgs, W as WalletApi } from './types-BpWw-OJl.js';
2
+ import { c as AppConfig, b as App } from './types-BpWw-OJl.js';
3
+ export { A as Account, d as AppInfo, C as ChainApi, a as CloudStorageApi, D as DotNsIdentitySignature, L as LocalStorageApi, S as SignMessageWithDotNsIdentityArgs, W as WalletApi } from './types-BpWw-OJl.js';
4
4
  export { Result, err, isErrorOf, ok } from '@parity/result';
5
5
  export { SdkError, isSdkError } from '@parity/product-sdk-errors';
6
6
  export { isInsideContainer, isInsideContainerSync } from '@parity/product-sdk-host';
@@ -10,3 +10,50 @@ export { createLocalKvStore } from '@parity/product-sdk-local-storage';
10
10
  export { CloudStorageClient, calculateCid } from '@parity/product-sdk-cloud-storage';
11
11
  export { ChainDefinition, PolkadotClient, TypedApi } from 'polkadot-api';
12
12
  import './dotns-CtmOwVQW.js';
13
+
14
+ /**
15
+ * createApp - Main entry point for the Product SDK
16
+ *
17
+ * Creates an App instance with wallet, storage, chain, and cloud storage APIs.
18
+ */
19
+
20
+ /**
21
+ * Create a new Product SDK app instance
22
+ *
23
+ * @param config - Application configuration
24
+ * @returns App instance with all APIs
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { createApp } from '@parity/product-sdk';
29
+ *
30
+ * // Default: cloud storage enabled with paseo environment
31
+ * const app = await createApp({
32
+ * logLevel: 'info',
33
+ * });
34
+ *
35
+ * // Custom cloud storage environment
36
+ * const prodApp = await createApp({
37
+ * cloudStorage: { environment: 'polkadot' },
38
+ * });
39
+ *
40
+ * // Disable cloud storage entirely
41
+ * const noCloudStorageApp = await createApp({
42
+ * cloudStorage: false,
43
+ * });
44
+ *
45
+ * // Connect wallet
46
+ * const { accounts } = await app.wallet.connect();
47
+ *
48
+ * // Use storage
49
+ * await app.localStorage.set('key', 'value');
50
+ *
51
+ * // Use cloud storage (check for null if it might be disabled)
52
+ * if (app.cloudStorage) {
53
+ * const cid = await app.cloudStorage.upload('hello world');
54
+ * }
55
+ * ```
56
+ */
57
+ declare function createApp(config?: AppConfig): Promise<App>;
58
+
59
+ export { App, AppConfig, createApp };
@@ -3,6 +3,7 @@ export * from '@parity/product-sdk-local-storage/testing';
3
3
  export * from '@parity/product-sdk-signer/testing';
4
4
  export * from '@parity/product-sdk-contracts/testing';
5
5
  export * from '@parity/product-sdk-host/testing';
6
+ export * from '@parity/product-sdk-individuality/testing';
6
7
  import '@parity/product-sdk-logger';
7
8
  import '@parity/product-sdk-cloud-storage';
8
9
  import '@parity/result';
@@ -6,6 +6,7 @@ import { err, ok } from '@parity/result';
6
6
  export * from '@parity/product-sdk-signer/testing';
7
7
  export * from '@parity/product-sdk-contracts/testing';
8
8
  export * from '@parity/product-sdk-host/testing';
9
+ export * from '@parity/product-sdk-individuality/testing';
9
10
 
10
11
  var textEncoder = new TextEncoder();
11
12
  function makeFakeWallet(options) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/testing.ts"],"names":[],"mappings":";;;;;;;;;AA2BA,IAAM,WAAA,GAAc,IAAI,WAAA,EAAY;AAwCpC,SAAS,eAAe,OAAA,EAAwC;AAC5D,EAAA,MAAM,QAAA,GAAW,OAAA,EAAS,QAAA,IAAY,EAAC;AACvC,EAAA,IAAI,QAAA,GAAW,SAAS,QAAA,KAAa,MAAA,GAAY,QAAQ,QAAA,GAAY,QAAA,CAAS,CAAC,CAAA,IAAK,IAAA;AACpF,EAAA,MAAM,SAAA,GAAY,OAAA,EAAS,SAAA,IAAa,IAAI,WAAW,EAAE,CAAA;AACzD,EAAA,MAAM,SAAA,uBAAgB,GAAA,EAAuC;AAC7D,EAAA,MAAM,SAAS,MAAM;AACjB,IAAA,KAAA,MAAW,CAAA,IAAK,SAAA,EAAW,CAAA,CAAE,QAAQ,CAAA;AAAA,EACzC,CAAA;AAEA,EAAA,OAAO;AAAA,IACH,MAAM,OAAA,GAAU;AACZ,MAAA,OAAO,EAAE,QAAA,EAAS;AAAA,IACtB,CAAA;AAAA,IACA,MAAM,UAAA,GAAa;AACf,MAAA,QAAA,GAAW,IAAA;AACX,MAAA,MAAA,EAAO;AAAA,IACX,CAAA;AAAA,IACA,WAAA,GAAc;AACV,MAAA,OAAO,QAAA;AAAA,IACX,CAAA;AAAA,IACA,kBAAA,GAAqB;AACjB,MAAA,OAAO,QAAA;AAAA,IACX,CAAA;AAAA,IACA,cAAc,OAAA,EAAS;AACnB,MAAA,QAAA,GAAW,SAAS,IAAA,CAAK,CAAC,MAAM,CAAA,CAAE,OAAA,KAAY,OAAO,CAAA,IAAK,IAAA;AAC1D,MAAA,MAAA,EAAO;AAAA,IACX,CAAA;AAAA,IACA,MAAM,WAAA,GAAc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AAA,CAAI,GAAG,CAAA;AAC3B,MAAA,IAAI,CAAC,KAAA,EAAO;AACR,QAAA,OAAO,GAAA;AAAA,UACH,IAAI,wBAAA;AAAA,YACA,gDAAgD,GAAG,CAAA;AAAA;AACvD,SACJ;AAAA,MACJ;AACA,MAAA,OAAO,GAAG,KAAK,CAAA;AAAA,IACnB,CAAA;AAAA,IACA,MAAM,WAAW,IAAA,EAAM;AACnB,MAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAC,CAAA;AAAA,IAC9B;AAAA,GACJ;AACJ;AAEA,SAAS,qBAAA,GAAkC;AACvC,EAAA,MAAM,OAAO,MAAa;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACN;AAAA,KAGJ;AAAA,EACJ,CAAA;AAEA,EAAA,OAAO;AAAA,IACH,SAAA,EAAW,IAAA;AAAA,IACX,YAAA,EAAc,IAAA;AAAA,IACd,OAAA,EAAS,IAAA;AAAA,IACT,aAAa,MAAM,KAAA;AAAA,IACnB,YAAY,MAAM;AAAA,IAAC;AAAA,GACvB;AACJ;AAsBO,SAAS,cAAc,OAAA,EAAqC;AAC/D,EAAA,MAAM,IAAA,GAAO,SAAS,IAAA,IAAQ,UAAA;AAC9B,EAAA,OAAO;AAAA,IACH,MAAA,EAAQ,cAAA,CAAe,OAAA,EAAS,MAAM,CAAA;AAAA,IACtC,YAAA,EAAc,OAAA,EAAS,YAAA,IAAgB,oBAAA,EAAqB;AAAA,IAC5D,KAAA,EAAO,OAAA,EAAS,KAAA,IAAS,qBAAA,EAAsB;AAAA,IAC/C,cACI,OAAA,EAAS,YAAA,KAAiB,MAAA,GAAY,OAAA,CAAQ,eAAe,oBAAA,EAAqB;AAAA,IACtF,UAAA,EAAY,OAAO,EAAE,IAAA,EAAK;AAAA,GAC9B;AACJ","file":"index.js","sourcesContent":["// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Test fakes for `@parity/product-sdk` (umbrella).\n *\n * `createFakeApp` returns a fake {@link App} — use it directly in logic tests or\n * hand it to `ProductSDKContext.Provider` for React component tests, so code that\n * calls `useProductSDK()` / `useWallet()` runs with no host. This entry also\n * re-exports every package's fakes, for a single meta-package import.\n *\n * @packageDocumentation\n */\nimport { ProductCloudStorageError } from \"@parity/product-sdk-cloud-storage\";\nimport type { LocalKvStore } from \"@parity/product-sdk-local-storage\";\nimport { createFakeHostLocalStorage } from \"@parity/product-sdk-local-storage/testing\";\nimport { createLocalStorageApi } from \"./core/local-storage-api.js\";\nimport { err, ok, unwrapErr, unwrapOk } from \"@parity/result\";\n\nimport type {\n Account,\n App,\n ChainApi,\n CloudStorageApi,\n LocalStorageApi,\n WalletApi,\n} from \"./core/types.js\";\n\nconst textEncoder = new TextEncoder();\n\n// Re-export the per-package fakes so `@parity/product-sdk/testing` is a one-stop import.\n// statement-store is deliberately absent: the umbrella doesn't wrap that package, so apps\n// using it depend on it directly — import `@parity/product-sdk-statement-store/testing`\n// there instead. Re-exporting its fake here would add a dependency the umbrella otherwise\n// doesn't have and could skew against the version the app actually installs.\nexport * from \"@parity/product-sdk-local-storage/testing\";\nexport * from \"@parity/product-sdk-signer/testing\";\nexport * from \"@parity/product-sdk-contracts/testing\";\nexport * from \"@parity/product-sdk-host/testing\";\n\n/** Configurable behavior for the fake {@link WalletApi}. */\nexport interface FakeWalletOptions {\n /** Accounts `connect()` / `getAccounts()` expose. Default: none. */\n accounts?: Account[];\n /** Initially selected account. Default: the first account, or `null`. */\n selected?: Account | null;\n /** Bytes returned by `signMessage` / `createProof`. Default: 64 zero bytes. */\n signature?: Uint8Array;\n /** Value returned by `getProductAccount()`. Default: the selected account. */\n productAccount?: Account | null;\n /** Value returned by `getAnonymousAlias()`. Default: `null`. */\n anonymousAlias?: string | null;\n}\n\n/** Options for {@link createFakeApp}. */\nexport interface CreateFakeAppOptions {\n /** App name reported by `getAppInfo()`. Default: `\"fake-app\"`. */\n name?: string;\n /** Configure the fake wallet. */\n wallet?: FakeWalletOptions;\n /** Override the local-storage API. Default: in-memory (backed by `createFakeHostLocalStorage`). */\n localStorage?: LocalStorageApi;\n /** Override the chain API. Default: unconfigured (throws until you provide one). */\n chain?: ChainApi;\n /** Override cloud storage, or pass `null` to disable it. Default: an in-memory fake. */\n cloudStorage?: CloudStorageApi | null;\n}\n\nfunction makeFakeWallet(options?: FakeWalletOptions): WalletApi {\n const accounts = options?.accounts ?? [];\n let selected = options?.selected !== undefined ? options.selected : (accounts[0] ?? null);\n const signature = options?.signature ?? new Uint8Array(64);\n const listeners = new Set<(account: Account | null) => void>();\n const notify = () => {\n for (const l of listeners) l(selected);\n };\n\n return {\n async connect() {\n return { accounts };\n },\n async disconnect() {\n selected = null;\n notify();\n },\n getAccounts() {\n return accounts;\n },\n getSelectedAccount() {\n return selected;\n },\n selectAccount(address) {\n selected = accounts.find((a) => a.address === address) ?? null;\n notify();\n },\n async signMessage() {\n return signature;\n },\n async signMessageWithDotNsIdentity(args) {\n return {\n username: args.username ?? \"alice\",\n accountId: `0x${\"00\".repeat(32)}`,\n signature,\n };\n },\n onAccountChange(callback) {\n listeners.add(callback);\n return () => {\n listeners.delete(callback);\n };\n },\n getProductAccount() {\n return options?.productAccount !== undefined ? options.productAccount : selected;\n },\n getAnonymousAlias() {\n return options?.anonymousAlias ?? null;\n },\n async createProof() {\n return signature;\n },\n };\n}\n\nfunction makeFakeLocalStorage(): LocalStorageApi {\n // Route through the *same* `createLocalStorageApi` factory `createApp` uses,\n // so the fake and the shipped adapter cannot drift (#344). The fake's host\n // is adapted to a `LocalKvStore` here rather than via the async\n // `createLocalKvStore`, so `createFakeApp` stays synchronous; the semantics\n // (get \"\" -> null, getJSON undefined -> null) match `createHostBackend`.\n const host = createFakeHostLocalStorage();\n const kv: LocalKvStore = {\n async get(key) {\n return (await host.readString(key)) || null;\n },\n async set(key, value) {\n await host.writeString(key, value);\n },\n async getJSON<T>(key: string) {\n return ((await host.readJSON(key)) ?? null) as T | null;\n },\n async setJSON(key, value) {\n await host.writeJSON(key, value);\n },\n async remove(key) {\n await host.clear(key);\n },\n };\n return createLocalStorageApi(kv);\n}\n\nfunction makeFakeCloudStorage(): CloudStorageApi {\n const store = new Map<string, Uint8Array>();\n const toBytes = (data: string | Uint8Array) =>\n typeof data === \"string\" ? textEncoder.encode(data) : data;\n // Deterministic content-addressed id so upload / computeCid / fetch line up.\n const cidOf = (bytes: Uint8Array) => {\n let h = 0x811c9dc5;\n for (const b of bytes) {\n h ^= b;\n h = Math.imul(h, 0x01000193);\n }\n return `bafyfake${(h >>> 0).toString(16).padStart(8, \"0\")}`;\n };\n return {\n async upload(data) {\n const bytes = toBytes(data);\n const cid = cidOf(bytes);\n store.set(cid, bytes);\n return ok(cid);\n },\n async fetch(cid) {\n const bytes = store.get(cid);\n if (!bytes) {\n return err(\n new ProductCloudStorageError(\n `fake cloud storage: no object stored for CID ${cid}`,\n ),\n );\n }\n return ok(bytes);\n },\n async computeCid(data) {\n return cidOf(toBytes(data));\n },\n };\n}\n\nfunction makeUnconfiguredChain(): ChainApi {\n const fail = (): never => {\n throw new Error(\n \"createFakeApp: `chain` is not configured. Pass a `chain` override in options. \" +\n \"There is no chain-read fake — the host owns RPC selection; test chain-reading \" +\n \"logic behind your own interface and cover the real wiring in e2e.\",\n );\n };\n // Reads throw (fail fast, no silent undefined); state queries stay quiet.\n return {\n getClient: fail,\n getRawClient: fail,\n connect: fail,\n isConnected: () => false,\n destroyAll: () => {},\n };\n}\n\n/**\n * Create a fake {@link App}. Wallet, local-storage, and cloud-storage are working\n * in-memory fakes; `chain` is unconfigured until you override it. Every sub-API\n * is overridable.\n *\n * @example\n * ```ts\n * import { createFakeApp } from \"@parity/product-sdk/testing\";\n *\n * const app = createFakeApp({ wallet: { accounts: [alice, bob], selected: alice } });\n * await app.wallet.connect();\n * expect(app.wallet.getAccounts()).toHaveLength(2);\n * ```\n *\n * For React, feed the fake to the exported context:\n * ```tsx\n * import { ProductSDKContext } from \"@parity/product-sdk/react\";\n * render(<ProductSDKContext.Provider value={app}><AccountPicker /></ProductSDKContext.Provider>);\n * ```\n */\nexport function createFakeApp(options?: CreateFakeAppOptions): App {\n const name = options?.name ?? \"fake-app\";\n return {\n wallet: makeFakeWallet(options?.wallet),\n localStorage: options?.localStorage ?? makeFakeLocalStorage(),\n chain: options?.chain ?? makeUnconfiguredChain(),\n cloudStorage:\n options?.cloudStorage !== undefined ? options.cloudStorage : makeFakeCloudStorage(),\n getAppInfo: () => ({ name }),\n };\n}\n\nif (import.meta.vitest) {\n const { describe, test, expect } = import.meta.vitest;\n\n const alice: Account = { address: \"5Alice\", name: \"Alice\", source: \"dev\" };\n const bob: Account = { address: \"5Bob\", name: \"Bob\", source: \"dev\" };\n\n describe(\"createFakeApp\", () => {\n test(\"wallet lists, selects, and notifies on account change\", async () => {\n const app = createFakeApp({ wallet: { accounts: [alice, bob], selected: alice } });\n expect(app.wallet.getAccounts()).toHaveLength(2);\n expect(app.wallet.getSelectedAccount()).toEqual(alice);\n\n let changed: Account | null = null;\n app.wallet.onAccountChange((a) => {\n changed = a;\n });\n app.wallet.selectAccount(\"5Bob\");\n expect(app.wallet.getSelectedAccount()).toEqual(bob);\n expect(changed).toEqual(bob);\n\n const { accounts } = await app.wallet.connect();\n expect(accounts).toHaveLength(2);\n });\n\n test(\"localStorage round-trips and remove deletes a key\", async () => {\n const app = createFakeApp();\n await app.localStorage.set(\"k\", \"v\");\n await app.localStorage.setJSON(\"o\", { n: 1 });\n expect(await app.localStorage.get(\"k\")).toBe(\"v\");\n expect(await app.localStorage.getJSON(\"o\")).toEqual({ n: 1 });\n expect(await app.localStorage.get(\"missing\")).toBeNull();\n\n await app.localStorage.remove(\"k\");\n expect(await app.localStorage.get(\"k\")).toBeNull();\n // Untouched keys stay — there is no clear-all.\n expect(await app.localStorage.getJSON(\"o\")).toEqual({ n: 1 });\n });\n\n test(\"cloudStorage round-trips upload -> fetch; computeCid matches upload\", async () => {\n const cs = createFakeApp().cloudStorage;\n if (!cs) throw new Error(\"expected default cloud storage\");\n const cid = unwrapOk(await cs.upload(\"hello\"));\n expect(await cs.computeCid(\"hello\")).toBe(cid);\n expect(new TextDecoder().decode(unwrapOk(await cs.fetch(cid)))).toBe(\"hello\");\n expect(unwrapErr(await cs.fetch(\"bafyfakemissing\"))).toBeInstanceOf(\n ProductCloudStorageError,\n );\n });\n\n test(\"cloudStorage can be disabled with null\", () => {\n expect(createFakeApp({ cloudStorage: null }).cloudStorage).toBeNull();\n });\n\n test(\"chain is unconfigured by default\", () => {\n const app = createFakeApp();\n expect(app.chain.isConnected({} as never)).toBe(false);\n expect(() => app.chain.getClient({} as never)).toThrow(/not configured/);\n });\n\n test(\"getAppInfo reports the name\", () => {\n expect(createFakeApp({ name: \"my-app\" }).getAppInfo().name).toBe(\"my-app\");\n });\n });\n}\n"]}
1
+ {"version":3,"sources":["../../src/testing.ts"],"names":[],"mappings":";;;;;;;;;;AA2BA,IAAM,WAAA,GAAc,IAAI,WAAA,EAAY;AAyCpC,SAAS,eAAe,OAAA,EAAwC;AAC5D,EAAA,MAAM,QAAA,GAAW,OAAA,EAAS,QAAA,IAAY,EAAC;AACvC,EAAA,IAAI,QAAA,GAAW,SAAS,QAAA,KAAa,MAAA,GAAY,QAAQ,QAAA,GAAY,QAAA,CAAS,CAAC,CAAA,IAAK,IAAA;AACpF,EAAA,MAAM,SAAA,GAAY,OAAA,EAAS,SAAA,IAAa,IAAI,WAAW,EAAE,CAAA;AACzD,EAAA,MAAM,SAAA,uBAAgB,GAAA,EAAuC;AAC7D,EAAA,MAAM,SAAS,MAAM;AACjB,IAAA,KAAA,MAAW,CAAA,IAAK,SAAA,EAAW,CAAA,CAAE,QAAQ,CAAA;AAAA,EACzC,CAAA;AAEA,EAAA,OAAO;AAAA,IACH,MAAM,OAAA,GAAU;AACZ,MAAA,OAAO,EAAE,QAAA,EAAS;AAAA,IACtB,CAAA;AAAA,IACA,MAAM,UAAA,GAAa;AACf,MAAA,QAAA,GAAW,IAAA;AACX,MAAA,MAAA,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gB,oBAAA,EAAqB;AAAA,IAC5D,KAAA,EAAO,OAAA,EAAS,KAAA,IAAS,qBAAA,EAAsB;AAAA,IAC/C,cACI,OAAA,EAAS,YAAA,KAAiB,MAAA,GAAY,OAAA,CAAQ,eAAe,oBAAA,EAAqB;AAAA,IACtF,UAAA,EAAY,OAAO,EAAE,IAAA,EAAK;AAAA,GAC9B;AACJ","file":"index.js","sourcesContent":["// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Test fakes for `@parity/product-sdk` (umbrella).\n *\n * `createFakeApp` returns a fake {@link App} — use it directly in logic tests or\n * hand it to `ProductSDKContext.Provider` for React component tests, so code that\n * calls `useProductSDK()` / `useWallet()` runs with no host. This entry also\n * re-exports every package's fakes, for a single meta-package import.\n *\n * @packageDocumentation\n */\nimport { ProductCloudStorageError } from \"@parity/product-sdk-cloud-storage\";\nimport type { LocalKvStore } from \"@parity/product-sdk-local-storage\";\nimport { createFakeHostLocalStorage } from \"@parity/product-sdk-local-storage/testing\";\nimport { createLocalStorageApi } from \"./core/local-storage-api.js\";\nimport { err, ok, unwrapErr, unwrapOk } from \"@parity/result\";\n\nimport type {\n Account,\n App,\n ChainApi,\n CloudStorageApi,\n LocalStorageApi,\n WalletApi,\n} from \"./core/types.js\";\n\nconst textEncoder = new TextEncoder();\n\n// Re-export the per-package fakes so `@parity/product-sdk/testing` is a one-stop import.\n// statement-store is deliberately absent: the umbrella doesn't wrap that package, so apps\n// using it depend on it directly — import `@parity/product-sdk-statement-store/testing`\n// there instead. Re-exporting its fake here would add a dependency the umbrella otherwise\n// doesn't have and could skew against the version the app actually installs.\nexport * from \"@parity/product-sdk-local-storage/testing\";\nexport * from \"@parity/product-sdk-signer/testing\";\nexport * from \"@parity/product-sdk-contracts/testing\";\nexport * from \"@parity/product-sdk-host/testing\";\nexport * from \"@parity/product-sdk-individuality/testing\";\n\n/** Configurable behavior for the fake {@link WalletApi}. */\nexport interface FakeWalletOptions {\n /** Accounts `connect()` / `getAccounts()` expose. Default: none. */\n accounts?: Account[];\n /** Initially selected account. Default: the first account, or `null`. */\n selected?: Account | null;\n /** Bytes returned by `signMessage` / `createProof`. Default: 64 zero bytes. */\n signature?: Uint8Array;\n /** Value returned by `getProductAccount()`. Default: the selected account. */\n productAccount?: Account | null;\n /** Value returned by `getAnonymousAlias()`. Default: `null`. */\n anonymousAlias?: string | null;\n}\n\n/** Options for {@link createFakeApp}. */\nexport interface CreateFakeAppOptions {\n /** App name reported by `getAppInfo()`. Default: `\"fake-app\"`. */\n name?: string;\n /** Configure the fake wallet. */\n wallet?: FakeWalletOptions;\n /** Override the local-storage API. Default: in-memory (backed by `createFakeHostLocalStorage`). */\n localStorage?: LocalStorageApi;\n /** Override the chain API. Default: unconfigured (throws until you provide one). */\n chain?: ChainApi;\n /** Override cloud storage, or pass `null` to disable it. Default: an in-memory fake. */\n cloudStorage?: CloudStorageApi | null;\n}\n\nfunction makeFakeWallet(options?: FakeWalletOptions): WalletApi {\n const accounts = options?.accounts ?? [];\n let selected = options?.selected !== undefined ? options.selected : (accounts[0] ?? null);\n const signature = options?.signature ?? new Uint8Array(64);\n const listeners = new Set<(account: Account | null) => void>();\n const notify = () => {\n for (const l of listeners) l(selected);\n };\n\n return {\n async connect() {\n return { accounts };\n },\n async disconnect() {\n selected = null;\n notify();\n },\n getAccounts() {\n return accounts;\n },\n getSelectedAccount() {\n return selected;\n },\n selectAccount(address) {\n selected = accounts.find((a) => a.address === address) ?? null;\n notify();\n },\n async signMessage() {\n return signature;\n },\n async signMessageWithDotNsIdentity(args) {\n return {\n username: args.username ?? \"alice\",\n accountId: `0x${\"00\".repeat(32)}`,\n signature,\n };\n },\n onAccountChange(callback) {\n listeners.add(callback);\n return () => {\n listeners.delete(callback);\n };\n },\n getProductAccount() {\n return options?.productAccount !== undefined ? options.productAccount : selected;\n },\n getAnonymousAlias() {\n return options?.anonymousAlias ?? null;\n },\n async createProof() {\n return signature;\n },\n };\n}\n\nfunction makeFakeLocalStorage(): LocalStorageApi {\n // Route through the *same* `createLocalStorageApi` factory `createApp` uses,\n // so the fake and the shipped adapter cannot drift (#344). The fake's host\n // is adapted to a `LocalKvStore` here rather than via the async\n // `createLocalKvStore`, so `createFakeApp` stays synchronous; the semantics\n // (get \"\" -> null, getJSON undefined -> null) match `createHostBackend`.\n const host = createFakeHostLocalStorage();\n const kv: LocalKvStore = {\n async get(key) {\n return (await host.readString(key)) || null;\n },\n async set(key, value) {\n await host.writeString(key, value);\n },\n async getJSON<T>(key: string) {\n return ((await host.readJSON(key)) ?? null) as T | null;\n },\n async setJSON(key, value) {\n await host.writeJSON(key, value);\n },\n async remove(key) {\n await host.clear(key);\n },\n };\n return createLocalStorageApi(kv);\n}\n\nfunction makeFakeCloudStorage(): CloudStorageApi {\n const store = new Map<string, Uint8Array>();\n const toBytes = (data: string | Uint8Array) =>\n typeof data === \"string\" ? textEncoder.encode(data) : data;\n // Deterministic content-addressed id so upload / computeCid / fetch line up.\n const cidOf = (bytes: Uint8Array) => {\n let h = 0x811c9dc5;\n for (const b of bytes) {\n h ^= b;\n h = Math.imul(h, 0x01000193);\n }\n return `bafyfake${(h >>> 0).toString(16).padStart(8, \"0\")}`;\n };\n return {\n async upload(data) {\n const bytes = toBytes(data);\n const cid = cidOf(bytes);\n store.set(cid, bytes);\n return ok(cid);\n },\n async fetch(cid) {\n const bytes = store.get(cid);\n if (!bytes) {\n return err(\n new ProductCloudStorageError(\n `fake cloud storage: no object stored for CID ${cid}`,\n ),\n );\n }\n return ok(bytes);\n },\n async computeCid(data) {\n return cidOf(toBytes(data));\n },\n };\n}\n\nfunction makeUnconfiguredChain(): ChainApi {\n const fail = (): never => {\n throw new Error(\n \"createFakeApp: `chain` is not configured. Pass a `chain` override in options. \" +\n \"There is no chain-read fake — the host owns RPC selection; test chain-reading \" +\n \"logic behind your own interface and cover the real wiring in e2e.\",\n );\n };\n // Reads throw (fail fast, no silent undefined); state queries stay quiet.\n return {\n getClient: fail,\n getRawClient: fail,\n connect: fail,\n isConnected: () => false,\n destroyAll: () => {},\n };\n}\n\n/**\n * Create a fake {@link App}. Wallet, local-storage, and cloud-storage are working\n * in-memory fakes; `chain` is unconfigured until you override it. Every sub-API\n * is overridable.\n *\n * @example\n * ```ts\n * import { createFakeApp } from \"@parity/product-sdk/testing\";\n *\n * const app = createFakeApp({ wallet: { accounts: [alice, bob], selected: alice } });\n * await app.wallet.connect();\n * expect(app.wallet.getAccounts()).toHaveLength(2);\n * ```\n *\n * For React, feed the fake to the exported context:\n * ```tsx\n * import { ProductSDKContext } from \"@parity/product-sdk/react\";\n * render(<ProductSDKContext.Provider value={app}><AccountPicker /></ProductSDKContext.Provider>);\n * ```\n */\nexport function createFakeApp(options?: CreateFakeAppOptions): App {\n const name = options?.name ?? \"fake-app\";\n return {\n wallet: makeFakeWallet(options?.wallet),\n localStorage: options?.localStorage ?? makeFakeLocalStorage(),\n chain: options?.chain ?? makeUnconfiguredChain(),\n cloudStorage:\n options?.cloudStorage !== undefined ? options.cloudStorage : makeFakeCloudStorage(),\n getAppInfo: () => ({ name }),\n };\n}\n\nif (import.meta.vitest) {\n const { describe, test, expect } = import.meta.vitest;\n\n const alice: Account = { address: \"5Alice\", name: \"Alice\", source: \"dev\" };\n const bob: Account = { address: \"5Bob\", name: \"Bob\", source: \"dev\" };\n\n describe(\"createFakeApp\", () => {\n test(\"wallet lists, selects, and notifies on account change\", async () => {\n const app = createFakeApp({ wallet: { accounts: [alice, bob], selected: alice } });\n expect(app.wallet.getAccounts()).toHaveLength(2);\n expect(app.wallet.getSelectedAccount()).toEqual(alice);\n\n let changed: Account | null = null;\n app.wallet.onAccountChange((a) => {\n changed = a;\n });\n app.wallet.selectAccount(\"5Bob\");\n expect(app.wallet.getSelectedAccount()).toEqual(bob);\n expect(changed).toEqual(bob);\n\n const { accounts } = await app.wallet.connect();\n expect(accounts).toHaveLength(2);\n });\n\n test(\"localStorage round-trips and remove deletes a key\", async () => {\n const app = createFakeApp();\n await app.localStorage.set(\"k\", \"v\");\n await app.localStorage.setJSON(\"o\", { n: 1 });\n expect(await app.localStorage.get(\"k\")).toBe(\"v\");\n expect(await app.localStorage.getJSON(\"o\")).toEqual({ n: 1 });\n expect(await app.localStorage.get(\"missing\")).toBeNull();\n\n await app.localStorage.remove(\"k\");\n expect(await app.localStorage.get(\"k\")).toBeNull();\n // Untouched keys stay — there is no clear-all.\n expect(await app.localStorage.getJSON(\"o\")).toEqual({ n: 1 });\n });\n\n test(\"cloudStorage round-trips upload -> fetch; computeCid matches upload\", async () => {\n const cs = createFakeApp().cloudStorage;\n if (!cs) throw new Error(\"expected default cloud storage\");\n const cid = unwrapOk(await cs.upload(\"hello\"));\n expect(await cs.computeCid(\"hello\")).toBe(cid);\n expect(new TextDecoder().decode(unwrapOk(await cs.fetch(cid)))).toBe(\"hello\");\n expect(unwrapErr(await cs.fetch(\"bafyfakemissing\"))).toBeInstanceOf(\n ProductCloudStorageError,\n );\n });\n\n test(\"cloudStorage can be disabled with null\", () => {\n expect(createFakeApp({ cloudStorage: null }).cloudStorage).toBeNull();\n });\n\n test(\"chain is unconfigured by default\", () => {\n const app = createFakeApp();\n expect(app.chain.isConnected({} as never)).toBe(false);\n expect(() => app.chain.getClient({} as never)).toThrow(/not configured/);\n });\n\n test(\"getAppInfo reports the name\", () => {\n expect(createFakeApp({ name: \"my-app\" }).getAppInfo().name).toBe(\"my-app\");\n });\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parity/product-sdk",
3
- "version": "0.0.0-dev.329.1",
3
+ "version": "0.0.0-dev.407.0",
4
4
  "description": "Unified SDK for building products in the Polkadot ecosystem - umbrella package",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -48,10 +48,6 @@
48
48
  "import": "./dist/individuality/index.js",
49
49
  "types": "./dist/individuality/index.d.ts"
50
50
  },
51
- "./nfts": {
52
- "import": "./dist/nfts/index.js",
53
- "types": "./dist/nfts/index.d.ts"
54
- },
55
51
  "./react": {
56
52
  "import": "./dist/react/index.js",
57
53
  "types": "./dist/react/index.d.ts"
@@ -79,22 +75,21 @@
79
75
  ],
80
76
  "dependencies": {
81
77
  "polkadot-api": "^2.1.6",
78
+ "@parity/product-sdk-cloud-storage": "0.0.0-dev.407.0",
82
79
  "@parity/product-sdk-address": "0.2.0",
83
80
  "@parity/product-sdk-crypto": "0.1.1",
84
81
  "@parity/product-sdk-contracts": "0.10.11",
85
- "@parity/product-sdk-chain-client": "0.0.0-dev.329.1",
86
- "@parity/product-sdk-cloud-storage": "0.0.0-dev.329.1",
87
82
  "@parity/product-sdk-host": "0.23.0",
88
- "@parity/product-sdk-individuality": "0.6.0",
83
+ "@parity/product-sdk-chain-client": "0.0.0-dev.407.0",
89
84
  "@parity/product-sdk-keys": "0.4.1",
90
- "@parity/result": "0.2.0",
91
85
  "@parity/product-sdk-logger": "0.1.1",
92
- "@parity/product-sdk-nfts": "0.0.0-dev.329.1",
93
- "@parity/product-sdk-errors": "0.2.0",
86
+ "@parity/result": "0.2.0",
94
87
  "@parity/product-sdk-signer": "0.15.1",
88
+ "@parity/product-sdk-errors": "0.2.0",
89
+ "@parity/product-sdk-individuality": "0.0.0-dev.407.0",
95
90
  "@parity/product-sdk-local-storage": "0.3.13",
96
- "@parity/product-sdk-tx": "0.4.11",
97
- "@parity/product-sdk-renderer": "0.3.0"
91
+ "@parity/product-sdk-renderer": "0.3.0",
92
+ "@parity/product-sdk-tx": "0.4.11"
98
93
  },
99
94
  "peerDependencies": {
100
95
  "react": "^18.0.0 || ^19.0.0"
@@ -41,6 +41,10 @@ import type {
41
41
  AirdropChain,
42
42
  ClaimChain,
43
43
  ConsumersChain,
44
+ CreditCandidatesChain,
45
+ CurrentGameWatchChain,
46
+ FeeEstimable,
47
+ CreditsChain,
44
48
  GameChain,
45
49
  GamePlayersChain,
46
50
  IndividualityChain,
@@ -49,12 +53,17 @@ import type {
49
53
  LiteSignUpChain,
50
54
  NetworkSuffixChain,
51
55
  PapiIndividualityChain,
56
+ ParticipantWatchChain,
57
+ PlayerWatchChain,
52
58
  PrizeStatusChain,
53
59
  RegisterChain,
54
60
  RegistrationEligibilityChain,
61
+ ReportChain,
55
62
  RingLocation as SdkRingLocation,
63
+ RosterChain,
56
64
  ScoreContextChain,
57
65
  SignUpChain,
66
+ SignUpFundsChain,
58
67
  AccountVrfSignature,
59
68
  VrfTranscriptItem as IndividualityVrfTranscriptItem,
60
69
  RingVRFProof as AsPersonRingVRFProof,
@@ -129,7 +138,10 @@ type FromPapiSatisfiesContracts = Assert<
129
138
  GamePlayersChain &
130
139
  ScoreContextChain &
131
140
  SignUpChain &
132
- LiteSignUpChain
141
+ LiteSignUpChain &
142
+ CreditsChain &
143
+ CreditCandidatesChain &
144
+ WatchChains
133
145
  ? true
134
146
  : false
135
147
  >;
@@ -327,12 +339,85 @@ type ClaimAirdropTakesTheDocumentedArgs = Assert<
327
339
  : false
328
340
  >;
329
341
 
342
+ // The report and offboard builders touch `tx` only. `full_report` and the two vote
343
+ // variants are pinned by name, since PAPI encodes whatever object it is handed.
344
+ type PaseoSatisfiesReportContract = Assert<PaseoClient extends ReportChain ? true : false>;
345
+ type PreviewnetSatisfiesReportContract = Assert<
346
+ PreviewnetClient extends ReportChain ? true : false
347
+ >;
348
+ type RejectsBogusReportClient = Assert<
349
+ ClientWithoutIndividuality extends ReportChain ? false : true
350
+ >;
351
+ type ReportArgs = Parameters<GameTx["report"]>[0];
352
+ type ReportTakesFullReport = Assert<"full_report" extends keyof ReportArgs ? true : false>;
353
+ type ReportVoteVariant = ReportArgs["full_report"][number][number]["type"];
354
+ type ReportVotesArePersonAndNotPerson = Assert<
355
+ [ReportVoteVariant] extends ["Person" | "NotPerson"]
356
+ ? ["Person" | "NotPerson"] extends [ReportVoteVariant]
357
+ ? true
358
+ : false
359
+ : false
360
+ >;
361
+
362
+ // The roster reads, and the candidates read that adds `Game.Game` to them. The
363
+ // batched `IndexToPlayer.getValues` takes `[round, index]` tuples as its single key.
364
+ type PaseoSatisfiesRosterContract = Assert<PaseoClient extends RosterChain ? true : false>;
365
+ type PreviewnetSatisfiesRosterContract = Assert<
366
+ PreviewnetClient extends RosterChain ? true : false
367
+ >;
368
+ type PaseoSatisfiesCreditCandidatesContract = Assert<
369
+ PaseoClient extends CreditCandidatesChain ? true : false
370
+ >;
371
+ type PreviewnetSatisfiesCreditCandidatesContract = Assert<
372
+ PreviewnetClient extends CreditCandidatesChain ? true : false
373
+ >;
374
+ type RejectsBogusRosterClient = Assert<
375
+ ClientWithoutIndividuality extends RosterChain ? false : true
376
+ >;
377
+
378
+ // The watches take `watchValue` rather than `getValue`, which the pinned contracts
379
+ // never name, so a PAPI release that changed its emission shape fails here.
380
+ type WatchChains = CurrentGameWatchChain & PlayerWatchChain & ParticipantWatchChain;
381
+ type PaseoSatisfiesWatchContracts = Assert<PaseoClient extends WatchChains ? true : false>;
382
+ type PreviewnetSatisfiesWatchContracts = Assert<
383
+ PreviewnetClient extends WatchChains ? true : false
384
+ >;
385
+ type RejectsBogusWatchClient = Assert<
386
+ ClientWithoutIndividuality extends CurrentGameWatchChain ? false : true
387
+ >;
388
+
389
+ // The credits read is the one contract typed over runtime APIs rather than storage,
390
+ // so a renamed claimant arm or a reshaped proof result fails here.
391
+ type PaseoSatisfiesCreditsContract = Assert<PaseoClient extends CreditsChain ? true : false>;
392
+ type PreviewnetSatisfiesCreditsContract = Assert<
393
+ PreviewnetClient extends CreditsChain ? true : false
394
+ >;
395
+ type DevnetPredatesTheCreditsContract = Assert<DevnetClient extends CreditsChain ? false : true>;
396
+ type RejectsBogusCreditsClient = Assert<
397
+ ClientWithoutIndividuality extends CreditsChain ? false : true
398
+ >;
399
+
330
400
  // Game sign-up.
331
401
  type PaseoSatisfiesSignUpContract = Assert<PaseoClient extends SignUpChain ? true : false>;
332
402
  type RejectsBogusSignUpClient = Assert<
333
403
  ClientWithoutIndividuality extends SignUpChain ? false : true
334
404
  >;
335
405
 
406
+ // The cost read also takes the raw client, for the chain spec that names the token.
407
+ type PaseoSatisfiesSignUpFundsContract = Assert<
408
+ PaseoClient extends SignUpFundsChain ? true : false
409
+ >;
410
+ type PreviewnetSatisfiesSignUpFundsContract = Assert<
411
+ PreviewnetClient extends SignUpFundsChain ? true : false
412
+ >;
413
+ type RejectsBogusSignUpFundsClient = Assert<
414
+ ClientWithoutIndividuality extends SignUpFundsChain ? false : true
415
+ >;
416
+ // The fee comes from the built sign-up itself, so a real PAPI transaction must fit.
417
+ type SignUpTxIsFeeEstimable = Assert<
418
+ ReturnType<GameTx["sign_up_with_account"]> extends FeeEstimable ? true : false
419
+ >;
420
+
336
421
  // `SignUpChain` alone does not reject devnet and cannot: a `tx` argument is
337
422
  // checked contravariantly and excess-property checking does not apply between
338
423
  // named types, so an interface naming `airdrops` is satisfied by devnet's call,
package/src/testing.ts CHANGED
@@ -36,6 +36,7 @@ export * from "@parity/product-sdk-local-storage/testing";
36
36
  export * from "@parity/product-sdk-signer/testing";
37
37
  export * from "@parity/product-sdk-contracts/testing";
38
38
  export * from "@parity/product-sdk-host/testing";
39
+ export * from "@parity/product-sdk-individuality/testing";
39
40
 
40
41
  /** Configurable behavior for the fake {@link WalletApi}. */
41
42
  export interface FakeWalletOptions {
@@ -1 +0,0 @@
1
- export * from '@parity/product-sdk-nfts';
@@ -1,3 +0,0 @@
1
- export * from '@parity/product-sdk-nfts';
2
- //# sourceMappingURL=index.js.map
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
@@ -1,58 +0,0 @@
1
- // Copyright 2026 Parity Technologies (UK) Ltd.
2
- // SPDX-License-Identifier: Apache-2.0
3
- /**
4
- * Compile-time guard for the chain contract in `@parity/product-sdk-nfts`.
5
- *
6
- * That package types its chain parameter structurally, listing the storage
7
- * entries it needs rather than naming a descriptor — same trade as
8
- * `IndividualityChain`, and the same gap: a hand-written contract can drift from
9
- * the real chain silently, because the package's own test doubles satisfy it by
10
- * construction. See `../individuality/contract.test.ts` for why this assertion
11
- * has to live in `@parity/product-sdk` to mean anything, and why it checks the
12
- * sibling's built `dist` rather than its `src`.
13
- *
14
- * The `ItemDefs` line below is the one that earned this file. PAPI generates its
15
- * key as `FixedSizeArray<2, number>` rather than the `[number, number]` tuple it
16
- * gives `CollectionMetadata` and `ItemMetadata`, because the runtime's metadata
17
- * declares the key type as an array. The raw storage layout is nonetheless two
18
- * Twox64Concat segments — a genuine two-key map, verified against live state
19
- * with `rpc.state_getKeys` — so a prefix scan by collection is sound at the
20
- * protocol level. Whether PAPI's *typing* admits the one-arg `getEntries` that
21
- * `NftsChain` asks for is a different question, and this is what answers it.
22
- *
23
- * **Paseo only, and that asymmetry is the point.** `devnet-asset-hub` carries
24
- * neither `Scarcity` nor `NftClaims`, so the negative control below is not a
25
- * hypothetical: it is the live state of the other supported network.
26
- */
27
- import type { getChainAPI } from "@parity/product-sdk-chain-client";
28
- import type { NftsChain, NftsCreditsChain } from "@parity/product-sdk-nfts";
29
- import { expect, test } from "vitest";
30
-
31
- // The false branch must be `false`, not `never`. `never` is assignable to
32
- // `true`, so a `never` branch would make the assertion unfalsifiable.
33
- type Assert<T extends true> = T;
34
-
35
- type PaseoClient = Awaited<ReturnType<typeof getChainAPI<"paseo">>>;
36
- type DevnetClient = Awaited<ReturnType<typeof getChainAPI<"devnet">>>;
37
-
38
- // The test: this alias fails to typecheck if the contract drifts from the
39
- // descriptor, so it needs no export and no runtime reference.
40
- type PaseoSatisfiesContract = Assert<PaseoClient extends NftsChain ? true : false>;
41
-
42
- // The credits read spans both chains the preset carries, so the same client
43
- // has to satisfy the second contract too.
44
- type PaseoSatisfiesCredits = Assert<PaseoClient extends NftsCreditsChain ? true : false>;
45
-
46
- // The negative control, and a real fact about the network rather than a
47
- // hypothetical: devnet Asset Hub has no `Scarcity` and no `NftClaims`. If
48
- // `NftsChain` ever stopped constraining, this `@ts-expect-error` would report
49
- // as unused and the file would fail.
50
- // @ts-expect-error devnet Asset Hub carries neither pallet
51
- type DevnetLacksPallets = Assert<DevnetClient extends NftsChain ? true : false>;
52
-
53
- test("nfts chain contract holds against the paseo descriptor", () => {
54
- // The assertions above are compile-time. This keeps vitest from reporting
55
- // the file as having no tests, and documents that a green run means tsc
56
- // accepted them.
57
- expect(true).toBe(true);
58
- });
package/src/nfts/index.ts DELETED
@@ -1,8 +0,0 @@
1
- // Copyright 2026 Parity Technologies (UK) Ltd.
2
- // SPDX-License-Identifier: Apache-2.0
3
- /**
4
- * @parity/product-sdk/nfts
5
- *
6
- * Re-exports from @parity/product-sdk-nfts.
7
- */
8
- export * from "@parity/product-sdk-nfts";