@parity/product-sdk 0.0.0-dev.312.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/LICENSE +201 -0
- package/dist/address/index.d.ts +9 -0
- package/dist/address/index.js +3 -0
- package/dist/address/index.js.map +1 -0
- package/dist/chain/index.d.ts +1 -0
- package/dist/chain/index.js +3 -0
- package/dist/chain/index.js.map +1 -0
- package/dist/chunk-BRZNHTLQ.js +89 -0
- package/dist/chunk-BRZNHTLQ.js.map +1 -0
- package/dist/chunk-DHRCWMY5.js +240 -0
- package/dist/chunk-DHRCWMY5.js.map +1 -0
- package/dist/chunk-JVJ552RU.js +3 -0
- package/dist/chunk-JVJ552RU.js.map +1 -0
- package/dist/cloud-storage/index.d.ts +1 -0
- package/dist/cloud-storage/index.js +3 -0
- package/dist/cloud-storage/index.js.map +1 -0
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.js +3 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/core/index.d.ts +12 -0
- package/dist/core/index.js +5 -0
- package/dist/core/index.js.map +1 -0
- package/dist/crypto/index.d.ts +1 -0
- package/dist/crypto/index.js +3 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/dotns-bswWAmR2.d.ts +136 -0
- package/dist/host/index.d.ts +1 -0
- package/dist/host/index.js +3 -0
- package/dist/host/index.js.map +1 -0
- package/dist/identity/index.d.ts +491 -0
- package/dist/identity/index.js +691 -0
- package/dist/identity/index.js.map +1 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/individuality/index.d.ts +1 -0
- package/dist/individuality/index.js +3 -0
- package/dist/individuality/index.js.map +1 -0
- package/dist/local-storage/index.d.ts +1 -0
- package/dist/local-storage/index.js +3 -0
- package/dist/local-storage/index.js.map +1 -0
- package/dist/react/index.d.ts +181 -0
- package/dist/react/index.js +198 -0
- package/dist/react/index.js.map +1 -0
- package/dist/testing/index.d.ts +61 -0
- package/dist/testing/index.js +149 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/types-B5Zx4RNq.d.ts +211 -0
- package/dist/wallet/index.d.ts +1 -0
- package/dist/wallet/index.js +3 -0
- package/dist/wallet/index.js.map +1 -0
- package/package.json +118 -0
- package/src/address/index.ts +8 -0
- package/src/chain/index.ts +8 -0
- package/src/cloud-storage/index.ts +8 -0
- package/src/contracts/index.ts +8 -0
- package/src/core/createApp.ts +408 -0
- package/src/core/index.ts +12 -0
- package/src/core/logger.ts +15 -0
- package/src/core/types.ts +233 -0
- package/src/crypto/index.ts +8 -0
- package/src/host/index.ts +8 -0
- package/src/identity/dotns-abis.test.ts +43 -0
- package/src/identity/dotns-abis.ts +274 -0
- package/src/identity/dotns-errors.ts +34 -0
- package/src/identity/dotns-namehash.test.ts +155 -0
- package/src/identity/dotns-namehash.ts +149 -0
- package/src/identity/dotns-owner.test.ts +92 -0
- package/src/identity/dotns-registry.test.ts +1154 -0
- package/src/identity/dotns-registry.ts +870 -0
- package/src/identity/dotns.test.ts +128 -0
- package/src/identity/dotns.ts +221 -0
- package/src/identity/index.ts +61 -0
- package/src/identity/product-account.test.ts +130 -0
- package/src/identity/product-account.ts +115 -0
- package/src/identity/types.ts +87 -0
- package/src/index.ts +61 -0
- package/src/individuality/contract.test.ts +135 -0
- package/src/individuality/index.ts +8 -0
- package/src/local-storage/index.ts +8 -0
- package/src/react/context.ts +35 -0
- package/src/react/index.ts +43 -0
- package/src/react/provider.tsx +78 -0
- package/src/react/useChain.ts +35 -0
- package/src/react/useLocalStorage.ts +127 -0
- package/src/react/useWallet.ts +156 -0
- package/src/testing.ts +297 -0
- package/src/wallet/index.ts +11 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { LogLevel } from '@parity/product-sdk-logger';
|
|
2
|
+
import { ProductCloudStorageError, CloudStorageEnvironment } from '@parity/product-sdk-cloud-storage';
|
|
3
|
+
import { Result } from '@parity/result';
|
|
4
|
+
import { ChainClient } from '@parity/product-sdk-chain-client';
|
|
5
|
+
import { P as PeopleUsernameChain } from './dotns-bswWAmR2.js';
|
|
6
|
+
import { ChainDefinition, TypedApi, PolkadotClient } from 'polkadot-api';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Core types for @parity/product-sdk
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** Cloud Storage configuration options */
|
|
13
|
+
interface CloudStorageConfig {
|
|
14
|
+
/** Cloud Storage environment to connect to */
|
|
15
|
+
environment: CloudStorageEnvironment;
|
|
16
|
+
}
|
|
17
|
+
/** Configuration for createApp */
|
|
18
|
+
interface AppConfig {
|
|
19
|
+
/** Application name - used to derive product accounts and namespace storage */
|
|
20
|
+
name: string;
|
|
21
|
+
/** Log level for SDK operations (default: 'info') */
|
|
22
|
+
logLevel?: LogLevel;
|
|
23
|
+
/**
|
|
24
|
+
* Cloud Storage configuration.
|
|
25
|
+
* - Omit or pass config object to enable (default: { environment: "paseo" })
|
|
26
|
+
* - Pass `false` to disable cloud storage initialization
|
|
27
|
+
*/
|
|
28
|
+
cloudStorage?: CloudStorageConfig | false;
|
|
29
|
+
}
|
|
30
|
+
/** Wallet API exposed by the SDK */
|
|
31
|
+
interface WalletApi {
|
|
32
|
+
/** Connect to available wallet providers */
|
|
33
|
+
connect(): Promise<{
|
|
34
|
+
accounts: Account[];
|
|
35
|
+
}>;
|
|
36
|
+
/** Disconnect from wallet */
|
|
37
|
+
disconnect(): Promise<void>;
|
|
38
|
+
/** Get all available accounts */
|
|
39
|
+
getAccounts(): Account[];
|
|
40
|
+
/** Get currently selected account */
|
|
41
|
+
getSelectedAccount(): Account | null;
|
|
42
|
+
/** Select an account by address */
|
|
43
|
+
selectAccount(address: string): void;
|
|
44
|
+
/** Sign an arbitrary message */
|
|
45
|
+
signMessage(message: string | Uint8Array): Promise<Uint8Array>;
|
|
46
|
+
/**
|
|
47
|
+
* Sign a message with the account that owns a People / People Lite DotNS identity.
|
|
48
|
+
*
|
|
49
|
+
* Pass the People / Individuality chain descriptor used for username lookup.
|
|
50
|
+
* Pass `username` to choose a specific identity. When omitted, the SDK first
|
|
51
|
+
* asks the host for the user's primary DotNS name and signs with the account
|
|
52
|
+
* that owns that username.
|
|
53
|
+
*/
|
|
54
|
+
signMessageWithDotNsIdentity(args: SignMessageWithDotNsIdentityArgs): Promise<DotNsIdentitySignature>;
|
|
55
|
+
/** Subscribe to account changes */
|
|
56
|
+
onAccountChange(callback: (account: Account | null) => void): () => void;
|
|
57
|
+
/** Get product-scoped account (container mode only) */
|
|
58
|
+
getProductAccount(): Account | null;
|
|
59
|
+
/** Get anonymous alias via Ring VRF (container mode only) */
|
|
60
|
+
getAnonymousAlias(): string | null;
|
|
61
|
+
/** Create Ring VRF proof (container mode only) */
|
|
62
|
+
createProof(message: Uint8Array): Promise<Uint8Array>;
|
|
63
|
+
}
|
|
64
|
+
/** Storage API exposed by the SDK */
|
|
65
|
+
interface LocalStorageApi {
|
|
66
|
+
/** Get a value by key */
|
|
67
|
+
get(key: string): Promise<string | null>;
|
|
68
|
+
/** Set a value by key */
|
|
69
|
+
set(key: string, value: string): Promise<void>;
|
|
70
|
+
/** Get a JSON value by key */
|
|
71
|
+
getJSON<T = unknown>(key: string): Promise<T | null>;
|
|
72
|
+
/** Set a JSON value by key */
|
|
73
|
+
setJSON<T = unknown>(key: string, value: T): Promise<void>;
|
|
74
|
+
/** Remove a value by key */
|
|
75
|
+
remove(key: string): Promise<void>;
|
|
76
|
+
/** Clear all values */
|
|
77
|
+
clear(): Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
/** Chain API exposed by the SDK */
|
|
80
|
+
interface ChainApi {
|
|
81
|
+
/**
|
|
82
|
+
* Get a typed PAPI client for a chain.
|
|
83
|
+
*
|
|
84
|
+
* Connections are routed through the host provider. The chain must be
|
|
85
|
+
* connected first via {@link connect}.
|
|
86
|
+
*
|
|
87
|
+
* @param descriptor - PAPI chain descriptor (from @parity/product-sdk-descriptors or custom)
|
|
88
|
+
* @returns Typed API for the chain
|
|
89
|
+
* @throws If the chain is not connected
|
|
90
|
+
*/
|
|
91
|
+
getClient<T extends ChainDefinition>(descriptor: T): TypedApi<T>;
|
|
92
|
+
/**
|
|
93
|
+
* Get the raw PolkadotClient for a chain.
|
|
94
|
+
*
|
|
95
|
+
* Use this for advanced APIs like `createContractRuntime` from `@parity/product-sdk-contracts`.
|
|
96
|
+
*
|
|
97
|
+
* @param descriptor - PAPI chain descriptor
|
|
98
|
+
* @returns Raw PolkadotClient instance
|
|
99
|
+
* @throws If the chain is not connected
|
|
100
|
+
*/
|
|
101
|
+
getRawClient(descriptor: ChainDefinition): PolkadotClient;
|
|
102
|
+
/**
|
|
103
|
+
* Connect to one or more chains.
|
|
104
|
+
*
|
|
105
|
+
* Connections are routed through the host provider (container-only).
|
|
106
|
+
* Results are cached - calling with the same descriptors returns existing connections.
|
|
107
|
+
*
|
|
108
|
+
* @param chains - Record of named chain descriptors
|
|
109
|
+
* @returns Connected chain client with typed APIs
|
|
110
|
+
*/
|
|
111
|
+
connect<T extends Record<string, ChainDefinition>>(chains: T): Promise<ChainClient<T>>;
|
|
112
|
+
/**
|
|
113
|
+
* Check if a chain is currently connected.
|
|
114
|
+
*/
|
|
115
|
+
isConnected(descriptor: ChainDefinition): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Destroy all chain connections.
|
|
118
|
+
*/
|
|
119
|
+
destroyAll(): void;
|
|
120
|
+
}
|
|
121
|
+
/** Cloud Storage API exposed by the SDK */
|
|
122
|
+
interface CloudStorageApi {
|
|
123
|
+
/**
|
|
124
|
+
* Upload data to the Cloud.
|
|
125
|
+
*
|
|
126
|
+
* Requires a wallet to be connected and an account selected.
|
|
127
|
+
*
|
|
128
|
+
* @returns A {@link Result}: `ok(cid)` on success, or `err(ProductCloudStorageError)`
|
|
129
|
+
* if the upload fails (no signer, network rejection, or no CID returned).
|
|
130
|
+
*/
|
|
131
|
+
upload(data: string | Uint8Array): Promise<Result<string, ProductCloudStorageError>>;
|
|
132
|
+
/**
|
|
133
|
+
* Fetch data by CID.
|
|
134
|
+
*
|
|
135
|
+
* @returns A {@link Result}: `ok(bytes)` on success, or `err(ProductCloudStorageError)`.
|
|
136
|
+
*/
|
|
137
|
+
fetch(cid: string): Promise<Result<Uint8Array, ProductCloudStorageError>>;
|
|
138
|
+
/**
|
|
139
|
+
* Compute the CID for data without uploading.
|
|
140
|
+
*
|
|
141
|
+
* Async because the underlying hash is computed via Web Crypto. Does not
|
|
142
|
+
* perform I/O, so it throws on invalid input rather than returning a Result.
|
|
143
|
+
*/
|
|
144
|
+
computeCid(data: string | Uint8Array): Promise<string>;
|
|
145
|
+
}
|
|
146
|
+
/** The main App instance returned by createApp */
|
|
147
|
+
interface App {
|
|
148
|
+
/** Wallet/signing operations */
|
|
149
|
+
wallet: WalletApi;
|
|
150
|
+
/** Local Key-value storage operations */
|
|
151
|
+
localStorage: LocalStorageApi;
|
|
152
|
+
/** Chain interaction operations */
|
|
153
|
+
chain: ChainApi;
|
|
154
|
+
/** Cloud Storage operations (null if disabled via config) */
|
|
155
|
+
cloudStorage: CloudStorageApi | null;
|
|
156
|
+
/** Get app configuration */
|
|
157
|
+
getAppInfo(): AppConfig;
|
|
158
|
+
}
|
|
159
|
+
/** Account information */
|
|
160
|
+
interface Account {
|
|
161
|
+
/** Account address (SS58 format) */
|
|
162
|
+
address: string;
|
|
163
|
+
/** Account name/label (if available) */
|
|
164
|
+
name?: string;
|
|
165
|
+
/** Source of the account (host, dev signer, etc.) */
|
|
166
|
+
source: string;
|
|
167
|
+
}
|
|
168
|
+
/** Arguments for signing with a DotNS / People username identity. */
|
|
169
|
+
interface SignMessageWithDotNsIdentityArgs {
|
|
170
|
+
/**
|
|
171
|
+
* PAPI descriptor for the People / Individuality chain that exposes
|
|
172
|
+
* `Resources.UsernameOwnerOf`.
|
|
173
|
+
*
|
|
174
|
+
* The SDK reuses an already-connected client when one matches this
|
|
175
|
+
* descriptor's genesis. For long-running apps, call
|
|
176
|
+
* `app.chain.connect({ ..., <name>: peopleChain })` once at startup so
|
|
177
|
+
* every subsequent `signMessageWithDotNsIdentity` call reuses the same
|
|
178
|
+
* chainHead subscription. When the chain isn't already connected, the
|
|
179
|
+
* SDK opens a transient connection for the lookup; that connection then
|
|
180
|
+
* lives in the chain-client cache for the rest of the process.
|
|
181
|
+
*/
|
|
182
|
+
peopleChain: PeopleUsernameChain;
|
|
183
|
+
/**
|
|
184
|
+
* People / People Lite username to resolve before signing.
|
|
185
|
+
*
|
|
186
|
+
* If omitted, the SDK fetches the primary DotNS name associated with the
|
|
187
|
+
* connected user from the host identity API. Note: that fetch triggers a
|
|
188
|
+
* host identity-permission prompt, so callers who want to avoid the
|
|
189
|
+
* dialog on a likely-miss should resolve the username themselves first.
|
|
190
|
+
*
|
|
191
|
+
* The string is UTF-8 encoded and used as the storage key on
|
|
192
|
+
* `Resources.UsernameOwnerOf` exactly as supplied — no `.dot` suffix
|
|
193
|
+
* handling is applied. On paseo-individuality today usernames are
|
|
194
|
+
* stored as bare strings (e.g. `alice`, not `alice.dot`); pass the
|
|
195
|
+
* exact value the chain has registered.
|
|
196
|
+
*/
|
|
197
|
+
username?: string;
|
|
198
|
+
/** Message to sign. Strings are UTF-8 encoded before signing. */
|
|
199
|
+
message: string | Uint8Array;
|
|
200
|
+
}
|
|
201
|
+
/** Signature produced for a DotNS / People username identity. */
|
|
202
|
+
interface DotNsIdentitySignature {
|
|
203
|
+
/** Username used for the lookup. */
|
|
204
|
+
username: string;
|
|
205
|
+
/** Raw `AccountId32` owner resolved from `Resources.UsernameOwnerOf`. */
|
|
206
|
+
accountId: `0x${string}`;
|
|
207
|
+
/** Signature bytes returned by the host wallet. */
|
|
208
|
+
signature: Uint8Array;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export type { Account as A, ChainApi as C, DotNsIdentitySignature as D, LocalStorageApi as L, SignMessageWithDotNsIdentityArgs as S, WalletApi as W, CloudStorageApi as a, App as b, AppConfig as c, CloudStorageConfig as d };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@parity/product-sdk-signer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@parity/product-sdk",
|
|
3
|
+
"version": "0.0.0-dev.312.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
|
+
"./cloud-storage": {
|
|
20
|
+
"import": "./dist/cloud-storage/index.js",
|
|
21
|
+
"types": "./dist/cloud-storage/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
|
+
"./individuality": {
|
|
48
|
+
"import": "./dist/individuality/index.js",
|
|
49
|
+
"types": "./dist/individuality/index.d.ts"
|
|
50
|
+
},
|
|
51
|
+
"./react": {
|
|
52
|
+
"import": "./dist/react/index.js",
|
|
53
|
+
"types": "./dist/react/index.d.ts"
|
|
54
|
+
},
|
|
55
|
+
"./local-storage": {
|
|
56
|
+
"import": "./dist/local-storage/index.js",
|
|
57
|
+
"types": "./dist/local-storage/index.d.ts"
|
|
58
|
+
},
|
|
59
|
+
"./wallet": {
|
|
60
|
+
"import": "./dist/wallet/index.js",
|
|
61
|
+
"types": "./dist/wallet/index.d.ts"
|
|
62
|
+
},
|
|
63
|
+
"./testing": {
|
|
64
|
+
"import": "./dist/testing/index.js",
|
|
65
|
+
"types": "./dist/testing/index.d.ts"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"files": [
|
|
69
|
+
"dist",
|
|
70
|
+
"src"
|
|
71
|
+
],
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"polkadot-api": "^2.1.6",
|
|
74
|
+
"@parity/product-sdk-cloud-storage": "0.0.0-dev.312.0",
|
|
75
|
+
"@parity/product-sdk-chain-client": "0.0.0-dev.312.0",
|
|
76
|
+
"@parity/product-sdk-contracts": "0.0.0-dev.312.0",
|
|
77
|
+
"@parity/product-sdk-host": "0.0.0-dev.312.0",
|
|
78
|
+
"@parity/product-sdk-crypto": "0.1.1",
|
|
79
|
+
"@parity/product-sdk-address": "0.1.1",
|
|
80
|
+
"@parity/product-sdk-individuality": "0.0.0-dev.312.0",
|
|
81
|
+
"@parity/product-sdk-keys": "0.0.0-dev.312.0",
|
|
82
|
+
"@parity/product-sdk-logger": "0.1.1",
|
|
83
|
+
"@parity/product-sdk-errors": "0.2.0",
|
|
84
|
+
"@parity/result": "0.2.0",
|
|
85
|
+
"@parity/product-sdk-signer": "0.0.0-dev.312.0",
|
|
86
|
+
"@parity/product-sdk-tx": "0.0.0-dev.312.0",
|
|
87
|
+
"@parity/product-sdk-local-storage": "0.0.0-dev.312.0"
|
|
88
|
+
},
|
|
89
|
+
"peerDependencies": {
|
|
90
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
91
|
+
},
|
|
92
|
+
"peerDependenciesMeta": {
|
|
93
|
+
"react": {
|
|
94
|
+
"optional": true
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"devDependencies": {
|
|
98
|
+
"@types/node": "^22.0.0",
|
|
99
|
+
"@types/react": "^18.0.0",
|
|
100
|
+
"react": "^18.0.0",
|
|
101
|
+
"typescript": "^5.7.0",
|
|
102
|
+
"vitest": "^3.0.0"
|
|
103
|
+
},
|
|
104
|
+
"keywords": [
|
|
105
|
+
"polkadot",
|
|
106
|
+
"parity",
|
|
107
|
+
"sdk",
|
|
108
|
+
"blockchain",
|
|
109
|
+
"web3"
|
|
110
|
+
],
|
|
111
|
+
"license": "Apache-2.0",
|
|
112
|
+
"scripts": {
|
|
113
|
+
"build": "NODE_OPTIONS=--max-old-space-size=8192 tsup",
|
|
114
|
+
"test": "vitest run",
|
|
115
|
+
"clean": "rm -rf dist",
|
|
116
|
+
"typecheck": "tsc -p tsconfig.typecheck.json"
|
|
117
|
+
}
|
|
118
|
+
}
|