@parity/product-sdk 0.0.0-dev.409.0 → 0.0.0-dev.421.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.
package/dist/testing/index.d.ts
CHANGED
|
@@ -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';
|
package/dist/testing/index.js
CHANGED
|
@@ -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;AACj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,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,S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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\";\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.
|
|
3
|
+
"version": "0.0.0-dev.421.0",
|
|
4
4
|
"description": "Unified SDK for building products in the Polkadot ecosystem - umbrella package",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -80,21 +80,21 @@
|
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"polkadot-api": "^2.1.6",
|
|
82
82
|
"@parity/product-sdk-address": "0.2.0",
|
|
83
|
-
"@parity/product-sdk-
|
|
84
|
-
"@parity/product-sdk-
|
|
83
|
+
"@parity/product-sdk-cloud-storage": "0.0.0-dev.421.0",
|
|
84
|
+
"@parity/product-sdk-chain-client": "0.0.0-dev.421.0",
|
|
85
|
+
"@parity/product-sdk-contracts": "0.0.0-dev.421.0",
|
|
85
86
|
"@parity/product-sdk-crypto": "0.1.1",
|
|
86
|
-
"@parity/product-sdk-
|
|
87
|
-
"@parity/product-sdk-
|
|
88
|
-
"@parity/product-sdk-keys": "0.
|
|
89
|
-
"@parity/product-sdk-cloud-storage": "0.0.0-dev.409.0",
|
|
90
|
-
"@parity/product-sdk-logger": "0.1.1",
|
|
87
|
+
"@parity/product-sdk-host": "0.0.0-dev.421.0",
|
|
88
|
+
"@parity/product-sdk-individuality": "0.0.0-dev.421.0",
|
|
89
|
+
"@parity/product-sdk-keys": "0.0.0-dev.421.0",
|
|
91
90
|
"@parity/product-sdk-errors": "0.2.0",
|
|
92
|
-
"@parity/product-sdk-
|
|
91
|
+
"@parity/product-sdk-logger": "0.1.1",
|
|
93
92
|
"@parity/result": "0.2.0",
|
|
94
|
-
"@parity/product-sdk-
|
|
95
|
-
"@parity/product-sdk-
|
|
96
|
-
"@parity/product-sdk-
|
|
97
|
-
"@parity/product-sdk-tx": "0.
|
|
93
|
+
"@parity/product-sdk-nfts": "0.0.0-dev.421.0",
|
|
94
|
+
"@parity/product-sdk-signer": "0.0.0-dev.421.0",
|
|
95
|
+
"@parity/product-sdk-local-storage": "0.0.0-dev.421.0",
|
|
96
|
+
"@parity/product-sdk-tx": "0.0.0-dev.421.0",
|
|
97
|
+
"@parity/product-sdk-renderer": "0.3.0"
|
|
98
98
|
},
|
|
99
99
|
"peerDependencies": {
|
|
100
100
|
"react": "^18.0.0 || ^19.0.0"
|
|
@@ -41,6 +41,9 @@ import type {
|
|
|
41
41
|
AirdropChain,
|
|
42
42
|
ClaimChain,
|
|
43
43
|
ConsumersChain,
|
|
44
|
+
CreditCandidatesChain,
|
|
45
|
+
CurrentGameWatchChain,
|
|
46
|
+
FeeEstimable,
|
|
44
47
|
GameChain,
|
|
45
48
|
GamePlayersChain,
|
|
46
49
|
IndividualityChain,
|
|
@@ -49,12 +52,17 @@ import type {
|
|
|
49
52
|
LiteSignUpChain,
|
|
50
53
|
NetworkSuffixChain,
|
|
51
54
|
PapiIndividualityChain,
|
|
55
|
+
ParticipantWatchChain,
|
|
56
|
+
PlayerWatchChain,
|
|
52
57
|
PrizeStatusChain,
|
|
53
58
|
RegisterChain,
|
|
54
59
|
RegistrationEligibilityChain,
|
|
60
|
+
ReportChain,
|
|
55
61
|
RingLocation as SdkRingLocation,
|
|
62
|
+
RosterChain,
|
|
56
63
|
ScoreContextChain,
|
|
57
64
|
SignUpChain,
|
|
65
|
+
SignUpFundsChain,
|
|
58
66
|
AccountVrfSignature,
|
|
59
67
|
VrfTranscriptItem as IndividualityVrfTranscriptItem,
|
|
60
68
|
RingVRFProof as AsPersonRingVRFProof,
|
|
@@ -129,7 +137,9 @@ type FromPapiSatisfiesContracts = Assert<
|
|
|
129
137
|
GamePlayersChain &
|
|
130
138
|
ScoreContextChain &
|
|
131
139
|
SignUpChain &
|
|
132
|
-
LiteSignUpChain
|
|
140
|
+
LiteSignUpChain &
|
|
141
|
+
CreditCandidatesChain &
|
|
142
|
+
WatchChains
|
|
133
143
|
? true
|
|
134
144
|
: false
|
|
135
145
|
>;
|
|
@@ -327,12 +337,74 @@ type ClaimAirdropTakesTheDocumentedArgs = Assert<
|
|
|
327
337
|
: false
|
|
328
338
|
>;
|
|
329
339
|
|
|
340
|
+
// The report and offboard builders touch `tx` only. `full_report` and the two vote
|
|
341
|
+
// variants are pinned by name, since PAPI encodes whatever object it is handed.
|
|
342
|
+
type PaseoSatisfiesReportContract = Assert<PaseoClient extends ReportChain ? true : false>;
|
|
343
|
+
type PreviewnetSatisfiesReportContract = Assert<
|
|
344
|
+
PreviewnetClient extends ReportChain ? true : false
|
|
345
|
+
>;
|
|
346
|
+
type RejectsBogusReportClient = Assert<
|
|
347
|
+
ClientWithoutIndividuality extends ReportChain ? false : true
|
|
348
|
+
>;
|
|
349
|
+
type ReportArgs = Parameters<GameTx["report"]>[0];
|
|
350
|
+
type ReportTakesFullReport = Assert<"full_report" extends keyof ReportArgs ? true : false>;
|
|
351
|
+
type ReportVoteVariant = ReportArgs["full_report"][number][number]["type"];
|
|
352
|
+
type ReportVotesArePersonAndNotPerson = Assert<
|
|
353
|
+
[ReportVoteVariant] extends ["Person" | "NotPerson"]
|
|
354
|
+
? ["Person" | "NotPerson"] extends [ReportVoteVariant]
|
|
355
|
+
? true
|
|
356
|
+
: false
|
|
357
|
+
: false
|
|
358
|
+
>;
|
|
359
|
+
|
|
360
|
+
// The roster reads, and the candidates read that adds `Game.Game` to them.
|
|
361
|
+
// `IndexToPlayer.getValues` takes each `[round, index]` tuple as a single key.
|
|
362
|
+
type PaseoSatisfiesRosterContract = Assert<PaseoClient extends RosterChain ? true : false>;
|
|
363
|
+
type PreviewnetSatisfiesRosterContract = Assert<
|
|
364
|
+
PreviewnetClient extends RosterChain ? true : false
|
|
365
|
+
>;
|
|
366
|
+
type PaseoSatisfiesCreditCandidatesContract = Assert<
|
|
367
|
+
PaseoClient extends CreditCandidatesChain ? true : false
|
|
368
|
+
>;
|
|
369
|
+
type PreviewnetSatisfiesCreditCandidatesContract = Assert<
|
|
370
|
+
PreviewnetClient extends CreditCandidatesChain ? true : false
|
|
371
|
+
>;
|
|
372
|
+
type RejectsBogusRosterClient = Assert<
|
|
373
|
+
ClientWithoutIndividuality extends RosterChain ? false : true
|
|
374
|
+
>;
|
|
375
|
+
|
|
376
|
+
// The watches take `watchValue` rather than `getValue`, which the pinned contracts
|
|
377
|
+
// never name, so a PAPI release that changed its emission shape fails here.
|
|
378
|
+
type WatchChains = CurrentGameWatchChain & PlayerWatchChain & ParticipantWatchChain;
|
|
379
|
+
type PaseoSatisfiesWatchContracts = Assert<PaseoClient extends WatchChains ? true : false>;
|
|
380
|
+
type PreviewnetSatisfiesWatchContracts = Assert<
|
|
381
|
+
PreviewnetClient extends WatchChains ? true : false
|
|
382
|
+
>;
|
|
383
|
+
type RejectsBogusWatchClient = Assert<
|
|
384
|
+
ClientWithoutIndividuality extends CurrentGameWatchChain ? false : true
|
|
385
|
+
>;
|
|
386
|
+
|
|
330
387
|
// Game sign-up.
|
|
331
388
|
type PaseoSatisfiesSignUpContract = Assert<PaseoClient extends SignUpChain ? true : false>;
|
|
332
389
|
type RejectsBogusSignUpClient = Assert<
|
|
333
390
|
ClientWithoutIndividuality extends SignUpChain ? false : true
|
|
334
391
|
>;
|
|
335
392
|
|
|
393
|
+
// The cost read also takes the raw client, for the chain spec that names the token.
|
|
394
|
+
type PaseoSatisfiesSignUpFundsContract = Assert<
|
|
395
|
+
PaseoClient extends SignUpFundsChain ? true : false
|
|
396
|
+
>;
|
|
397
|
+
type PreviewnetSatisfiesSignUpFundsContract = Assert<
|
|
398
|
+
PreviewnetClient extends SignUpFundsChain ? true : false
|
|
399
|
+
>;
|
|
400
|
+
type RejectsBogusSignUpFundsClient = Assert<
|
|
401
|
+
ClientWithoutIndividuality extends SignUpFundsChain ? false : true
|
|
402
|
+
>;
|
|
403
|
+
// The fee comes from the built sign-up itself, so a real PAPI transaction must fit.
|
|
404
|
+
type SignUpTxIsFeeEstimable = Assert<
|
|
405
|
+
ReturnType<GameTx["sign_up_with_account"]> extends FeeEstimable ? true : false
|
|
406
|
+
>;
|
|
407
|
+
|
|
336
408
|
// `SignUpChain` alone does not reject devnet and cannot: a `tx` argument is
|
|
337
409
|
// checked contravariantly and excess-property checking does not apply between
|
|
338
410
|
// 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 {
|