@parity/product-sdk 0.1.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.
Files changed (66) hide show
  1. package/LICENSE +201 -0
  2. package/dist/address/index.d.ts +8 -0
  3. package/dist/address/index.js +3 -0
  4. package/dist/address/index.js.map +1 -0
  5. package/dist/bulletin/index.d.ts +1 -0
  6. package/dist/bulletin/index.js +3 -0
  7. package/dist/bulletin/index.js.map +1 -0
  8. package/dist/chain/index.d.ts +1 -0
  9. package/dist/chain/index.js +3 -0
  10. package/dist/chain/index.js.map +1 -0
  11. package/dist/chunk-NVGSGXGH.js +177 -0
  12. package/dist/chunk-NVGSGXGH.js.map +1 -0
  13. package/dist/chunk-XSKBA5SR.js +8 -0
  14. package/dist/chunk-XSKBA5SR.js.map +1 -0
  15. package/dist/contracts/index.d.ts +1 -0
  16. package/dist/contracts/index.js +3 -0
  17. package/dist/contracts/index.js.map +1 -0
  18. package/dist/core/index.d.ts +9 -0
  19. package/dist/core/index.js +13 -0
  20. package/dist/core/index.js.map +1 -0
  21. package/dist/crypto/index.d.ts +1 -0
  22. package/dist/crypto/index.js +3 -0
  23. package/dist/crypto/index.js.map +1 -0
  24. package/dist/host/index.d.ts +1 -0
  25. package/dist/host/index.js +3 -0
  26. package/dist/host/index.js.map +1 -0
  27. package/dist/identity/index.d.ts +186 -0
  28. package/dist/identity/index.js +109 -0
  29. package/dist/identity/index.js.map +1 -0
  30. package/dist/index.d.ts +59 -0
  31. package/dist/index.js +27 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/react/index.d.ts +177 -0
  34. package/dist/react/index.js +213 -0
  35. package/dist/react/index.js.map +1 -0
  36. package/dist/storage/index.d.ts +1 -0
  37. package/dist/storage/index.js +3 -0
  38. package/dist/storage/index.js.map +1 -0
  39. package/dist/types-CZQDzQ53.d.ts +142 -0
  40. package/dist/wallet/index.d.ts +1 -0
  41. package/dist/wallet/index.js +3 -0
  42. package/dist/wallet/index.js.map +1 -0
  43. package/package.json +105 -0
  44. package/src/address/index.ts +6 -0
  45. package/src/bulletin/index.ts +6 -0
  46. package/src/chain/index.ts +6 -0
  47. package/src/contracts/index.ts +6 -0
  48. package/src/core/createApp.ts +284 -0
  49. package/src/core/index.ts +10 -0
  50. package/src/core/logger.ts +13 -0
  51. package/src/core/types.ts +155 -0
  52. package/src/crypto/index.ts +6 -0
  53. package/src/host/index.ts +6 -0
  54. package/src/identity/dotns.ts +96 -0
  55. package/src/identity/index.ts +34 -0
  56. package/src/identity/product-account.ts +158 -0
  57. package/src/identity/types.ts +75 -0
  58. package/src/index.ts +49 -0
  59. package/src/react/context.ts +33 -0
  60. package/src/react/index.ts +41 -0
  61. package/src/react/provider.tsx +76 -0
  62. package/src/react/useChain.ts +33 -0
  63. package/src/react/useStorage.ts +125 -0
  64. package/src/react/useWallet.ts +138 -0
  65. package/src/storage/index.ts +6 -0
  66. package/src/wallet/index.ts +9 -0
