@privy-io/react-auth 1.25.1 → 1.26.0-beta.2
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/esm/index.js +282 -243
- package/dist/index.d.ts +348 -266
- package/dist/index.js +282 -243
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react, { ReactElement } from 'react';
|
|
2
2
|
import { ExternalProvider, InfuraProvider, Web3Provider } from '@ethersproject/providers';
|
|
3
|
-
import EventEmitter from 'eventemitter3';
|
|
4
|
-
import WCProvider from '@walletconnect/web3-provider';
|
|
5
3
|
import { AbstractProvider } from 'web3-core';
|
|
4
|
+
import EventEmitter from 'eventemitter3';
|
|
6
5
|
import { AxiosResponse, AxiosRequestConfig } from 'axios';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -103,10 +102,223 @@ interface eth_signTransactionResponse {
|
|
|
103
102
|
type RpcRequestType = eth_signTransaction | eth_populateTransactionRequest | eth_sign | personal_sign;
|
|
104
103
|
type RpcResponseType = eth_signTransactionResponse | eth_populateTransactionRequestResponse | eth_signResponse | personal_signResponse;
|
|
105
104
|
|
|
105
|
+
type WalletCreateRequestDataType = {
|
|
106
|
+
accessToken: string;
|
|
107
|
+
recoveryPin: string;
|
|
108
|
+
};
|
|
109
|
+
type WalletConnectRequestDataType = {
|
|
110
|
+
accessToken: string;
|
|
111
|
+
address: string;
|
|
112
|
+
};
|
|
113
|
+
type WalletRecoverRequestDataType = {
|
|
114
|
+
accessToken: string;
|
|
115
|
+
address: string;
|
|
116
|
+
recoveryPin: string;
|
|
117
|
+
};
|
|
118
|
+
type WalletRpcRequestDataType = {
|
|
119
|
+
accessToken: string;
|
|
120
|
+
address: string;
|
|
121
|
+
request: RpcRequestType;
|
|
122
|
+
};
|
|
123
|
+
type WalletCreateResponseDataType = {
|
|
124
|
+
address: string;
|
|
125
|
+
};
|
|
126
|
+
type WalletConnectResponseDataType = {
|
|
127
|
+
address: string;
|
|
128
|
+
};
|
|
129
|
+
type WalletRecoverResponseDataType = {
|
|
130
|
+
address: string;
|
|
131
|
+
};
|
|
132
|
+
type WalletRpcResponseDataType = {
|
|
133
|
+
address: string;
|
|
134
|
+
response: RpcResponseType;
|
|
135
|
+
};
|
|
136
|
+
interface EmbeddedWalletProxy {
|
|
137
|
+
create: (data: WalletCreateRequestDataType) => Promise<WalletCreateResponseDataType>;
|
|
138
|
+
connect: (data: WalletConnectRequestDataType) => Promise<WalletConnectResponseDataType>;
|
|
139
|
+
recover: (data: WalletRecoverRequestDataType) => Promise<WalletRecoverResponseDataType>;
|
|
140
|
+
rpc: (data: WalletRpcRequestDataType) => Promise<WalletRpcResponseDataType>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
declare global {
|
|
144
|
+
interface Window {
|
|
145
|
+
ethereum?: unknown;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
type EIP1193OnEventHandler = ((accounts: string[]) => void) | ((chainId: string | number) => void);
|
|
149
|
+
interface EIP1193Provider {
|
|
150
|
+
request: (request: {
|
|
151
|
+
method: string;
|
|
152
|
+
params?: Array<any> | undefined;
|
|
153
|
+
}) => Promise<any>;
|
|
154
|
+
on: (eventName: string, listener: EIP1193OnEventHandler) => any;
|
|
155
|
+
removeListener: (eventName: string | symbol, listener: (...args: any[]) => void) => any;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The PrivyProxyProvider adds a middleware layer on top of the underlying wallet provider.
|
|
159
|
+
* @hidden
|
|
160
|
+
* */
|
|
161
|
+
declare class PrivyProxyProvider implements EIP1193Provider {
|
|
162
|
+
walletProvider?: EIP1193Provider;
|
|
163
|
+
private _subscriptions;
|
|
164
|
+
constructor(walletProvider?: EIP1193Provider);
|
|
165
|
+
on(eventName: string, listener: (...args: any[]) => void): any;
|
|
166
|
+
request(request: {
|
|
167
|
+
method: string;
|
|
168
|
+
params?: any[] | undefined;
|
|
169
|
+
}): Promise<any>;
|
|
170
|
+
removeListener: (eventName: string | symbol, listener: (...args: any[]) => void) => any;
|
|
171
|
+
setWalletProvider: (provider: EIP1193Provider) => void;
|
|
172
|
+
}
|
|
173
|
+
interface RequestArguments {
|
|
174
|
+
readonly method: string;
|
|
175
|
+
readonly params?: readonly unknown[] | object;
|
|
176
|
+
}
|
|
177
|
+
declare class Embedded1193Provider extends EventEmitter implements EIP1193Provider {
|
|
178
|
+
walletProxy: EmbeddedWalletProxy;
|
|
179
|
+
address: string;
|
|
180
|
+
infuraProvider: InfuraProvider;
|
|
181
|
+
chainId: number;
|
|
182
|
+
constructor(walletProxy: EmbeddedWalletProxy, address: string, chainId?: number);
|
|
183
|
+
handleSendTransaction(args: RequestArguments): Promise<string>;
|
|
184
|
+
private handleSwitchEthereumChain;
|
|
185
|
+
private handlePersonalSign;
|
|
186
|
+
private handleEstimateGas;
|
|
187
|
+
request(args: RequestArguments): Promise<unknown>;
|
|
188
|
+
connect(): Promise<string | null>;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Shim to convert to ethers-compatible ExternalProvider class.
|
|
192
|
+
* @hidden
|
|
193
|
+
*/
|
|
194
|
+
declare class AsExternalProvider extends PrivyProxyProvider implements ExternalProvider {
|
|
195
|
+
constructor(provider: EIP1193Provider);
|
|
196
|
+
isMetaMask?: boolean;
|
|
197
|
+
isStatus?: boolean;
|
|
198
|
+
host?: string;
|
|
199
|
+
path?: string;
|
|
200
|
+
sendAsync?: (request: {
|
|
201
|
+
method: string;
|
|
202
|
+
params?: Array<any>;
|
|
203
|
+
}, callback: (error: any, response: any) => void) => void;
|
|
204
|
+
send?: (request: {
|
|
205
|
+
method: string;
|
|
206
|
+
params?: Array<any>;
|
|
207
|
+
}, callback: (error: any, response: any) => void) => void;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
interface ConnectorEvents {
|
|
211
|
+
walletsUpdated(): void;
|
|
212
|
+
initialized(): void;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* @hidden
|
|
216
|
+
*
|
|
217
|
+
* A WalletConnector is identified by a connectorType and walletClientType. A
|
|
218
|
+
* connectorType includes injected, wallet_connect, etc. A walletClientType
|
|
219
|
+
* includes metamask, trustwallet, etc.
|
|
220
|
+
*
|
|
221
|
+
* Each WalletConnector manages a list of wallets, identified by an address
|
|
222
|
+
* and chainId. Each wallet has a connected property indicating its current
|
|
223
|
+
* connection status, which is determined based on events emitted by the
|
|
224
|
+
* underlying provider.
|
|
225
|
+
*
|
|
226
|
+
* The WalletConnector also emits two events: walletsUpdated and initialized.
|
|
227
|
+
* The walletsUpdated event is triggered when the list of wallets changes,
|
|
228
|
+
* while the initialized event is triggered when the WalletConnector is
|
|
229
|
+
* ready and has successfully executed the syncAccounts() function for
|
|
230
|
+
* the first time.
|
|
231
|
+
*/
|
|
232
|
+
declare abstract class WalletConnector extends EventEmitter<ConnectorEvents> {
|
|
233
|
+
connected: boolean;
|
|
234
|
+
initialized: boolean;
|
|
235
|
+
wallets: BaseConnectedWallet[];
|
|
236
|
+
walletClientType: WalletClientType;
|
|
237
|
+
abstract connectorType: ConnectorType;
|
|
238
|
+
abstract proxyProvider: PrivyProxyProvider | Embedded1193Provider;
|
|
239
|
+
constructor(walletClientType: WalletClientType);
|
|
240
|
+
/**
|
|
241
|
+
* Builds a connected wallet object to be exposed to the developer. This object
|
|
242
|
+
* contains the address, chainId, and a few helper methods.
|
|
243
|
+
*
|
|
244
|
+
* Provider methods share the PrivyProxyProvider instance. This means that multiple
|
|
245
|
+
* wallets may share the same provider if one wallet was disconnected and another
|
|
246
|
+
* wallet was connected.
|
|
247
|
+
*
|
|
248
|
+
* A wallet is considered connected if it is present in the wallets array and is
|
|
249
|
+
* in a connected state.
|
|
250
|
+
*/
|
|
251
|
+
buildConnectedWallet(address: string, chainId: string): BaseConnectedWallet;
|
|
252
|
+
/**
|
|
253
|
+
* Sync all accounts available via the provider if the wallet is connected.
|
|
254
|
+
*/
|
|
255
|
+
syncAccounts(): Promise<void>;
|
|
256
|
+
/**
|
|
257
|
+
* Get the most recently connected wallet.
|
|
258
|
+
*/
|
|
259
|
+
getConnectedWallet(): Promise<BaseConnectedWallet | null>;
|
|
260
|
+
/**
|
|
261
|
+
* As a proxy for "connected", we call eth_accounts and consider the client
|
|
262
|
+
* connected if at least one account is returned.
|
|
263
|
+
*/
|
|
264
|
+
isConnected(): Promise<boolean>;
|
|
265
|
+
/**
|
|
266
|
+
* Perform personal_sign with the user's wallet.
|
|
267
|
+
*
|
|
268
|
+
* @param {string} message The message to sign.
|
|
269
|
+
* @returns {string} The resulting signature.
|
|
270
|
+
*/
|
|
271
|
+
sign(message: string): Promise<string>;
|
|
272
|
+
protected onAccountsChanged: (_: string[]) => void;
|
|
273
|
+
protected onChainChanged: (chainId: string) => void;
|
|
274
|
+
protected onDisconnect: () => void;
|
|
275
|
+
protected onConnect: () => void;
|
|
276
|
+
subscribeListeners(): void;
|
|
277
|
+
unsubscribeListeners(): void;
|
|
278
|
+
abstract get walletBranding(): WalletBranding;
|
|
279
|
+
abstract connect(options: {
|
|
280
|
+
showPrompt?: boolean;
|
|
281
|
+
chainId?: number;
|
|
282
|
+
}): Promise<BaseConnectedWallet | null>;
|
|
283
|
+
abstract disconnect(): void;
|
|
284
|
+
abstract promptConnection(walletClientType: WalletClientType): void;
|
|
285
|
+
}
|
|
286
|
+
|
|
106
287
|
declare const SUPPORTED_OAUTH_PROVIDERS: readonly ["google", "discord", "twitter", "github", "apple"];
|
|
107
288
|
type OAuthProviderType = typeof SUPPORTED_OAUTH_PROVIDERS[number];
|
|
108
|
-
|
|
109
|
-
type
|
|
289
|
+
/** @hidden */
|
|
290
|
+
type EmbeddedWalletClientType = 'privy';
|
|
291
|
+
/** @hidden */
|
|
292
|
+
type InjectedWalletClientType = 'metamask' | 'phantom';
|
|
293
|
+
/** @hidden */
|
|
294
|
+
type CoinbaseWalletClientType = 'coinbase_wallet';
|
|
295
|
+
/** @hidden
|
|
296
|
+
*
|
|
297
|
+
* How this works:
|
|
298
|
+
*
|
|
299
|
+
* The raw data is pulled from https://registry.walletconnect.com/api/v2/wallets
|
|
300
|
+
* Some post-processing is done using the following script.
|
|
301
|
+
*
|
|
302
|
+
* const axios = require('axios');
|
|
303
|
+
* const walletTypes = [];
|
|
304
|
+
* axios.get("https://registry.walletconnect.com/api/v2/wallets").then((apiResult) => {
|
|
305
|
+
* Object.values(apiResult.data.listings).forEach((walletEntry) => {
|
|
306
|
+
* if (!walletEntry.mobile.native || !walletEntry.mobile.universal) return;
|
|
307
|
+
* if (!walletEntry.chains.includes('eip155:1')) return;
|
|
308
|
+
* if (!walletEntry.metadata.shortName) return;
|
|
309
|
+
* // Manually removed for cleanliness
|
|
310
|
+
* if (walletEntry.id === 'b2ce31fb31735fa886270806340de999f72342a7c29484badd8d4d013d77c8b8') return;
|
|
311
|
+
* if (walletEntry.id) walletTypes.push(`'${walletEntry.id}'`);
|
|
312
|
+
* });
|
|
313
|
+
* console.log(walletTypes.join("\n | "));
|
|
314
|
+
* });
|
|
315
|
+
*/
|
|
316
|
+
type WalletConnectWalletClientType = 'rainbow' | 'trust' | 'uniswap' | 'metamask' | 'argent' | 'spot' | 'zerion' | 'bitkeep' | 'unstoppable' | 'omni' | 'mathwallet' | 'bitpay' | '1inch' | 'eidoo' | 'coin98' | 'unstoppable' | 'alphawallet' | 'rwallet' | 'plasmapay' | 'o3wallet' | 'hashkey_me' | 'defiant' | 'essentials' | 'stasis' | 'julwallet' | 'tangem' | 'secux' | 'linen' | 'ambire' | 'obvious' | 'easypocket' | 'rice_wallet' | 'safemoon' | 'simplehold' | 'bitizen' | 'slavi_wallet' | 'nufinetes' | 'now_wallet' | 'blocto' | 'timeless' | 'arculus_wallet' | 'card' | 'mew_wallet' | 'pltwallet' | 'avacus' | 'bitski' | 'hippowallet' | 'edge' | 'assure' | 'enjin_wallet' | 'slingshot' | 'coinstats' | 'bitcoincom_wallet' | 'defiant' | 'binance';
|
|
317
|
+
/** @hidden */
|
|
318
|
+
type UnknownWalletClientType = 'unknown';
|
|
319
|
+
type WalletClientType = InjectedWalletClientType | CoinbaseWalletClientType | WalletConnectWalletClientType | EmbeddedWalletClientType | UnknownWalletClientType;
|
|
320
|
+
declare const SUPPORTED_CONNECTOR_TYPES: string[];
|
|
321
|
+
type ConnectorType = typeof SUPPORTED_CONNECTOR_TYPES[number];
|
|
110
322
|
/**
|
|
111
323
|
* Wallet metadata currently for internal use only
|
|
112
324
|
*/
|
|
@@ -134,9 +346,6 @@ interface Wallet {
|
|
|
134
346
|
* @experimental
|
|
135
347
|
* DO NOT USE: This feature is under active development.
|
|
136
348
|
*
|
|
137
|
-
* The chain ID of the active connected wallet, if used to verify in the current session.
|
|
138
|
-
* Only present for the active wallet.
|
|
139
|
-
*
|
|
140
349
|
* e.g. testnet, mainnet, goerli */
|
|
141
350
|
chainId?: string;
|
|
142
351
|
/**
|
|
@@ -152,6 +361,51 @@ interface Wallet {
|
|
|
152
361
|
*/
|
|
153
362
|
walletClient: 'privy' | 'unknown';
|
|
154
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* Object representation of a connected wallet.
|
|
366
|
+
*/
|
|
367
|
+
interface BaseConnectedWallet {
|
|
368
|
+
/** The wallet address. */
|
|
369
|
+
address: string;
|
|
370
|
+
/** The current chain ID with CAIP-2 formatting. */
|
|
371
|
+
chainId: string;
|
|
372
|
+
/** The first time this wallet was connected without break. */
|
|
373
|
+
connectedAt: number;
|
|
374
|
+
/** The wallet client where this key-pair is stored. */
|
|
375
|
+
walletClientType: WalletClientType;
|
|
376
|
+
/** The connector used to initiate the connection with the wallet client. */
|
|
377
|
+
connectorType: ConnectorType;
|
|
378
|
+
/** Returns true if the wallet is connected, false otherwise */
|
|
379
|
+
isConnected: () => Promise<boolean>;
|
|
380
|
+
/** Helper methods to build providers for interfacing with this wallet. */
|
|
381
|
+
getEthereumProvider: () => EIP1193Provider;
|
|
382
|
+
getEthersProvider: () => Web3Provider;
|
|
383
|
+
getWeb3jsProvider: () => AbstractProvider;
|
|
384
|
+
/**
|
|
385
|
+
* Perform personal_sign with the user's wallet.
|
|
386
|
+
*
|
|
387
|
+
* @param {string} message The message to sign.
|
|
388
|
+
* @returns {string} The resulting signature.
|
|
389
|
+
*/
|
|
390
|
+
sign: (message: string) => Promise<string>;
|
|
391
|
+
/** Disconnect method does not work on all connector types and will no-op if
|
|
392
|
+
* that is the case (metamask does not support programmatic disconnects) */
|
|
393
|
+
disconnect: () => void;
|
|
394
|
+
}
|
|
395
|
+
interface ConnectedWallet extends BaseConnectedWallet {
|
|
396
|
+
/** True if this wallet is linked to the authenticated user. False if it is not yet linked or
|
|
397
|
+
* the user has not yet authenticated. */
|
|
398
|
+
linked: boolean;
|
|
399
|
+
/** Link this wallet to the authenticated user. Throws a PrivyClientError if the user is not
|
|
400
|
+
* authenticated or if the wallet is not connected. */
|
|
401
|
+
link: () => Promise<void>;
|
|
402
|
+
/** Unlink this wallet to the authenticated user. Throws a PrivyClientError if the user is not
|
|
403
|
+
* authenticated. */
|
|
404
|
+
unlink: () => Promise<void>;
|
|
405
|
+
/** Login with this wallet. Throws a PrivyClientError if the user is already authenticated or
|
|
406
|
+
* the wallet is not connected. */
|
|
407
|
+
login: () => Promise<void>;
|
|
408
|
+
}
|
|
155
409
|
/** Object representation of a user's email. */
|
|
156
410
|
interface Email {
|
|
157
411
|
/** The email address. */
|
|
@@ -261,10 +515,9 @@ interface User {
|
|
|
261
515
|
email?: Email;
|
|
262
516
|
/** The user's phone number, if they have linked one. It cannot be linked to another user. */
|
|
263
517
|
phone?: Phone;
|
|
264
|
-
/** The user's
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
* The active wallet is the wallet that will be used for transactions and signing.
|
|
518
|
+
/** The user's most recently linked wallet, if they have linked at least one wallet.
|
|
519
|
+
* It cannot be linked to another user.
|
|
520
|
+
* This wallet is the wallet that will be used for transactions and signing if it is connected.
|
|
268
521
|
**/
|
|
269
522
|
wallet?: Wallet;
|
|
270
523
|
/** The user's Google account, if they have linked one. It cannot be linked to another user. */
|
|
@@ -440,7 +693,7 @@ interface PrivyProviderProps {
|
|
|
440
693
|
* @ignore
|
|
441
694
|
* @class
|
|
442
695
|
*/
|
|
443
|
-
children:
|
|
696
|
+
children: react.ReactNode;
|
|
444
697
|
}
|
|
445
698
|
/**
|
|
446
699
|
* Passes the Privy authentication context to your React components.
|
|
@@ -459,282 +712,89 @@ interface PrivyProviderProps {
|
|
|
459
712
|
*/
|
|
460
713
|
declare const PrivyProvider: (props: PrivyProviderProps) => JSX.Element;
|
|
461
714
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
recoveryPin: string;
|
|
465
|
-
};
|
|
466
|
-
type WalletConnectRequestDataType = {
|
|
467
|
-
accessToken: string;
|
|
468
|
-
address: string;
|
|
469
|
-
};
|
|
470
|
-
type WalletRecoverRequestDataType = {
|
|
471
|
-
accessToken: string;
|
|
472
|
-
address: string;
|
|
473
|
-
recoveryPin: string;
|
|
474
|
-
};
|
|
475
|
-
type WalletRpcRequestDataType = {
|
|
476
|
-
accessToken: string;
|
|
477
|
-
address: string;
|
|
478
|
-
request: RpcRequestType;
|
|
479
|
-
};
|
|
480
|
-
type WalletCreateResponseDataType = {
|
|
481
|
-
address: string;
|
|
482
|
-
};
|
|
483
|
-
type WalletConnectResponseDataType = {
|
|
484
|
-
address: string;
|
|
485
|
-
};
|
|
486
|
-
type WalletRecoverResponseDataType = {
|
|
487
|
-
address: string;
|
|
488
|
-
};
|
|
489
|
-
type WalletRpcResponseDataType = {
|
|
490
|
-
address: string;
|
|
491
|
-
response: RpcResponseType;
|
|
492
|
-
};
|
|
493
|
-
interface EmbeddedWalletProxy {
|
|
494
|
-
create: (data: WalletCreateRequestDataType) => Promise<WalletCreateResponseDataType>;
|
|
495
|
-
connect: (data: WalletConnectRequestDataType) => Promise<WalletConnectResponseDataType>;
|
|
496
|
-
recover: (data: WalletRecoverRequestDataType) => Promise<WalletRecoverResponseDataType>;
|
|
497
|
-
rpc: (data: WalletRpcRequestDataType) => Promise<WalletRpcResponseDataType>;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
declare global {
|
|
501
|
-
interface Window {
|
|
502
|
-
ethereum?: any;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
interface EIP1193Provider {
|
|
506
|
-
request: (request: {
|
|
507
|
-
method: string;
|
|
508
|
-
params?: Array<any> | undefined;
|
|
509
|
-
}) => Promise<any>;
|
|
510
|
-
on: (eventName: string, listener: (...args: unknown[]) => void) => any;
|
|
511
|
-
removeListener: (eventName: string | symbol, listener: (...args: any[]) => void) => any;
|
|
512
|
-
}
|
|
513
|
-
/**
|
|
514
|
-
* The PrivyProxyProvider adds a middleware layer on top of the underlying wallet provider.
|
|
515
|
-
* @hidden
|
|
516
|
-
* */
|
|
517
|
-
declare class PrivyProxyProvider implements EIP1193Provider {
|
|
518
|
-
walletProvider?: EIP1193Provider;
|
|
519
|
-
private _subscriptions;
|
|
520
|
-
constructor(walletProvider?: EIP1193Provider);
|
|
521
|
-
on(eventName: string, listener: (...args: any[]) => void): any;
|
|
522
|
-
request(request: {
|
|
523
|
-
method: string;
|
|
524
|
-
params?: any[] | undefined;
|
|
525
|
-
}): Promise<any>;
|
|
526
|
-
removeListener: (eventName: string | symbol, listener: (...args: any[]) => void) => any;
|
|
527
|
-
setWalletProvider: (provider: EIP1193Provider) => void;
|
|
528
|
-
}
|
|
529
|
-
interface RequestArguments {
|
|
530
|
-
readonly method: string;
|
|
531
|
-
readonly params?: readonly unknown[] | object;
|
|
532
|
-
}
|
|
533
|
-
declare class Embedded1193Provider extends EventEmitter implements EIP1193Provider {
|
|
534
|
-
walletProxy: EmbeddedWalletProxy;
|
|
535
|
-
address: string;
|
|
536
|
-
infuraProvider: InfuraProvider;
|
|
537
|
-
chainId: number;
|
|
538
|
-
constructor(walletProxy: EmbeddedWalletProxy, address: string, chainId?: number);
|
|
539
|
-
handleSendTransaction(args: RequestArguments): Promise<string>;
|
|
540
|
-
private handleSwitchEthereumChain;
|
|
541
|
-
private handlePersonalSign;
|
|
542
|
-
private handleEstimateGas;
|
|
543
|
-
request(args: RequestArguments): Promise<unknown>;
|
|
544
|
-
connect(): Promise<string | null>;
|
|
545
|
-
}
|
|
546
|
-
/**
|
|
547
|
-
* Shim to convert to ethers-compatible ExternalProvider class.
|
|
548
|
-
* @hidden
|
|
549
|
-
*/
|
|
550
|
-
declare class AsExternalProvider extends PrivyProxyProvider implements ExternalProvider {
|
|
551
|
-
constructor(provider: EIP1193Provider);
|
|
552
|
-
isMetaMask?: boolean;
|
|
553
|
-
isStatus?: boolean;
|
|
554
|
-
host?: string;
|
|
555
|
-
path?: string;
|
|
556
|
-
sendAsync?: (request: {
|
|
557
|
-
method: string;
|
|
558
|
-
params?: Array<any>;
|
|
559
|
-
}, callback: (error: any, response: any) => void) => void;
|
|
560
|
-
send?: (request: {
|
|
561
|
-
method: string;
|
|
562
|
-
params?: Array<any>;
|
|
563
|
-
}, callback: (error: any, response: any) => void) => void;
|
|
715
|
+
interface ConnectorManagerEvents {
|
|
716
|
+
walletsUpdated(): void;
|
|
564
717
|
}
|
|
565
|
-
|
|
566
718
|
/** @hidden */
|
|
567
|
-
declare
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
constructor(walletType: WalletType, proxyProvider: PrivyProxyProvider | Embedded1193Provider, address: string | null);
|
|
574
|
-
fetchAddress(): Promise<string | null>;
|
|
575
|
-
fetchChainId(): Promise<string>;
|
|
576
|
-
getConnectedWallet(): Promise<Wallet | null>;
|
|
577
|
-
abstract get walletBranding(): WalletBranding;
|
|
578
|
-
abstract connect(options: {
|
|
579
|
-
showPrompt: boolean;
|
|
580
|
-
chainId?: number;
|
|
581
|
-
}): Promise<Wallet | null>;
|
|
582
|
-
abstract disconnect(): void;
|
|
583
|
-
abstract isConnected(): Promise<boolean>;
|
|
584
|
-
abstract promptConnection(walletType: WalletType): void;
|
|
585
|
-
setActive(): Promise<boolean>;
|
|
719
|
+
declare class ConnectorManager extends EventEmitter<ConnectorManagerEvents> {
|
|
720
|
+
walletConnectors: WalletConnector[];
|
|
721
|
+
initialized: boolean;
|
|
722
|
+
private storedConnections;
|
|
723
|
+
private activeWallet?;
|
|
724
|
+
constructor();
|
|
586
725
|
/**
|
|
587
|
-
*
|
|
726
|
+
* The core wallets array that is exposed to developers. It builds
|
|
727
|
+
* the wallets away with the following logic:
|
|
588
728
|
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
|
|
592
|
-
sign(message: string): Promise<string>;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
/**
|
|
596
|
-
* Types aren't included in the final distribution, so we can have the duplicates here to assure
|
|
597
|
-
* type-safety
|
|
598
|
-
*/
|
|
599
|
-
type WalletId = '1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369' | '4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0' | 'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96' | '225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f' | '74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d' | 'ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18' | '8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3' | '38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662' | 'afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7' | 'ccb714920401f7d008dbe11281ae70e3a4bfb621763b187b9e4a3ce1ab8faa3b' | '7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26' | '2863183c3299d820fb9a4cb8aab4a34f50380c9992e8be871fd60a62e8d36481' | 'efba9ae0a9e0fdd9e3e055ddf3c8e75f294babb8aea3499456eff27f771fda61' | 'b021913ba555948a1c81eb3d89b372be46f8354e926679de648e4fa2938bed3e' | '7e90b95230bc462869bbb59f952273d89841e1c76bcc5319898e08c9f34bd4cd' | '138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98' | '468b4ab3582757233017ec10735863489104515ab160c053074905a1eecb7e63' | '29f4a70ad5993f3f73ae8119f0e78ecbae51deec2a021a770225c644935c0f09' | '8240fb8a7b117aed27f04aa8870c714eeb910f7c1b16c9b868e793c1836335b8' | '15d7610042217f691385d20e640869dc7273e991b04e8f476417cdc5ec856955' | 'a395dbfc92b5519cbd1cc6937a4e79830187daaeb2c6fcdf9b9cce4255f2dcd5' | '0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150' | '881946407ff22a32ec0e42b2cd31ea5dab52242dc3648d777b511a0440d59efb' | '3b0e861b3a57e98325b82ab687fe0a712c81366d521ceec49eebc35591f1b5d1' | '38ee551a01e3c5af9d8a9715768861e4d642e2381a62245083f96672b5646c6b' | 'f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d' | '15d1d97de89526a3c259a235304a7c510c40cda3331f0f8433da860ecc528bef' | '19ad8334f0f034f4176a95722b5746b539b47b37ce17a5abde4755956d05d44c' | '95501c1a07c8eb575cb28c753ab9044259546ebcefcd3645461086e49b671f5c' | '2ed796df33fdbde6a3ea6a47d3636b8341fe285038d844c7a78267b465b27028' | '4e6af4201658b52daad51a279bb363a08b3927e74c0f27abeca3b0110bddf0a9' | 'b13fcc7e3500a4580c9a5341ed64c49c17d7f864497881048eb160c089be5346' | '13c6a06b733edf51784f669f508826b2ab0dc80122a8b5d25d84b17d94bbdf70' | '0aafbedfb8eb56dae59ecc37c9a5388509cf9c082635e3f752581cc7128a17c0' | '761d3d98fd77bdb06e6c90092ee7071c6001e93401d05dcf2b007c1a6c9c222c' | 'ffa139f74d1c8ebbb748cf0166f92d886e8c81b521c2193aa940e00626f4e215' | '717911f4db0c5eda0e02e76ed179b7940ba1eefffdfb3c9e6540696226860da0' | '9d6c614d1995741d5313f1f3dbf1f66dcba694de782087d13b8721822502692f' | 'a6ffb821a3c32d36fc9d29e29c2ff79a0cd1db0bca453714777846ddf3fdff76' | '76745388a50e6fea982c4dee2a3ad61a8aa417668be870754689caa8a7506c93' | '6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa' | '2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568' | 'b823fb0d7228ef8e3c0bc9607df9ed79dae2ab3a2811d33f22ade4f573c18232' | 'dccbd717df77b395445cc6080e01fffada9d8b92dacfda312a26c70c2e9af673' | 'c6f3d04a4e1a51e7d2045f347a5ebdab30fc600950a740fca21f0c92e230ee05' | 'c482dfe368d4f004479977fd88e80dc9e81107f3245d706811581a6dfe69c534' | '14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd' | '0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92' | 'a2c031fccd13a6c16d7745c303507f78ae4da53fed064542804e9657d73e8b5c' | 'f593f4eb9755ff047681a37ebc46706e0e915cf1c2fe0102f5ae47c9f6aa4082' | '5859076ade608fbc4e9d3fe2f95e8527de80f8451ecbb1dced54ca84deae0dd6' | 'bb88a220ed4dcd3d717ec19b6ac00a672edf92e97ef7c243d35e25ff56a07301' | 'cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e' | 'b83a346877b71c02b8531f53485ce12bc00033eabcc1213ca3329cbc744813a5' | 'a92d512c649e87a5acba5885ac03f62662cff1f647c20a63833eb45a71a6f877' | '226d8a12a2e6e5c4185fa9c24313824bfb144c2a180325bddbd121844f497afa' | '11c5487e4d8dd8bf32d4c92222363df8296a27307b2531be1e25770365392ecb' | 'f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2' | '576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd' | '94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43' | 'bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6' | '664b505fea4c2117b8a55c054ef209664e0a68ddaafd7534df739f97a293fa1d' | '0c5bba82e70a2b62405871af809020a077d110d765c0798eb660ad5d3131b328' | '792fbacfe787d67595dd4eb38ac308e14b3bbc810393db56f477a92e5ac8764b' | '7ef337ff00714f179d38b8142398efa2ab902a53430e99ebce02892053d7a310' | '7e94e75c90964a69ea375b92214f50c4223dfbfa4913a3733b615444b322f687' | '107bb20463699c4e614d3a2fb7b961e66f48774cb8f6d6c1aee789853280972c' | '1986e7c874bb906f057d5d64a4806c004e021689536e5228c74d64a6058e8bac' | '19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b' | '37a686ab6223cd42e2886ed6e5477fce100a4fb565dcd57ed4f81f7c12e93053' | '4f5de5333fed2ccf47c690579aba3b9128aea78175339ff51ef61704bde7502a' | '9034d54985807aaf3d7780f50f155f954daa468fb58d7b14b216fc79d68bbd14' | 'c39d8ee468e50474fdf3a0bd6b981be404d4671e2702a3d633aae95bcbaa032a' | 'e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4' | '114efdbef4ce710081c1507f3dbc51f439c96a342cf33397799cd1c84b01a8c5' | '5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b' | '2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715' | 'e3787ea98d014ca77e2c3794db97c02ef8bcb39347705f5e79502a55434a1ecf' | '159b0423ce9075d5662f588f805931d989627affab3e63e4dd7ebc62b9c6738c' | 'fbea6f68df4e6ce163c144df86da89f24cb244f19b53903e26aea9ab7de6393c' | '1aedbcfc1f31aade56ca34c38b0a1607b41cccfa3de93c946ef3b4ba2dfab11c' | '14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc' | '031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa' | 'c40b9bcef32fa6ce4e0df98be1420628bbc4957646f742380fe618fcb4ab74f1' | 'b265ce38b94d602957a0946673c59a99a15d69adda4317544fec7298ea2d1387' | 'dc5415b6ea8114db518ae91195b027d690a11a1d2bfdd1a904e93c5cb746380e' | '41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071';
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* Light wrapper around WCConnectionManager that uses the global connection manager
|
|
603
|
-
* to manage the local storage layer and avoid conflicts.
|
|
604
|
-
* There can be multiple WCWalletConnectors, but should only ever be a single
|
|
605
|
-
* WCConnectionManager, which should be the class referenced - it will in turn find
|
|
606
|
-
* the appropriate WCWalletConnector for use with an action.
|
|
607
|
-
*/
|
|
608
|
-
declare class WCWalletConnector extends WalletConnector {
|
|
609
|
-
private connectionManager;
|
|
610
|
-
proxyProvider: PrivyProxyProvider;
|
|
611
|
-
constructor(connectionManager: WCConnectionManager, proxyProvider: PrivyProxyProvider, address: string | null);
|
|
612
|
-
setActive(): Promise<boolean>;
|
|
613
|
-
connect(options: {
|
|
614
|
-
showPrompt: boolean;
|
|
615
|
-
}): Promise<Wallet | null>;
|
|
616
|
-
isConnected(): Promise<boolean>;
|
|
617
|
-
/**
|
|
618
|
-
* Metadata about the wallet represented by this connector.
|
|
729
|
+
* 1. Flatten all wallets from all connectors
|
|
730
|
+
* 2. Sorted by connectedAT
|
|
731
|
+
* 3. Active wallet is moved to front of array (if it exists)
|
|
619
732
|
*/
|
|
620
|
-
get
|
|
621
|
-
name: string;
|
|
622
|
-
icon: string | EmbeddedSVG;
|
|
623
|
-
};
|
|
624
|
-
promptConnection(): Promise<void>;
|
|
733
|
+
get wallets(): BaseConnectedWallet[];
|
|
625
734
|
/**
|
|
626
|
-
*
|
|
735
|
+
* Detect and add all valid wallet connectors.
|
|
627
736
|
*/
|
|
628
|
-
|
|
629
|
-
disconnect(): void;
|
|
737
|
+
initialize(): void;
|
|
630
738
|
/**
|
|
631
|
-
*
|
|
739
|
+
* Restore previous Wallet Connect connections that have been stored in local storage.
|
|
632
740
|
*/
|
|
633
|
-
|
|
741
|
+
restoreWalletConnectConnectors(): void;
|
|
634
742
|
/**
|
|
635
|
-
*
|
|
743
|
+
* Helper function to find a wallet connector by connector type and wallet client type.
|
|
636
744
|
*/
|
|
637
|
-
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* An object representation of the Wallet Connect V1 protocol. This is used to initiate and manage connections
|
|
641
|
-
* with any number of wallets.
|
|
642
|
-
*/
|
|
643
|
-
declare class WCConnectionManager {
|
|
644
|
-
private _storageIdToProvider;
|
|
645
|
-
private reconnectDelayMs;
|
|
646
|
-
private reconnectBackoff;
|
|
647
|
-
constructor();
|
|
745
|
+
findWalletConnector(connectorType: ConnectorType, walletClientType: WalletClientType): WalletConnector | null;
|
|
648
746
|
/**
|
|
649
|
-
*
|
|
650
|
-
*
|
|
651
|
-
* If walletId is specified, attempts to launch into that specific flow.
|
|
652
|
-
*
|
|
653
|
-
* IMPORTANT! Nothing in this flow can be costly in order to properly launch our deep links. See:
|
|
654
|
-
* https://docs.walletconnect.com/1.0/mobile-linking#ios-app-link-constraints
|
|
747
|
+
* Add any connectedAt overrides for newly initialized wallets and pass-through change events.
|
|
655
748
|
*/
|
|
656
|
-
|
|
749
|
+
private onInitialized;
|
|
657
750
|
/**
|
|
658
|
-
*
|
|
659
|
-
* wallet. If omitted, but an address is provided, the connector may still attempt to link
|
|
660
|
-
* up to a wallet, but may be unable to. If a wallet cannot be determined, the standard WC
|
|
661
|
-
* modal is shown.
|
|
751
|
+
* Save connection history and pass-through change events.
|
|
662
752
|
*/
|
|
663
|
-
|
|
753
|
+
private onWalletsUpdated;
|
|
754
|
+
addEmbeddedWalletConnector(walletProxy: EmbeddedWalletProxy, address: string): void;
|
|
664
755
|
/**
|
|
665
|
-
*
|
|
756
|
+
* Normally, we do not remove connectors after creation. Privy embedded wallets are an exception
|
|
757
|
+
* because they are closely tied with an authenticated state.
|
|
666
758
|
*/
|
|
667
|
-
|
|
759
|
+
removeEmbeddedWalletConnector(): void;
|
|
668
760
|
/**
|
|
669
|
-
*
|
|
670
|
-
*
|
|
671
|
-
* just metamask and reuse if that. Admittedly, this method feels very fragile and unknown.
|
|
761
|
+
* Creates a new wallet connector for the given connector type and wallet client type.
|
|
762
|
+
* If a connector already exists, it will be returned instead.
|
|
672
763
|
*/
|
|
673
|
-
|
|
764
|
+
createWalletConnector(connectorType: ConnectorType, walletClientType: WalletClientType): WalletConnector | null;
|
|
765
|
+
private addWalletConnector;
|
|
674
766
|
/**
|
|
675
|
-
*
|
|
676
|
-
*
|
|
767
|
+
* Upon initialization, loads previous connections from local storage. If local storage
|
|
768
|
+
* is misformatted (e.g. due to previous privy:connectors usage), it returns an empty array that
|
|
769
|
+
* will be overwritten later.
|
|
770
|
+
*
|
|
771
|
+
* @returns StoredConnection[] list of stored connections from previous session
|
|
677
772
|
*/
|
|
678
|
-
|
|
679
|
-
private createProviderWithStorageId;
|
|
773
|
+
private loadConnectionHistory;
|
|
680
774
|
/**
|
|
681
|
-
*
|
|
682
|
-
* WC storageId. If walletId is specified, attempts to launch the WC flow for that particular
|
|
683
|
-
* wallet
|
|
775
|
+
* Saves all current connections to local storage overridding any previous connections.
|
|
684
776
|
*/
|
|
685
|
-
|
|
777
|
+
private saveConnectionHistory;
|
|
686
778
|
/**
|
|
687
|
-
*
|
|
779
|
+
* @deprecated **Deprecated**: This feature will be removed and should be replaced by
|
|
780
|
+
* interfacing with wallets directly (wallets[0].getEthereumProvider()).
|
|
688
781
|
*
|
|
689
|
-
*
|
|
690
|
-
* seeing - WC sessions wouldn't open a new modal/etc when doing `provider.enable()` if it had
|
|
691
|
-
* previously been rejected: https://github.com/Uniswap/web3-react/issues/217
|
|
782
|
+
* Build an Ethereum provider for the most recently connected wallet.
|
|
692
783
|
*/
|
|
693
|
-
replaceProvider(connector: WCWalletConnector, provider: WCProvider): WCProvider;
|
|
694
|
-
/**
|
|
695
|
-
* Enables the provider. Under the hood, this calls connect() and 'eth_RequestAccounts'.
|
|
696
|
-
*/
|
|
697
|
-
enableProvider(provider: WCProvider): Promise<string[]>;
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
/** @hidden */
|
|
701
|
-
declare class ConnectorManager {
|
|
702
|
-
walletConnectors: WalletConnector[];
|
|
703
|
-
activeWalletConnector?: WalletConnector;
|
|
704
|
-
initialized: boolean;
|
|
705
|
-
wcConnectionManager: WCConnectionManager;
|
|
706
|
-
constructor();
|
|
707
|
-
initialize(): void;
|
|
708
784
|
getEthereumProvider: () => EIP1193Provider;
|
|
709
785
|
/**
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
714
|
-
|
|
715
|
-
initializeLinkedWallets(user: User): void;
|
|
716
|
-
/** Load the state from storage and hydrate the instance with WalletConnectors. */
|
|
717
|
-
load(): void;
|
|
718
|
-
/** Persist the instance state to storage to reload the connectors later. */
|
|
719
|
-
save(): void;
|
|
720
|
-
addEmbeddedWalletConnector(walletProxy: EmbeddedWalletProxy, address: string): void;
|
|
721
|
-
addWalletConnector(walletConnector: WalletConnector): void;
|
|
722
|
-
getConnectorByAddress(address: string): WalletConnector | undefined;
|
|
723
|
-
removeWallet(address: string): Promise<void>;
|
|
724
|
-
/**
|
|
725
|
-
* Performing personal_sign with the active wallet
|
|
726
|
-
* If the active wallet is not connected, we connect it in just-in-time" fashion.
|
|
786
|
+
* @deprecated **Deprecated**: This feature will be removed and should be replaced by
|
|
787
|
+
* interfacing with `wallets` directly.
|
|
788
|
+
*
|
|
789
|
+
* Performing personal_sign with the most recently connected wallet.
|
|
790
|
+
* If there is not a wallet connected, return null.
|
|
727
791
|
*/
|
|
728
792
|
activeWalletSign(message: string): Promise<string | null>;
|
|
729
793
|
/**
|
|
730
|
-
*
|
|
731
|
-
*
|
|
732
|
-
* If the connector was successfully found and set active, return true.
|
|
794
|
+
* @deprecated **Deprecated**: This feature will be removed and should be replaced by
|
|
795
|
+
* interfacing with `wallets` directly.
|
|
733
796
|
*/
|
|
734
|
-
setActiveWallet(address: string
|
|
735
|
-
createWalletConnector(walletType: WalletType, address: string | null,
|
|
736
|
-
/** Only applicable for WalletConnect right now */
|
|
737
|
-
walletId?: WalletId): WalletConnector;
|
|
797
|
+
setActiveWallet(address: string): void;
|
|
738
798
|
}
|
|
739
799
|
|
|
740
800
|
/**
|
|
@@ -759,6 +819,10 @@ interface PrivyInterface {
|
|
|
759
819
|
* The user object, or null if the user is not authenticated.
|
|
760
820
|
*/
|
|
761
821
|
user: User | null;
|
|
822
|
+
/**
|
|
823
|
+
* Opens the Privy modal and prompts the user to connect a wallet.
|
|
824
|
+
*/
|
|
825
|
+
connectWallet: () => void;
|
|
762
826
|
/**
|
|
763
827
|
* Opens the Privy login modal and prompts the user to login.
|
|
764
828
|
*/
|
|
@@ -818,22 +882,33 @@ interface PrivyInterface {
|
|
|
818
882
|
*/
|
|
819
883
|
getAccessToken: () => Promise<string | null>;
|
|
820
884
|
/**
|
|
885
|
+
* @deprecated **Deprecated**: This feature will be removed and should be replaced by
|
|
886
|
+
* interfacing with wallets directly (wallets[0].getEthereumProvider()).
|
|
887
|
+
*
|
|
821
888
|
* Get an [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193)-compatible provider from the user's wallet, if the user has connected one.
|
|
822
889
|
*
|
|
823
890
|
* You may then use the Ethereum Javascript API syntax to send JSON-RPC requests to the user's wallet.
|
|
824
891
|
*/
|
|
825
892
|
getEthereumProvider: () => EIP1193Provider;
|
|
826
893
|
/**
|
|
894
|
+
* @deprecated **Deprecated**: This feature will be removed and should be replaced by
|
|
895
|
+
* interfacing with wallets directly (wallets[0].getEthersProvider()).
|
|
827
896
|
*
|
|
828
897
|
* Get an [ethers.js](https://docs.ethers.io/v5/)-compatible provider from the user's wallet, if the user has connected one.
|
|
829
898
|
*
|
|
830
899
|
*/
|
|
831
900
|
getEthersProvider: () => Web3Provider;
|
|
832
901
|
/**
|
|
902
|
+
* @deprecated **Deprecated**: This feature will be removed and should be replaced by
|
|
903
|
+
* interfacing with wallets directly (wallets[0].getWeb3jsProvider()).
|
|
904
|
+
*
|
|
833
905
|
* Get a [web3.js](https://web3js.readthedocs.io/en/v1.8.0/)-compatible provider from the user's wallet, if the user has connected one.
|
|
834
906
|
*/
|
|
835
907
|
getWeb3jsProvider: () => AbstractProvider;
|
|
836
908
|
/**
|
|
909
|
+
* @deprecated **Deprecated**: This feature will be removed and should be replaced by the
|
|
910
|
+
* `useWallet` hook.
|
|
911
|
+
*
|
|
837
912
|
* Get the ConnectorManager object
|
|
838
913
|
* This shouldn't need to be used directly unless creating a plugin, like a WAGMI plugin
|
|
839
914
|
*/
|
|
@@ -872,14 +947,10 @@ interface PrivyInterface {
|
|
|
872
947
|
*/
|
|
873
948
|
unlinkApple: (subject: string) => Promise<User>;
|
|
874
949
|
/**
|
|
875
|
-
*
|
|
876
|
-
*
|
|
877
|
-
* This will prompt the user to reconnect their wallet if the connection is lost.
|
|
950
|
+
* @deprecated **Deprecated**: This feature will be removed and behaves the same as connectWallet(). Instead, please
|
|
951
|
+
* interact with the wallets array directly.
|
|
878
952
|
*
|
|
879
|
-
*
|
|
880
|
-
* It is also the wallet present at `user.wallet`, and that value is updated when this is called.
|
|
881
|
-
*
|
|
882
|
-
* Note that when you link a new wallet, it becomes active.
|
|
953
|
+
* Note that when you connect a new wallet, it becomes first in the wallets array.
|
|
883
954
|
*/
|
|
884
955
|
setActiveWallet: (address: string) => Promise<void>;
|
|
885
956
|
/**
|
|
@@ -920,6 +991,18 @@ interface PrivyInterface {
|
|
|
920
991
|
*/
|
|
921
992
|
declare const usePrivy: () => PrivyInterface;
|
|
922
993
|
|
|
994
|
+
/**
|
|
995
|
+
* Allows you to manage the user's currently connected wallets.
|
|
996
|
+
* You can access the fields and methods documented here via the {@link useWallets} hook.
|
|
997
|
+
*/
|
|
998
|
+
interface UseWalletsInterface {
|
|
999
|
+
/**
|
|
1000
|
+
* The user's connected wallets.
|
|
1001
|
+
*/
|
|
1002
|
+
wallets: ConnectedWallet[];
|
|
1003
|
+
}
|
|
1004
|
+
declare function useWallets(): UseWalletsInterface;
|
|
1005
|
+
|
|
923
1006
|
declare const VERSION: string;
|
|
924
1007
|
|
|
925
1008
|
interface ResponseEmailAccount {
|
|
@@ -1130,7 +1213,6 @@ declare class PrivyClient {
|
|
|
1130
1213
|
}): Promise<string | null>;
|
|
1131
1214
|
getServerConfig(): Promise<PrivyServerConfig>;
|
|
1132
1215
|
getUsdTokenPrice(chainId: string | number): Promise<number | undefined>;
|
|
1133
|
-
setActiveWallet(address: string, user: User): Promise<User>;
|
|
1134
1216
|
/**
|
|
1135
1217
|
* Get a short-lived token to start a new Privy session from the existing authenticated session.
|
|
1136
1218
|
*
|
|
@@ -1143,4 +1225,4 @@ declare class PrivyClient {
|
|
|
1143
1225
|
forkSession(): Promise<string>;
|
|
1144
1226
|
}
|
|
1145
1227
|
|
|
1146
|
-
export { Apple, AppleOAuthWithMetadata, AsExternalProvider, ConnectorManager, Discord, DiscordOAuthWithMetadata, Email, EmailWithMetadata, Github, GithubOAuthWithMetadata, Google, GoogleOAuthWithMetadata, Phone, PhoneWithMetadata, PrivyClient, PrivyClientConfig, PrivyInterface, PrivyProvider, PrivyProviderProps, PrivyProxyProvider, Quantity, SendTransactionModalUIOptions, SignMessageModalUIOptions, TransactionLog, TransactionReceipt, Twitter, TwitterOAuthWithMetadata, UnsignedTransactionRequest, User, VERSION, Wallet, WalletConnector, WalletWithMetadata, getAccessToken, usePrivy };
|
|
1228
|
+
export { Apple, AppleOAuthWithMetadata, AsExternalProvider, ConnectedWallet, ConnectorManager, Discord, DiscordOAuthWithMetadata, EIP1193Provider, Email, EmailWithMetadata, Github, GithubOAuthWithMetadata, Google, GoogleOAuthWithMetadata, Phone, PhoneWithMetadata, PrivyClient, PrivyClientConfig, PrivyInterface, PrivyProvider, PrivyProviderProps, PrivyProxyProvider, Quantity, SendTransactionModalUIOptions, SignMessageModalUIOptions, TransactionLog, TransactionReceipt, Twitter, TwitterOAuthWithMetadata, UnsignedTransactionRequest, UseWalletsInterface, User, VERSION, Wallet, WalletConnector, WalletWithMetadata, getAccessToken, usePrivy, useWallets };
|