@aksumite/react-providers 1.0.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/index.d.mts +181 -0
- package/dist/index.d.ts +181 -0
- package/dist/index.js +946 -0
- package/dist/index.mjs +916 -0
- package/package.json +40 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { FunctionComponent, SVGProps, ReactNode } from 'react';
|
|
3
|
+
import { AnyJson, MaybeAddress } from '@aksumite/sdk-utils';
|
|
4
|
+
import { CreateResult } from '@polkadot/ui-keyring/types';
|
|
5
|
+
import { KeyringPair, KeyringPair$Json } from '@polkadot/keyring/types';
|
|
6
|
+
import * as _aksumite_local_wallets from '@aksumite/local-wallets';
|
|
7
|
+
import * as _polkadot_api_promise_types from '@polkadot/api/promise/types';
|
|
8
|
+
import { SubmittableExtrinsic } from '@polkadot/api/promise/types';
|
|
9
|
+
import { SubmittableResult } from '@polkadot/api';
|
|
10
|
+
|
|
11
|
+
type ExtensionStatus = "installed" | "not_authenticated" | "connected";
|
|
12
|
+
type ExtensionFeature = "getAccounts" | "subscribeAccounts" | "signer";
|
|
13
|
+
interface ExtensionsContextInterface {
|
|
14
|
+
checkingInjectedWeb3: boolean;
|
|
15
|
+
extensionsStatus: Record<string, ExtensionStatus>;
|
|
16
|
+
setExtensionStatus: (id: string, status: ExtensionStatus) => void;
|
|
17
|
+
removeExtensionStatus: (id: string) => void;
|
|
18
|
+
extensionInstalled: (id: string) => boolean;
|
|
19
|
+
extensionCanConnect: (id: string) => boolean;
|
|
20
|
+
extensionHasFeature: (id: string, feature: ExtensionFeature) => boolean;
|
|
21
|
+
}
|
|
22
|
+
interface ExtensionInjected extends ExtensionConfig {
|
|
23
|
+
id: string;
|
|
24
|
+
enable: (n: string) => Promise<ExtensionInterface>;
|
|
25
|
+
}
|
|
26
|
+
interface ExtensionInterface {
|
|
27
|
+
accounts: {
|
|
28
|
+
subscribe: {
|
|
29
|
+
(a: {
|
|
30
|
+
(b: ExtensionAccount[]): void;
|
|
31
|
+
}): void;
|
|
32
|
+
};
|
|
33
|
+
get: () => Promise<ExtensionAccount[]>;
|
|
34
|
+
};
|
|
35
|
+
provider: AnyJson;
|
|
36
|
+
metadata: AnyJson;
|
|
37
|
+
signer: AnyJson;
|
|
38
|
+
}
|
|
39
|
+
interface ExtensionAccount extends ExtensionMetadata {
|
|
40
|
+
address: string;
|
|
41
|
+
meta?: AnyJson;
|
|
42
|
+
name: string;
|
|
43
|
+
type: "sr25519" | "ethereum";
|
|
44
|
+
signer?: AnyJson;
|
|
45
|
+
}
|
|
46
|
+
interface ExtensionConfig {
|
|
47
|
+
id: string;
|
|
48
|
+
title: string;
|
|
49
|
+
icon: FunctionComponent<SVGProps<SVGSVGElement> & {
|
|
50
|
+
title?: string | undefined;
|
|
51
|
+
}>;
|
|
52
|
+
url: string;
|
|
53
|
+
}
|
|
54
|
+
interface ExtensionMetadata {
|
|
55
|
+
addedBy?: string;
|
|
56
|
+
source: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
declare const ExtensionsContext: react.Context<ExtensionsContextInterface>;
|
|
60
|
+
declare const ExtensionsProvider: ({ children }: {
|
|
61
|
+
children: ReactNode;
|
|
62
|
+
}) => react.JSX.Element;
|
|
63
|
+
|
|
64
|
+
declare const defaultExtensionsContext: ExtensionsContextInterface;
|
|
65
|
+
|
|
66
|
+
declare const useExtensions: () => {
|
|
67
|
+
checkingInjectedWeb3: boolean;
|
|
68
|
+
extensionsStatus: Record<string, ExtensionStatus>;
|
|
69
|
+
setExtensionStatus: (id: string, status: ExtensionStatus) => void;
|
|
70
|
+
removeExtensionStatus: (id: string) => void;
|
|
71
|
+
extensionInstalled: (id: string) => boolean;
|
|
72
|
+
extensionCanConnect: (id: string) => boolean;
|
|
73
|
+
extensionHasFeature: (id: string, feature: ExtensionFeature) => boolean;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
interface ExtensionAccountsContextInterface {
|
|
77
|
+
connectExtensionAccounts: (id: string) => Promise<boolean>;
|
|
78
|
+
extensionAccountsSynced: Sync;
|
|
79
|
+
extensionAccounts: ExtensionAccount[];
|
|
80
|
+
}
|
|
81
|
+
interface ExtensionAccountsProviderProps {
|
|
82
|
+
children: ReactNode;
|
|
83
|
+
network: string;
|
|
84
|
+
ss58: number;
|
|
85
|
+
dappName: string;
|
|
86
|
+
activeAccount?: MaybeAddress;
|
|
87
|
+
setActiveAccount?: (a: MaybeAddress) => void;
|
|
88
|
+
onExtensionEnabled?: (id: string) => void;
|
|
89
|
+
}
|
|
90
|
+
interface HandleImportExtension {
|
|
91
|
+
newAccounts: ExtensionAccount[];
|
|
92
|
+
meta: {
|
|
93
|
+
removedActiveAccount: MaybeAddress;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
type Sync = "synced" | "unsynced" | "syncing";
|
|
97
|
+
|
|
98
|
+
declare const ExtensionAccountsContext: react.Context<ExtensionAccountsContextInterface>;
|
|
99
|
+
declare const ExtensionAccountsProvider: ({ children, network, ss58, dappName, activeAccount, setActiveAccount, onExtensionEnabled, }: ExtensionAccountsProviderProps) => react.JSX.Element;
|
|
100
|
+
|
|
101
|
+
declare const defaultExtensionAccountsContext: ExtensionAccountsContextInterface;
|
|
102
|
+
declare const defaultHandleImportExtension: {
|
|
103
|
+
newAccounts: never[];
|
|
104
|
+
meta: {
|
|
105
|
+
removedActiveAccount: null;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
declare const useExtensionAccounts: () => {
|
|
110
|
+
connectExtensionAccounts: (id: string) => Promise<boolean>;
|
|
111
|
+
extensionAccountsSynced: Sync;
|
|
112
|
+
extensionAccounts: ExtensionAccount[];
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
interface Base {
|
|
116
|
+
init: () => Promise<void>;
|
|
117
|
+
isReady: () => boolean;
|
|
118
|
+
}
|
|
119
|
+
interface LocalAccountExternalStorage extends Base {
|
|
120
|
+
id: string;
|
|
121
|
+
getAll(): Promise<KeyringPair$Json[]>;
|
|
122
|
+
get(address: string): Promise<KeyringPair$Json>;
|
|
123
|
+
addFromJson(json: KeyringPair$Json): Promise<void>;
|
|
124
|
+
remove(address: string): Promise<void>;
|
|
125
|
+
}
|
|
126
|
+
interface LocalAccountStore extends Base {
|
|
127
|
+
add(pair: KeyringPair, password: string): CreateResult;
|
|
128
|
+
addFromMnemonic(mnemonic: string, name: string, password: string | undefined): CreateResult;
|
|
129
|
+
import(json: KeyringPair$Json, password: string): KeyringPair;
|
|
130
|
+
remove(address: string): void;
|
|
131
|
+
getAll(): KeyringPair[];
|
|
132
|
+
getPair(address: string): KeyringPair | undefined;
|
|
133
|
+
isLocked(address: string): boolean;
|
|
134
|
+
sign(address: string, data: Uint8Array | string): Uint8Array | undefined;
|
|
135
|
+
addToExternalStorage(json: KeyringPair$Json, store: LocalAccountExternalStorage): Promise<void>;
|
|
136
|
+
backupAllToExternalStorage(store: LocalAccountExternalStorage): Promise<void>;
|
|
137
|
+
subscribeAddresses(cb: (addresses: string[]) => void): void;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
interface UserAccountsContextInterface {
|
|
141
|
+
wallet: LocalAccountStore;
|
|
142
|
+
isReady: boolean;
|
|
143
|
+
localAddresses: string[];
|
|
144
|
+
}
|
|
145
|
+
interface UserAccountsProviderProps {
|
|
146
|
+
children: ReactNode;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
declare const LocalAccountsContext: react.Context<UserAccountsContextInterface>;
|
|
150
|
+
declare const UserAccountsProvider: ({ children, }: UserAccountsProviderProps) => react.JSX.Element;
|
|
151
|
+
|
|
152
|
+
declare const useUserAccounts: () => {
|
|
153
|
+
wallet: _aksumite_local_wallets.LocalAccountStore;
|
|
154
|
+
isReady: boolean;
|
|
155
|
+
localAddresses: string[];
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
type TransactionManagerState = {
|
|
159
|
+
addToTxQueue: (e: SubmittableExtrinsic) => void;
|
|
160
|
+
txStatus: ExtStatus[];
|
|
161
|
+
getTxStatus: (hash: string) => ExtStatus | undefined;
|
|
162
|
+
};
|
|
163
|
+
type ExtStatus = {
|
|
164
|
+
hash: string;
|
|
165
|
+
result: SubmittableResult[];
|
|
166
|
+
status: "broadcasted" | "inblock" | "finalized" | "error" | "ongoing";
|
|
167
|
+
error?: string;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
declare const TransactionManagerProvider: ({ children, }: {
|
|
171
|
+
children: ReactNode;
|
|
172
|
+
}) => react.JSX.Element;
|
|
173
|
+
declare const Context: react.Context<TransactionManagerState>;
|
|
174
|
+
|
|
175
|
+
declare const useTransactionManager: () => {
|
|
176
|
+
addToTxQueue: (e: _polkadot_api_promise_types.SubmittableExtrinsic) => void;
|
|
177
|
+
txStatus: ExtStatus[];
|
|
178
|
+
getTxStatus: (hash: string) => ExtStatus | undefined;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export { Context, type ExtStatus, type ExtensionAccount, ExtensionAccountsContext, type ExtensionAccountsContextInterface, ExtensionAccountsProvider, type ExtensionAccountsProviderProps, type ExtensionConfig, type ExtensionFeature, type ExtensionInjected, type ExtensionInterface, type ExtensionMetadata, type ExtensionStatus, ExtensionsContext, type ExtensionsContextInterface, ExtensionsProvider, type HandleImportExtension, LocalAccountsContext, type Sync, TransactionManagerProvider, type TransactionManagerState, type UserAccountsContextInterface, UserAccountsProvider, type UserAccountsProviderProps, defaultExtensionAccountsContext, defaultExtensionsContext, defaultHandleImportExtension, useExtensionAccounts, useExtensions, useTransactionManager, useUserAccounts };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { FunctionComponent, SVGProps, ReactNode } from 'react';
|
|
3
|
+
import { AnyJson, MaybeAddress } from '@aksumite/sdk-utils';
|
|
4
|
+
import { CreateResult } from '@polkadot/ui-keyring/types';
|
|
5
|
+
import { KeyringPair, KeyringPair$Json } from '@polkadot/keyring/types';
|
|
6
|
+
import * as _aksumite_local_wallets from '@aksumite/local-wallets';
|
|
7
|
+
import * as _polkadot_api_promise_types from '@polkadot/api/promise/types';
|
|
8
|
+
import { SubmittableExtrinsic } from '@polkadot/api/promise/types';
|
|
9
|
+
import { SubmittableResult } from '@polkadot/api';
|
|
10
|
+
|
|
11
|
+
type ExtensionStatus = "installed" | "not_authenticated" | "connected";
|
|
12
|
+
type ExtensionFeature = "getAccounts" | "subscribeAccounts" | "signer";
|
|
13
|
+
interface ExtensionsContextInterface {
|
|
14
|
+
checkingInjectedWeb3: boolean;
|
|
15
|
+
extensionsStatus: Record<string, ExtensionStatus>;
|
|
16
|
+
setExtensionStatus: (id: string, status: ExtensionStatus) => void;
|
|
17
|
+
removeExtensionStatus: (id: string) => void;
|
|
18
|
+
extensionInstalled: (id: string) => boolean;
|
|
19
|
+
extensionCanConnect: (id: string) => boolean;
|
|
20
|
+
extensionHasFeature: (id: string, feature: ExtensionFeature) => boolean;
|
|
21
|
+
}
|
|
22
|
+
interface ExtensionInjected extends ExtensionConfig {
|
|
23
|
+
id: string;
|
|
24
|
+
enable: (n: string) => Promise<ExtensionInterface>;
|
|
25
|
+
}
|
|
26
|
+
interface ExtensionInterface {
|
|
27
|
+
accounts: {
|
|
28
|
+
subscribe: {
|
|
29
|
+
(a: {
|
|
30
|
+
(b: ExtensionAccount[]): void;
|
|
31
|
+
}): void;
|
|
32
|
+
};
|
|
33
|
+
get: () => Promise<ExtensionAccount[]>;
|
|
34
|
+
};
|
|
35
|
+
provider: AnyJson;
|
|
36
|
+
metadata: AnyJson;
|
|
37
|
+
signer: AnyJson;
|
|
38
|
+
}
|
|
39
|
+
interface ExtensionAccount extends ExtensionMetadata {
|
|
40
|
+
address: string;
|
|
41
|
+
meta?: AnyJson;
|
|
42
|
+
name: string;
|
|
43
|
+
type: "sr25519" | "ethereum";
|
|
44
|
+
signer?: AnyJson;
|
|
45
|
+
}
|
|
46
|
+
interface ExtensionConfig {
|
|
47
|
+
id: string;
|
|
48
|
+
title: string;
|
|
49
|
+
icon: FunctionComponent<SVGProps<SVGSVGElement> & {
|
|
50
|
+
title?: string | undefined;
|
|
51
|
+
}>;
|
|
52
|
+
url: string;
|
|
53
|
+
}
|
|
54
|
+
interface ExtensionMetadata {
|
|
55
|
+
addedBy?: string;
|
|
56
|
+
source: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
declare const ExtensionsContext: react.Context<ExtensionsContextInterface>;
|
|
60
|
+
declare const ExtensionsProvider: ({ children }: {
|
|
61
|
+
children: ReactNode;
|
|
62
|
+
}) => react.JSX.Element;
|
|
63
|
+
|
|
64
|
+
declare const defaultExtensionsContext: ExtensionsContextInterface;
|
|
65
|
+
|
|
66
|
+
declare const useExtensions: () => {
|
|
67
|
+
checkingInjectedWeb3: boolean;
|
|
68
|
+
extensionsStatus: Record<string, ExtensionStatus>;
|
|
69
|
+
setExtensionStatus: (id: string, status: ExtensionStatus) => void;
|
|
70
|
+
removeExtensionStatus: (id: string) => void;
|
|
71
|
+
extensionInstalled: (id: string) => boolean;
|
|
72
|
+
extensionCanConnect: (id: string) => boolean;
|
|
73
|
+
extensionHasFeature: (id: string, feature: ExtensionFeature) => boolean;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
interface ExtensionAccountsContextInterface {
|
|
77
|
+
connectExtensionAccounts: (id: string) => Promise<boolean>;
|
|
78
|
+
extensionAccountsSynced: Sync;
|
|
79
|
+
extensionAccounts: ExtensionAccount[];
|
|
80
|
+
}
|
|
81
|
+
interface ExtensionAccountsProviderProps {
|
|
82
|
+
children: ReactNode;
|
|
83
|
+
network: string;
|
|
84
|
+
ss58: number;
|
|
85
|
+
dappName: string;
|
|
86
|
+
activeAccount?: MaybeAddress;
|
|
87
|
+
setActiveAccount?: (a: MaybeAddress) => void;
|
|
88
|
+
onExtensionEnabled?: (id: string) => void;
|
|
89
|
+
}
|
|
90
|
+
interface HandleImportExtension {
|
|
91
|
+
newAccounts: ExtensionAccount[];
|
|
92
|
+
meta: {
|
|
93
|
+
removedActiveAccount: MaybeAddress;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
type Sync = "synced" | "unsynced" | "syncing";
|
|
97
|
+
|
|
98
|
+
declare const ExtensionAccountsContext: react.Context<ExtensionAccountsContextInterface>;
|
|
99
|
+
declare const ExtensionAccountsProvider: ({ children, network, ss58, dappName, activeAccount, setActiveAccount, onExtensionEnabled, }: ExtensionAccountsProviderProps) => react.JSX.Element;
|
|
100
|
+
|
|
101
|
+
declare const defaultExtensionAccountsContext: ExtensionAccountsContextInterface;
|
|
102
|
+
declare const defaultHandleImportExtension: {
|
|
103
|
+
newAccounts: never[];
|
|
104
|
+
meta: {
|
|
105
|
+
removedActiveAccount: null;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
declare const useExtensionAccounts: () => {
|
|
110
|
+
connectExtensionAccounts: (id: string) => Promise<boolean>;
|
|
111
|
+
extensionAccountsSynced: Sync;
|
|
112
|
+
extensionAccounts: ExtensionAccount[];
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
interface Base {
|
|
116
|
+
init: () => Promise<void>;
|
|
117
|
+
isReady: () => boolean;
|
|
118
|
+
}
|
|
119
|
+
interface LocalAccountExternalStorage extends Base {
|
|
120
|
+
id: string;
|
|
121
|
+
getAll(): Promise<KeyringPair$Json[]>;
|
|
122
|
+
get(address: string): Promise<KeyringPair$Json>;
|
|
123
|
+
addFromJson(json: KeyringPair$Json): Promise<void>;
|
|
124
|
+
remove(address: string): Promise<void>;
|
|
125
|
+
}
|
|
126
|
+
interface LocalAccountStore extends Base {
|
|
127
|
+
add(pair: KeyringPair, password: string): CreateResult;
|
|
128
|
+
addFromMnemonic(mnemonic: string, name: string, password: string | undefined): CreateResult;
|
|
129
|
+
import(json: KeyringPair$Json, password: string): KeyringPair;
|
|
130
|
+
remove(address: string): void;
|
|
131
|
+
getAll(): KeyringPair[];
|
|
132
|
+
getPair(address: string): KeyringPair | undefined;
|
|
133
|
+
isLocked(address: string): boolean;
|
|
134
|
+
sign(address: string, data: Uint8Array | string): Uint8Array | undefined;
|
|
135
|
+
addToExternalStorage(json: KeyringPair$Json, store: LocalAccountExternalStorage): Promise<void>;
|
|
136
|
+
backupAllToExternalStorage(store: LocalAccountExternalStorage): Promise<void>;
|
|
137
|
+
subscribeAddresses(cb: (addresses: string[]) => void): void;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
interface UserAccountsContextInterface {
|
|
141
|
+
wallet: LocalAccountStore;
|
|
142
|
+
isReady: boolean;
|
|
143
|
+
localAddresses: string[];
|
|
144
|
+
}
|
|
145
|
+
interface UserAccountsProviderProps {
|
|
146
|
+
children: ReactNode;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
declare const LocalAccountsContext: react.Context<UserAccountsContextInterface>;
|
|
150
|
+
declare const UserAccountsProvider: ({ children, }: UserAccountsProviderProps) => react.JSX.Element;
|
|
151
|
+
|
|
152
|
+
declare const useUserAccounts: () => {
|
|
153
|
+
wallet: _aksumite_local_wallets.LocalAccountStore;
|
|
154
|
+
isReady: boolean;
|
|
155
|
+
localAddresses: string[];
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
type TransactionManagerState = {
|
|
159
|
+
addToTxQueue: (e: SubmittableExtrinsic) => void;
|
|
160
|
+
txStatus: ExtStatus[];
|
|
161
|
+
getTxStatus: (hash: string) => ExtStatus | undefined;
|
|
162
|
+
};
|
|
163
|
+
type ExtStatus = {
|
|
164
|
+
hash: string;
|
|
165
|
+
result: SubmittableResult[];
|
|
166
|
+
status: "broadcasted" | "inblock" | "finalized" | "error" | "ongoing";
|
|
167
|
+
error?: string;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
declare const TransactionManagerProvider: ({ children, }: {
|
|
171
|
+
children: ReactNode;
|
|
172
|
+
}) => react.JSX.Element;
|
|
173
|
+
declare const Context: react.Context<TransactionManagerState>;
|
|
174
|
+
|
|
175
|
+
declare const useTransactionManager: () => {
|
|
176
|
+
addToTxQueue: (e: _polkadot_api_promise_types.SubmittableExtrinsic) => void;
|
|
177
|
+
txStatus: ExtStatus[];
|
|
178
|
+
getTxStatus: (hash: string) => ExtStatus | undefined;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export { Context, type ExtStatus, type ExtensionAccount, ExtensionAccountsContext, type ExtensionAccountsContextInterface, ExtensionAccountsProvider, type ExtensionAccountsProviderProps, type ExtensionConfig, type ExtensionFeature, type ExtensionInjected, type ExtensionInterface, type ExtensionMetadata, type ExtensionStatus, ExtensionsContext, type ExtensionsContextInterface, ExtensionsProvider, type HandleImportExtension, LocalAccountsContext, type Sync, TransactionManagerProvider, type TransactionManagerState, type UserAccountsContextInterface, UserAccountsProvider, type UserAccountsProviderProps, defaultExtensionAccountsContext, defaultExtensionsContext, defaultHandleImportExtension, useExtensionAccounts, useExtensions, useTransactionManager, useUserAccounts };
|