@@ -0,0 +1,213 @@
1
+ import {
2
+ createApp
3
+ } from "../chunk-NVGSGXGH.js";
4
+
5
+ // src/react/provider.tsx
6
+ import { useEffect, useState } from "react";
7
+
8
+ // src/react/context.ts
9
+ import { createContext, useContext } from "react";
10
+ var ProductSDKContext = createContext(null);
11
+ function useProductSDK() {
12
+ const app = useContext(ProductSDKContext);
13
+ if (!app) {
14
+ throw new Error(
15
+ 'useProductSDK must be used within a ProductSDKProvider. Wrap your app with <ProductSDKProvider name="your-app">.'
16
+ );
17
+ }
18
+ return app;
19
+ }
20
+
21
+ // src/react/provider.tsx
22
+ import { Fragment, jsx } from "react/jsx-runtime";
23
+ function ProductSDKProvider({
24
+ name,
25
+ logLevel = "info",
26
+ children,
27
+ fallback = null
28
+ }) {
29
+ const [app, setApp] = useState(null);
30
+ const [error, setError] = useState(null);
31
+ useEffect(() => {
32
+ let mounted = true;
33
+ createApp({ name, logLevel }).then((createdApp) => {
34
+ if (mounted) {
35
+ setApp(createdApp);
36
+ }
37
+ }).catch((e) => {
38
+ if (mounted) {
39
+ setError(e instanceof Error ? e : new Error(String(e)));
40
+ }
41
+ });
42
+ return () => {
43
+ mounted = false;
44
+ };
45
+ }, [name, logLevel]);
46
+ if (error) {
47
+ throw error;
48
+ }
49
+ if (!app) {
50
+ return /* @__PURE__ */ jsx(Fragment, { children: fallback });
51
+ }
52
+ return /* @__PURE__ */ jsx(ProductSDKContext.Provider, { value: app, children });
53
+ }
54
+
55
+ // src/react/useWallet.ts
56
+ import { useState as useState2, useEffect as useEffect2, useCallback } from "react";
57
+ function useWallet() {
58
+ const app = useProductSDK();
59
+ const [state, setState] = useState2({
60
+ isConnected: false,
61
+ isConnecting: false,
62
+ accounts: [],
63
+ selectedAccount: null,
64
+ error: null
65
+ });
66
+ const connect = useCallback(async () => {
67
+ setState((s) => ({ ...s, isConnecting: true, error: null }));
68
+ try {
69
+ const result = await app.wallet.connect();
70
+ setState((s) => ({
71
+ ...s,
72
+ isConnected: true,
73
+ isConnecting: false,
74
+ accounts: result.accounts,
75
+ selectedAccount: result.accounts[0] || null
76
+ }));
77
+ } catch (e) {
78
+ setState((s) => ({
79
+ ...s,
80
+ isConnecting: false,
81
+ error: e instanceof Error ? e : new Error(String(e))
82
+ }));
83
+ }
84
+ }, [app]);
85
+ const disconnect = useCallback(async () => {
86
+ await app.wallet.disconnect();
87
+ setState({
88
+ isConnected: false,
89
+ isConnecting: false,
90
+ accounts: [],
91
+ selectedAccount: null,
92
+ error: null
93
+ });
94
+ }, [app]);
95
+ const selectAccount = useCallback(
96
+ (address) => {
97
+ app.wallet.selectAccount(address);
98
+ const account = state.accounts.find((a) => a.address === address) || null;
99
+ setState((s) => ({ ...s, selectedAccount: account }));
100
+ },
101
+ [app, state.accounts]
102
+ );
103
+ const signMessage = useCallback(
104
+ async (message) => {
105
+ return app.wallet.signMessage(message);
106
+ },
107
+ [app]
108
+ );
109
+ useEffect2(() => {
110
+ const unsubscribe = app.wallet.onAccountChange((account) => {
111
+ setState((s) => ({ ...s, selectedAccount: account }));
112
+ });
113
+ return unsubscribe;
114
+ }, [app]);
115
+ return {
116
+ ...state,
117
+ connect,
118
+ disconnect,
119
+ selectAccount,
120
+ signMessage
121
+ };
122
+ }
123
+
124
+ // src/react/useStorage.ts
125
+ import { useState as useState3, useEffect as useEffect3, useCallback as useCallback2 } from "react";
126
+ function useStorage(key, defaultValue) {
127
+ const app = useProductSDK();
128
+ const [value, setValue] = useState3(null);
129
+ const [loading, setLoading] = useState3(true);
130
+ const [error, setError] = useState3(null);
131
+ useEffect3(() => {
132
+ let mounted = true;
133
+ const loadValue = async () => {
134
+ try {
135
+ setLoading(true);
136
+ const stored = await app.storage.getJSON(key);
137
+ if (mounted) {
138
+ setValue(stored ?? defaultValue ?? null);
139
+ setLoading(false);
140
+ }
141
+ } catch (e) {
142
+ if (mounted) {
143
+ setError(e instanceof Error ? e : new Error(String(e)));
144
+ setLoading(false);
145
+ }
146
+ }
147
+ };
148
+ loadValue();
149
+ return () => {
150
+ mounted = false;
151
+ };
152
+ }, [app, key, defaultValue]);
153
+ const setStoredValue = useCallback2(
154
+ async (newValue) => {
155
+ try {
156
+ setError(null);
157
+ await app.storage.setJSON(key, newValue);
158
+ setValue(newValue);
159
+ } catch (e) {
160
+ setError(e instanceof Error ? e : new Error(String(e)));
161
+ throw e;
162
+ }
163
+ },
164
+ [app, key]
165
+ );
166
+ return [value, setStoredValue, { loading, error }];
167
+ }
168
+ function useStorageString(key, defaultValue) {
169
+ const app = useProductSDK();
170
+ const [value, setValue] = useState3(null);
171
+ const [loading, setLoading] = useState3(true);
172
+ useEffect3(() => {
173
+ let mounted = true;
174
+ const loadValue = async () => {
175
+ const stored = await app.storage.get(key);
176
+ if (mounted) {
177
+ setValue(stored ?? defaultValue ?? null);
178
+ setLoading(false);
179
+ }
180
+ };
181
+ loadValue();
182
+ return () => {
183
+ mounted = false;
184
+ };
185
+ }, [app, key, defaultValue]);
186
+ const setStoredValue = useCallback2(
187
+ async (newValue) => {
188
+ await app.storage.set(key, newValue);
189
+ setValue(newValue);
190
+ },
191
+ [app, key]
192
+ );
193
+ return [value, setStoredValue, { loading }];
194
+ }
195
+
196
+ // src/react/useChain.ts
197
+ import { useMemo } from "react";
198
+ function useChain(chain) {
199
+ const app = useProductSDK();
200
+ return useMemo(() => {
201
+ return app.chain.getClient(chain);
202
+ }, [app, chain]);
203
+ }
204
+ export {
205
+ ProductSDKContext,
206
+ ProductSDKProvider,
207
+ useChain,
208
+ useProductSDK,
209
+ useStorage,
210
+ useStorageString,
211
+ useWallet
212
+ };
213
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/react/provider.tsx","../../src/react/context.ts","../../src/react/useWallet.ts","../../src/react/useStorage.ts","../../src/react/useChain.ts"],"sourcesContent":["/**\n * ProductSDKProvider component\n */\n\nimport React, { useEffect, useState, type ReactNode } from \"react\";\nimport { ProductSDKContext } from \"./context.js\";\nimport { createApp } from \"../core/createApp.js\";\nimport type { App, LogLevel } from \"../core/types.js\";\n\n/** Props for ProductSDKProvider */\nexport interface ProductSDKProviderProps {\n /** Application name - used for storage namespacing and product account derivation */\n name: string;\n /** Log level (default: 'info') */\n logLevel?: LogLevel;\n /** Child components */\n children: ReactNode;\n /** Fallback to show while loading */\n fallback?: ReactNode;\n}\n\n/**\n * Provider component that initializes the Product SDK\n *\n * @example\n * ```tsx\n * import { ProductSDKProvider } from '@parity/product-sdk/react';\n *\n * function App() {\n * return (\n * <ProductSDKProvider name=\"my-app\" fallback={<Loading />}>\n * <MyApp />\n * </ProductSDKProvider>\n * );\n * }\n * ```\n */\nexport function ProductSDKProvider({\n name,\n logLevel = \"info\",\n children,\n fallback = null,\n}: ProductSDKProviderProps) {\n const [app, setApp] = useState<App | null>(null);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n let mounted = true;\n\n createApp({ name, logLevel })\n .then((createdApp) => {\n if (mounted) {\n setApp(createdApp);\n }\n })\n .catch((e) => {\n if (mounted) {\n setError(e instanceof Error ? e : new Error(String(e)));\n }\n });\n\n return () => {\n mounted = false;\n };\n }, [name, logLevel]);\n\n if (error) {\n throw error;\n }\n\n if (!app) {\n return <>{fallback}</>;\n }\n\n return <ProductSDKContext.Provider value={app}>{children}</ProductSDKContext.Provider>;\n}\n","/**\n * React context for Product SDK\n */\n\nimport { createContext, useContext } from \"react\";\nimport type { App } from \"../core/types.js\";\n\n/** Context for the Product SDK app instance */\nexport const ProductSDKContext = createContext<App | null>(null);\n\n/**\n * Hook to access the Product SDK app instance\n *\n * @throws If used outside of ProductSDKProvider\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const app = useProductSDK();\n * // Use app.wallet, app.storage, etc.\n * }\n * ```\n */\nexport function useProductSDK(): App {\n const app = useContext(ProductSDKContext);\n if (!app) {\n throw new Error(\n \"useProductSDK must be used within a ProductSDKProvider. \" +\n 'Wrap your app with <ProductSDKProvider name=\"your-app\">.',\n );\n }\n return app;\n}\n","/**\n * useWallet hook\n */\n\nimport { useState, useEffect, useCallback } from \"react\";\nimport { useProductSDK } from \"./context.js\";\nimport type { Account } from \"../core/types.js\";\n\n/** Wallet hook state */\nexport interface UseWalletState {\n /** Whether wallet is connected */\n isConnected: boolean;\n /** Whether connection is in progress */\n isConnecting: boolean;\n /** Available accounts */\n accounts: Account[];\n /** Currently selected account */\n selectedAccount: Account | null;\n /** Last error */\n error: Error | null;\n}\n\n/** Wallet hook actions */\nexport interface UseWalletActions {\n /** Connect to wallet */\n connect: () => Promise<void>;\n /** Disconnect from wallet */\n disconnect: () => Promise<void>;\n /** Select an account */\n selectAccount: (address: string) => void;\n /** Sign a message */\n signMessage: (message: string | Uint8Array) => Promise<Uint8Array>;\n}\n\n/** Return type of useWallet */\nexport type UseWalletReturn = UseWalletState & UseWalletActions;\n\n/**\n * Hook for wallet connection and signing\n *\n * @example\n * ```tsx\n * function WalletButton() {\n * const { isConnected, accounts, connect, disconnect, selectAccount } = useWallet();\n *\n * if (!isConnected) {\n * return <button onClick={connect}>Connect Wallet</button>;\n * }\n *\n * return (\n * <div>\n * <select onChange={(e) => selectAccount(e.target.value)}>\n * {accounts.map((a) => (\n * <option key={a.address} value={a.address}>\n * {a.name || a.address}\n * </option>\n * ))}\n * </select>\n * <button onClick={disconnect}>Disconnect</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useWallet(): UseWalletReturn {\n const app = useProductSDK();\n\n const [state, setState] = useState<UseWalletState>({\n isConnected: false,\n isConnecting: false,\n accounts: [],\n selectedAccount: null,\n error: null,\n });\n\n const connect = useCallback(async () => {\n setState((s) => ({ ...s, isConnecting: true, error: null }));\n try {\n const result = await app.wallet.connect();\n setState((s) => ({\n ...s,\n isConnected: true,\n isConnecting: false,\n accounts: result.accounts,\n selectedAccount: result.accounts[0] || null,\n }));\n } catch (e) {\n setState((s) => ({\n ...s,\n isConnecting: false,\n error: e instanceof Error ? e : new Error(String(e)),\n }));\n }\n }, [app]);\n\n const disconnect = useCallback(async () => {\n await app.wallet.disconnect();\n setState({\n isConnected: false,\n isConnecting: false,\n accounts: [],\n selectedAccount: null,\n error: null,\n });\n }, [app]);\n\n const selectAccount = useCallback(\n (address: string) => {\n app.wallet.selectAccount(address);\n const account = state.accounts.find((a) => a.address === address) || null;\n setState((s) => ({ ...s, selectedAccount: account }));\n },\n [app, state.accounts],\n );\n\n const signMessage = useCallback(\n async (message: string | Uint8Array) => {\n return app.wallet.signMessage(message);\n },\n [app],\n );\n\n // Subscribe to account changes\n useEffect(() => {\n const unsubscribe = app.wallet.onAccountChange((account) => {\n setState((s) => ({ ...s, selectedAccount: account }));\n });\n return unsubscribe;\n }, [app]);\n\n return {\n ...state,\n connect,\n disconnect,\n selectAccount,\n signMessage,\n };\n}\n","/**\n * useStorage hook\n */\n\nimport { useState, useEffect, useCallback } from \"react\";\nimport { useProductSDK } from \"./context.js\";\n\n/**\n * Hook for key-value storage operations\n *\n * @param key - Storage key\n * @param defaultValue - Default value if key doesn't exist\n *\n * @example\n * ```tsx\n * function ThemeToggle() {\n * const [theme, setTheme, { loading }] = useStorage('theme', 'light');\n *\n * if (loading) return <div>Loading...</div>;\n *\n * return (\n * <button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>\n * Current: {theme}\n * </button>\n * );\n * }\n * ```\n */\nexport function useStorage<T = string>(\n key: string,\n defaultValue?: T,\n): [T | null, (value: T) => Promise<void>, { loading: boolean; error: Error | null }] {\n const app = useProductSDK();\n\n const [value, setValue] = useState<T | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n // Load initial value\n useEffect(() => {\n let mounted = true;\n\n const loadValue = async () => {\n try {\n setLoading(true);\n const stored = await app.storage.getJSON<T>(key);\n if (mounted) {\n setValue(stored ?? defaultValue ?? null);\n setLoading(false);\n }\n } catch (e) {\n if (mounted) {\n setError(e instanceof Error ? e : new Error(String(e)));\n setLoading(false);\n }\n }\n };\n\n loadValue();\n\n return () => {\n mounted = false;\n };\n }, [app, key, defaultValue]);\n\n const setStoredValue = useCallback(\n async (newValue: T) => {\n try {\n setError(null);\n await app.storage.setJSON(key, newValue);\n setValue(newValue);\n } catch (e) {\n setError(e instanceof Error ? e : new Error(String(e)));\n throw e;\n }\n },\n [app, key],\n );\n\n return [value, setStoredValue, { loading, error }];\n}\n\n/**\n * Hook for string storage (simpler API)\n *\n * @param key - Storage key\n * @param defaultValue - Default value\n */\nexport function useStorageString(\n key: string,\n defaultValue?: string,\n): [string | null, (value: string) => Promise<void>, { loading: boolean }] {\n const app = useProductSDK();\n\n const [value, setValue] = useState<string | null>(null);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n let mounted = true;\n\n const loadValue = async () => {\n const stored = await app.storage.get(key);\n if (mounted) {\n setValue(stored ?? defaultValue ?? null);\n setLoading(false);\n }\n };\n\n loadValue();\n\n return () => {\n mounted = false;\n };\n }, [app, key, defaultValue]);\n\n const setStoredValue = useCallback(\n async (newValue: string) => {\n await app.storage.set(key, newValue);\n setValue(newValue);\n },\n [app, key],\n );\n\n return [value, setStoredValue, { loading }];\n}\n","/**\n * useChain hook\n */\n\nimport { useMemo } from \"react\";\nimport { useProductSDK } from \"./context.js\";\nimport type { ChainDefinition, TypedApi } from \"../core/types.js\";\n\n/**\n * Hook to get a typed chain client\n *\n * @param chain - Chain descriptor (PAPI ChainDefinition)\n *\n * @example\n * ```tsx\n * import { paseo_asset_hub } from '@parity/product-sdk-descriptors/paseo-asset-hub';\n * import { useChain } from '@parity/product-sdk/react';\n *\n * function AssetHubBalance() {\n * const assetHub = useChain(paseo_asset_hub);\n *\n * // assetHub is typed for Asset Hub queries\n * const balance = await assetHub.query.System.Account.getValue(address);\n * }\n * ```\n */\nexport function useChain<T extends ChainDefinition>(chain: T): TypedApi<T> {\n const app = useProductSDK();\n\n return useMemo(() => {\n return app.chain.getClient(chain);\n }, [app, chain]);\n}\n"],"mappings":";;;;;AAIA,SAAgB,WAAW,gBAAgC;;;ACA3D,SAAS,eAAe,kBAAkB;AAInC,IAAM,oBAAoB,cAA0B,IAAI;AAexD,SAAS,gBAAqB;AACjC,QAAM,MAAM,WAAW,iBAAiB;AACxC,MAAI,CAAC,KAAK;AACN,UAAM,IAAI;AAAA,MACN;AAAA,IAEJ;AAAA,EACJ;AACA,SAAO;AACX;;;ADuCe;AAlCR,SAAS,mBAAmB;AAAA,EAC/B;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA,WAAW;AACf,GAA4B;AACxB,QAAM,CAAC,KAAK,MAAM,IAAI,SAAqB,IAAI;AAC/C,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAuB,IAAI;AAErD,YAAU,MAAM;AACZ,QAAI,UAAU;AAEd,cAAU,EAAE,MAAM,SAAS,CAAC,EACvB,KAAK,CAAC,eAAe;AAClB,UAAI,SAAS;AACT,eAAO,UAAU;AAAA,MACrB;AAAA,IACJ,CAAC,EACA,MAAM,CAAC,MAAM;AACV,UAAI,SAAS;AACT,iBAAS,aAAa,QAAQ,IAAI,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC;AA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,IACrB;AAAA,IACA,CAAC,KAAK,GAAG;AAAA,EACb;AAEA,SAAO,CAAC,OAAO,gBAAgB,EAAE,QAAQ,CAAC;AAC9C;;;ACxHA,SAAS,eAAe;AAsBjB,SAAS,SAAoC,OAAuB;AACvE,QAAM,MAAM,cAAc;AAE1B,SAAO,QAAQ,MAAM;AACjB,WAAO,IAAI,MAAM,UAAU,KAAK;AAAA,EACpC,GAAG,CAAC,KAAK,KAAK,CAAC;AACnB;","names":["useState","useEffect","useState","useEffect","useState","useEffect","useCallback","useState","useEffect","useCallback"]}
@@ -0,0 +1 @@
1
+ export * from '@parity/product-sdk-storage';
@@ -0,0 +1,3 @@
1
+ // src/storage/index.ts
2
+ export * from "@parity/product-sdk-storage";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/storage/index.ts"],"sourcesContent":["/**\n * @parity/product-sdk/storage\n *\n * Re-exports from @parity/product-sdk-storage.\n */\nexport * from \"@parity/product-sdk-storage\";\n"],"mappings":";AAKA,cAAc;","names":[]}
@@ -0,0 +1,142 @@
1
+ import { LogLevel } from '@parity/product-sdk-logger';
2
+ import { Environment } from '@parity/product-sdk-bulletin';
3
+ import { ChainClient } from '@parity/product-sdk-chain-client';
4
+ import { ChainDefinition, TypedApi, PolkadotClient } from 'polkadot-api';
5
+
6
+ /**
7
+ * Core types for @parity/product-sdk
8
+ */
9
+
10
+ /** Bulletin configuration options */
11
+ interface BulletinConfig {
12
+ /** Bulletin environment to connect to */
13
+ environment: Environment;
14
+ }
15
+ /** Configuration for createApp */
16
+ interface AppConfig {
17
+ /** Application name - used to derive product accounts and namespace storage */
18
+ name: string;
19
+ /** Log level for SDK operations (default: 'info') */
20
+ logLevel?: LogLevel;
21
+ /**
22
+ * Bulletin Chain configuration.
23
+ * - Omit or pass config object to enable (default: { environment: "paseo" })
24
+ * - Pass `false` to disable bulletin initialization
25
+ */
26
+ bulletin?: BulletinConfig | false;
27
+ }
28
+ /** Wallet API exposed by the SDK */
29
+ interface WalletApi {
30
+ /** Connect to available wallet providers */
31
+ connect(): Promise<{
32
+ accounts: Account[];
33
+ }>;
34
+ /** Disconnect from wallet */
35
+ disconnect(): Promise<void>;
36
+ /** Get all available accounts */
37
+ getAccounts(): Account[];
38
+ /** Get currently selected account */
39
+ getSelectedAccount(): Account | null;
40
+ /** Select an account by address */
41
+ selectAccount(address: string): void;
42
+ /** Sign an arbitrary message */
43
+ signMessage(message: string | Uint8Array): Promise<Uint8Array>;
44
+ /** Subscribe to account changes */
45
+ onAccountChange(callback: (account: Account | null) => void): () => void;
46
+ /** Get product-scoped account (container mode only) */
47
+ getProductAccount(): Account | null;
48
+ /** Get anonymous alias via Ring VRF (container mode only) */
49
+ getAnonymousAlias(): string | null;
50
+ /** Create Ring VRF proof (container mode only) */
51
+ createProof(message: Uint8Array): Promise<Uint8Array>;
52
+ }
53
+ /** Storage API exposed by the SDK */
54
+ interface StorageApi {
55
+ /** Get a value by key */
56
+ get(key: string): Promise<string | null>;
57
+ /** Set a value by key */
58
+ set(key: string, value: string): Promise<void>;
59
+ /** Get a JSON value by key */
60
+ getJSON<T = unknown>(key: string): Promise<T | null>;
61
+ /** Set a JSON value by key */
62
+ setJSON<T = unknown>(key: string, value: T): Promise<void>;
63
+ /** Remove a value by key */
64
+ remove(key: string): Promise<void>;
65
+ /** Clear all values */
66
+ clear(): Promise<void>;
67
+ }
68
+ /** Chain API exposed by the SDK */
69
+ interface ChainApi {
70
+ /**
71
+ * Get a typed PAPI client for a chain.
72
+ *
73
+ * Connections are routed through the host provider. The chain must be
74
+ * connected first via {@link connect}.
75
+ *
76
+ * @param descriptor - PAPI chain descriptor (from @parity/product-sdk-descriptors or custom)
77
+ * @returns Typed API for the chain
78
+ * @throws If the chain is not connected
79
+ */
80
+ getClient<T extends ChainDefinition>(descriptor: T): TypedApi<T>;
81
+ /**
82
+ * Get the raw PolkadotClient for a chain.
83
+ *
84
+ * Use this for advanced APIs like `createInkSdk` from `@polkadot-api/sdk-ink`.
85
+ *
86
+ * @param descriptor - PAPI chain descriptor
87
+ * @returns Raw PolkadotClient instance
88
+ * @throws If the chain is not connected
89
+ */
90
+ getRawClient(descriptor: ChainDefinition): PolkadotClient;
91
+ /**
92
+ * Connect to one or more chains.
93
+ *
94
+ * Connections are routed through the host provider (container-only).
95
+ * Results are cached - calling with the same descriptors returns existing connections.
96
+ *
97
+ * @param chains - Record of named chain descriptors
98
+ * @returns Connected chain client with typed APIs
99
+ */
100
+ connect<T extends Record<string, ChainDefinition>>(chains: T): Promise<ChainClient<T>>;
101
+ /**
102
+ * Check if a chain is currently connected.
103
+ */
104
+ isConnected(descriptor: ChainDefinition): boolean;
105
+ /**
106
+ * Destroy all chain connections.
107
+ */
108
+ destroyAll(): void;
109
+ }
110
+ /** Bulletin Chain API exposed by the SDK */
111
+ interface BulletinApi {
112
+ /** Upload data to Bulletin Chain */
113
+ upload(data: string | Uint8Array): Promise<string>;
114
+ /** Fetch data by CID */
115
+ fetch(cid: string): Promise<Uint8Array>;
116
+ /** Compute CID for data without uploading */
117
+ computeCid(data: string | Uint8Array): string;
118
+ }
119
+ /** The main App instance returned by createApp */
120
+ interface App {
121
+ /** Wallet/signing operations */
122
+ wallet: WalletApi;
123
+ /** Key-value storage operations */
124
+ storage: StorageApi;
125
+ /** Chain interaction operations */
126
+ chain: ChainApi;
127
+ /** Bulletin Chain operations (null if disabled via config) */
128
+ bulletin: BulletinApi | null;
129
+ /** Get app configuration */
130
+ getAppInfo(): AppConfig;
131
+ }
132
+ /** Account information */
133
+ interface Account {
134
+ /** Account address (SS58 format) */
135
+ address: string;
136
+ /** Account name/label (if available) */
137
+ name?: string;
138
+ /** Source of the account (extension name, host, etc.) */
139
+ source: string;
140
+ }
141
+
142
+ export type { App as A, BulletinApi as B, ChainApi as C, StorageApi as S, WalletApi as W, Account as a, AppConfig as b, BulletinConfig as c };
@@ -0,0 +1 @@
1
+ export * from '@parity/product-sdk-signer';
@@ -0,0 +1,3 @@
1
+ // src/wallet/index.ts
2
+ export * from "@parity/product-sdk-signer";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/wallet/index.ts"],"sourcesContent":["/**\n * @parity/product-sdk/wallet\n *\n * Re-exports from @parity/product-sdk-signer.\n *\n * Note: The leaf package is named \"signer\" but exposed here as \"wallet\"\n * for backwards compatibility with the umbrella API.\n */\nexport * from \"@parity/product-sdk-signer\";\n"],"mappings":";AAQA,cAAc;","names":[]}
package/package.json ADDED
@@ -0,0 +1,105 @@
1
+ {
2
+ "name": "@parity/product-sdk",
3
+ "version": "0.1.0",
4
+ "description": "Unified SDK for building products in the Polkadot ecosystem - umbrella package",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.js",
13
+ "types": "./dist/index.d.ts"
14
+ },
15
+ "./address": {
16
+ "import": "./dist/address/index.js",
17
+ "types": "./dist/address/index.d.ts"
18
+ },
19
+ "./bulletin": {
20
+ "import": "./dist/bulletin/index.js",
21
+ "types": "./dist/bulletin/index.d.ts"
22
+ },
23
+ "./chain": {
24
+ "import": "./dist/chain/index.js",
25
+ "types": "./dist/chain/index.d.ts"
26
+ },
27
+ "./contracts": {
28
+ "import": "./dist/contracts/index.js",
29
+ "types": "./dist/contracts/index.d.ts"
30
+ },
31
+ "./core": {
32
+ "import": "./dist/core/index.js",
33
+ "types": "./dist/core/index.d.ts"
34
+ },
35
+ "./crypto": {
36
+ "import": "./dist/crypto/index.js",
37
+ "types": "./dist/crypto/index.d.ts"
38
+ },
39
+ "./host": {
40
+ "import": "./dist/host/index.js",
41
+ "types": "./dist/host/index.d.ts"
42
+ },
43
+ "./identity": {
44
+ "import": "./dist/identity/index.js",
45
+ "types": "./dist/identity/index.d.ts"
46
+ },
47
+ "./react": {
48
+ "import": "./dist/react/index.js",
49
+ "types": "./dist/react/index.d.ts"
50
+ },
51
+ "./storage": {
52
+ "import": "./dist/storage/index.js",
53
+ "types": "./dist/storage/index.d.ts"
54
+ },
55
+ "./wallet": {
56
+ "import": "./dist/wallet/index.js",
57
+ "types": "./dist/wallet/index.d.ts"
58
+ }
59
+ },
60
+ "files": [
61
+ "dist",
62
+ "src"
63
+ ],
64
+ "dependencies": {
65
+ "polkadot-api": "^1.9.5",
66
+ "@parity/product-sdk-address": "0.1.0",
67
+ "@parity/product-sdk-bulletin": "0.1.0",
68
+ "@parity/product-sdk-chain-client": "0.1.0",
69
+ "@parity/product-sdk-contracts": "0.1.0",
70
+ "@parity/product-sdk-crypto": "0.1.0",
71
+ "@parity/product-sdk-host": "0.1.0",
72
+ "@parity/product-sdk-keys": "0.1.0",
73
+ "@parity/product-sdk-logger": "0.1.0",
74
+ "@parity/product-sdk-storage": "0.1.0",
75
+ "@parity/product-sdk-tx": "0.1.0",
76
+ "@parity/product-sdk-signer": "0.1.0"
77
+ },
78
+ "peerDependencies": {
79
+ "react": "^18.0.0 || ^19.0.0"
80
+ },
81
+ "peerDependenciesMeta": {
82
+ "react": {
83
+ "optional": true
84
+ }
85
+ },
86
+ "devDependencies": {
87
+ "@types/node": "^22.0.0",
88
+ "@types/react": "^18.0.0",
89
+ "react": "^18.0.0",
90
+ "typescript": "^5.7.0",
91
+ "vitest": "^3.0.0"
92
+ },
93
+ "keywords": [
94
+ "polkadot",
95
+ "parity",
96
+ "sdk",
97
+ "blockchain",
98
+ "web3"
99
+ ],
100
+ "license": "Apache-2.0",
101
+ "scripts": {
102
+ "build": "tsup",
103
+ "clean": "rm -rf dist"
104
+ }
105
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @parity/product-sdk/address
3
+ *
4
+ * Re-exports from @parity/product-sdk-address.
5
+ */
6
+ export * from "@parity/product-sdk-address";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @parity/product-sdk/bulletin
3
+ *
4
+ * Re-exports from @parity/product-sdk-bulletin.
5
+ */
6
+ export * from "@parity/product-sdk-bulletin";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @parity/product-sdk/chain
3
+ *
4
+ * Re-exports from @parity/product-sdk-chain-client.
5
+ */
6
+ export * from "@parity/product-sdk-chain-client";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @parity/product-sdk/contracts
3
+ *
4
+ * Re-exports from @parity/product-sdk-contracts.
5
+ */
6
+ export * from "@parity/product-sdk-contracts";