@broxus/evm-connect 1.16.0 → 1.17.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/sdk.mjs +1 -1
- package/package.json +19 -19
- package/dist/index.d.mts +0 -453
- package/dist/index.d.ts +0 -453
- package/dist/react.d.mts +0 -453
- package/dist/react.d.ts +0 -453
- package/dist/sdk.d.mts +0 -346
- package/dist/sdk.d.ts +0 -346
- /package/lib/{esm → types}/_react.d.ts +0 -0
- /package/lib/{esm → types}/_sdk.d.ts +0 -0
- /package/lib/{esm → types}/components/EvmConnectButton.d.ts +0 -0
- /package/lib/{esm → types}/components/EvmConnectDialog.d.ts +0 -0
- /package/lib/{esm → types}/components/EvmConnectionRequest.d.ts +0 -0
- /package/lib/{esm → types}/components/EvmConnector.d.ts +0 -0
- /package/lib/{esm → types}/components/EvmProviderButton.d.ts +0 -0
- /package/lib/{esm → types}/components/EvmProvidersDispatcher.d.ts +0 -0
- /package/lib/{esm → types}/components/EvmProvidersList.d.ts +0 -0
- /package/lib/{esm → types}/components/index.d.ts +0 -0
- /package/lib/{esm → types}/connectors/EIP6963Connector.d.ts +0 -0
- /package/lib/{esm → types}/connectors/MetaMask.d.ts +0 -0
- /package/lib/{esm → types}/connectors/WalletConnect.d.ts +0 -0
- /package/lib/{esm → types}/connectors/index.d.ts +0 -0
- /package/lib/{esm → types}/constants.d.ts +0 -0
- /package/lib/{esm → types}/context/EvmWalletProvidersContext.d.ts +0 -0
- /package/lib/{esm → types}/context/EvmWalletServiceContext.d.ts +0 -0
- /package/lib/{esm → types}/context/index.d.ts +0 -0
- /package/lib/{esm → types}/core/EthereumConnector.d.ts +0 -0
- /package/lib/{esm → types}/core/index.d.ts +0 -0
- /package/lib/{esm → types}/hooks/index.d.ts +0 -0
- /package/lib/{esm → types}/hooks/useContext.d.ts +0 -0
- /package/lib/{esm → types}/hooks/useEIP6963Connections.d.ts +0 -0
- /package/lib/{esm → types}/hooks/useFilteredConnections.d.ts +0 -0
- /package/lib/{esm → types}/hooks/useOrderedConnections.d.ts +0 -0
- /package/lib/{esm → types}/hooks/useRecentConnectionMeta.d.ts +0 -0
- /package/lib/{esm → types}/index.d.ts +0 -0
- /package/lib/{esm → types}/intl/index.d.ts +0 -0
- /package/lib/{esm → types}/services/EvmWalletService.d.ts +0 -0
- /package/lib/{esm → types}/services/index.d.ts +0 -0
- /package/lib/{esm → types}/types.d.ts +0 -0
- /package/lib/{esm → types}/utils/get-evm-provider-platform-link.d.ts +0 -0
- /package/lib/{esm → types}/utils/index.d.ts +0 -0
- /package/lib/{esm → types}/utils/parse-chain-id.d.ts +0 -0
- /package/lib/{esm → types}/utils/recent-connection-meta.d.ts +0 -0
- /package/lib/{esm → types}/utils/to-chain-params.d.ts +0 -0
package/dist/sdk.d.mts
DELETED
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
import Web3, { Web3APISpec, Web3EthExecutionAPI, EIP1193Provider, Web3BaseProvider, MetaMaskProvider, ProviderRpcError, EthExecutionAPI, EIP6963ProviderInfo, ProviderConnectInfo } from 'web3';
|
|
2
|
-
import { NetworkConfigBase, AbstractStore, NativeCurrency } from '@broxus/js-core';
|
|
3
|
-
import detectEthereumProvider from '@metamask/detect-provider';
|
|
4
|
-
import EthereumProvider, { EthereumProviderOptions } from '@walletconnect/ethereum-provider';
|
|
5
|
-
import { IReactionDisposer } from 'mobx';
|
|
6
|
-
|
|
7
|
-
type EvmBasedNetwork = 'evm';
|
|
8
|
-
interface EvmNetworkConfig extends NetworkConfigBase<string> {
|
|
9
|
-
transactionType?: string | string[];
|
|
10
|
-
type: EvmBasedNetwork;
|
|
11
|
-
}
|
|
12
|
-
type SupportedProviders<API extends Web3APISpec = Web3EthExecutionAPI> = EIP1193Provider<API> | Web3BaseProvider<API> | MetaMaskProvider<API>;
|
|
13
|
-
declare enum EthereumConnectionType {
|
|
14
|
-
INJECTED = "INJECTED",
|
|
15
|
-
COINBASE_WALLET = "COINBASE_WALLET",
|
|
16
|
-
WALLET_CONNECT_V2 = "WALLET_CONNECT_V2",
|
|
17
|
-
EIP_6963_INJECTED = "EIP_6963_INJECTED"
|
|
18
|
-
}
|
|
19
|
-
declare enum EIP6963Event {
|
|
20
|
-
REQUEST_PROVIDER = "eip6963:requestProvider",
|
|
21
|
-
ANNOUNCE_PROVIDER = "eip6963:announceProvider"
|
|
22
|
-
}
|
|
23
|
-
interface WatchAssetParameters {
|
|
24
|
-
address: string;
|
|
25
|
-
decimals: number;
|
|
26
|
-
image?: string;
|
|
27
|
-
symbol: string;
|
|
28
|
-
}
|
|
29
|
-
interface AddEthereumChainParams {
|
|
30
|
-
blockExplorerUrls?: string[];
|
|
31
|
-
chainId: number;
|
|
32
|
-
chainName: string;
|
|
33
|
-
iconUrls?: string[];
|
|
34
|
-
nativeCurrency: {
|
|
35
|
-
decimals: 18;
|
|
36
|
-
name: string;
|
|
37
|
-
symbol: string;
|
|
38
|
-
};
|
|
39
|
-
rpcUrls: string[];
|
|
40
|
-
}
|
|
41
|
-
interface RecentConnectionMeta {
|
|
42
|
-
chainId?: string;
|
|
43
|
-
disconnected?: boolean;
|
|
44
|
-
providerId: string;
|
|
45
|
-
type?: EthereumConnectionType;
|
|
46
|
-
}
|
|
47
|
-
type EvmProviderAvailablePlatforms = 'ios' | 'android' | 'chromeExtension' | 'firefoxExtension';
|
|
48
|
-
type EvmProviderPlatformLinks = Partial<Record<EvmProviderAvailablePlatforms, string>>;
|
|
49
|
-
interface EvmWalletProviderConfig {
|
|
50
|
-
connector: EthereumConnector;
|
|
51
|
-
id: string;
|
|
52
|
-
info: {
|
|
53
|
-
description?: string;
|
|
54
|
-
icon?: string;
|
|
55
|
-
links?: EvmProviderPlatformLinks & {
|
|
56
|
-
homepage?: string;
|
|
57
|
-
universalLink?: string;
|
|
58
|
-
};
|
|
59
|
-
name: string;
|
|
60
|
-
rdns?: string;
|
|
61
|
-
};
|
|
62
|
-
isRecent?: boolean;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
interface EthereumConnectorCtorParams {
|
|
66
|
-
onDisconnect?: (err: ProviderRpcError) => Promise<void> | void;
|
|
67
|
-
}
|
|
68
|
-
interface EthereumConnectorData {
|
|
69
|
-
accounts?: string[];
|
|
70
|
-
chainId?: number;
|
|
71
|
-
}
|
|
72
|
-
interface EthereumConnectorState {
|
|
73
|
-
isConnecting?: boolean;
|
|
74
|
-
isDisconnecting?: boolean;
|
|
75
|
-
isInitialized?: boolean;
|
|
76
|
-
isInitializing?: boolean;
|
|
77
|
-
}
|
|
78
|
-
declare abstract class EthereumConnector extends AbstractStore<EthereumConnectorData, EthereumConnectorState> {
|
|
79
|
-
protected readonly params?: Readonly<EthereumConnectorCtorParams> | undefined;
|
|
80
|
-
readonly type?: EthereumConnectionType;
|
|
81
|
-
/**
|
|
82
|
-
* An
|
|
83
|
-
* EIP-1193 ({@link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md}) and
|
|
84
|
-
* EIP-1102 ({@link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1102.md}) compliant provider.
|
|
85
|
-
* May also comply with EIP-3085 ({@link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3085.md}).
|
|
86
|
-
* This property must be defined while the connector is active.
|
|
87
|
-
*/
|
|
88
|
-
provider?: SupportedProviders<EthExecutionAPI>;
|
|
89
|
-
protected constructor(params?: Readonly<EthereumConnectorCtorParams> | undefined);
|
|
90
|
-
abstract connect(...args: unknown[]): Promise<void>;
|
|
91
|
-
abstract disconnect(...args: unknown[]): Promise<void>;
|
|
92
|
-
addNetwork(chainParams: AddEthereumChainParams): Promise<void>;
|
|
93
|
-
switchNetwork(chainIdOrParams: number | AddEthereumChainParams): Promise<void>;
|
|
94
|
-
watchAsset(params: WatchAssetParameters): Promise<true>;
|
|
95
|
-
get accounts(): EthereumConnectorData['accounts'];
|
|
96
|
-
get chainId(): EthereumConnectorData['chainId'];
|
|
97
|
-
get isConnecting(): EthereumConnectorState['isConnecting'];
|
|
98
|
-
get isDisconnecting(): EthereumConnectorState['isDisconnecting'];
|
|
99
|
-
get isInitialized(): EthereumConnectorState['isInitialized'];
|
|
100
|
-
get isInitializing(): EthereumConnectorState['isInitializing'];
|
|
101
|
-
protected handleAccountsChanged(accounts: string[]): void;
|
|
102
|
-
protected handleChainChanged(chainId: string): void;
|
|
103
|
-
protected handleDisconnect(err: ProviderRpcError): void;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
interface EIP6963ConnectorCtorParams extends EthereumConnectorCtorParams {
|
|
107
|
-
info: EIP6963ProviderInfo;
|
|
108
|
-
provider: Readonly<SupportedProviders<EthExecutionAPI>>;
|
|
109
|
-
}
|
|
110
|
-
declare class EIP6963Connector extends EthereumConnector {
|
|
111
|
-
protected readonly params: Readonly<EIP6963ConnectorCtorParams>;
|
|
112
|
-
readonly type = EthereumConnectionType.EIP_6963_INJECTED;
|
|
113
|
-
constructor(params: Readonly<EIP6963ConnectorCtorParams>);
|
|
114
|
-
connect(chainIdOrParams?: number | AddEthereumChainParams): Promise<void>;
|
|
115
|
-
disconnect(): Promise<void>;
|
|
116
|
-
protected init(): Promise<void>;
|
|
117
|
-
protected handleConnect({ chainId }: ProviderConnectInfo): void;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
interface MetaMaskEthereumProvider extends MetaMaskProvider<EthExecutionAPI> {
|
|
121
|
-
get accounts(): string[];
|
|
122
|
-
get chainId(): string;
|
|
123
|
-
isConnected?: () => boolean;
|
|
124
|
-
providers?: MetaMaskEthereumProvider[];
|
|
125
|
-
}
|
|
126
|
-
interface MetaMaskCtorParams extends EthereumConnectorCtorParams {
|
|
127
|
-
options?: Parameters<typeof detectEthereumProvider>[0];
|
|
128
|
-
}
|
|
129
|
-
declare class MetaMask extends EthereumConnector {
|
|
130
|
-
protected readonly params?: Readonly<MetaMaskCtorParams> | undefined;
|
|
131
|
-
readonly type = EthereumConnectionType.INJECTED;
|
|
132
|
-
provider?: MetaMaskEthereumProvider;
|
|
133
|
-
constructor(params?: Readonly<MetaMaskCtorParams> | undefined);
|
|
134
|
-
connect(chainIdOrParams?: number | AddEthereumChainParams): Promise<void>;
|
|
135
|
-
disconnect(): Promise<void>;
|
|
136
|
-
protected init(): Promise<void>;
|
|
137
|
-
protected handleConnect({ chainId }: ProviderConnectInfo): void;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
interface WalletConnectOptions extends Omit<EthereumProviderOptions, 'rpcMap'> {
|
|
141
|
-
rpcMap?: Record<number, string | string[]>;
|
|
142
|
-
}
|
|
143
|
-
interface WalletConnectCtorParams extends EthereumConnectorCtorParams {
|
|
144
|
-
options: WalletConnectOptions;
|
|
145
|
-
}
|
|
146
|
-
declare class WalletConnect extends EthereumConnector {
|
|
147
|
-
protected readonly params: Readonly<WalletConnectCtorParams>;
|
|
148
|
-
readonly type = EthereumConnectionType.WALLET_CONNECT_V2;
|
|
149
|
-
provider?: EthereumProvider;
|
|
150
|
-
protected readonly options: WalletConnectOptions;
|
|
151
|
-
constructor(params: Readonly<WalletConnectCtorParams>);
|
|
152
|
-
connect(chainIdOrParams?: number | AddEthereumChainParams): Promise<void>;
|
|
153
|
-
disconnect(): Promise<void>;
|
|
154
|
-
protected init(): Promise<void>;
|
|
155
|
-
protected createProvider(): Promise<EthereumProvider>;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
declare const EVM_RECENT_CONNECTION = "EVM_RECENT_CONNECTION";
|
|
159
|
-
|
|
160
|
-
interface EvmWalletServiceCtorParams {
|
|
161
|
-
autoInit?: boolean;
|
|
162
|
-
defaultNetworkId?: number;
|
|
163
|
-
/**
|
|
164
|
-
* List of supported networks
|
|
165
|
-
*/
|
|
166
|
-
networks?: Readonly<EvmNetworkConfig[]>;
|
|
167
|
-
providerId?: string;
|
|
168
|
-
/**
|
|
169
|
-
* List of supported Providers
|
|
170
|
-
*/
|
|
171
|
-
providers?: Readonly<EvmWalletProviderConfig[]>;
|
|
172
|
-
}
|
|
173
|
-
interface EvmWalletServiceData {
|
|
174
|
-
balance?: string;
|
|
175
|
-
networks: Readonly<EvmNetworkConfig[]>;
|
|
176
|
-
}
|
|
177
|
-
interface EvmWalletServiceState {
|
|
178
|
-
isSyncing?: boolean;
|
|
179
|
-
providerId?: string;
|
|
180
|
-
}
|
|
181
|
-
declare class EvmWalletService extends AbstractStore<EvmWalletServiceData, EvmWalletServiceState> {
|
|
182
|
-
protected readonly params?: Readonly<EvmWalletServiceCtorParams> | undefined;
|
|
183
|
-
readonly name = "EvmWalletService";
|
|
184
|
-
constructor(params?: Readonly<EvmWalletServiceCtorParams> | undefined);
|
|
185
|
-
/**
|
|
186
|
-
* Define current provider connector
|
|
187
|
-
* @returns {EthereumConnector|undefined}
|
|
188
|
-
*/
|
|
189
|
-
get connector(): EthereumConnector | undefined;
|
|
190
|
-
init(): Promise<void>;
|
|
191
|
-
/**
|
|
192
|
-
* Manually connect to the wallet
|
|
193
|
-
* @returns {Promise<void>}
|
|
194
|
-
*/
|
|
195
|
-
connect(networkIdOParams?: number | AddEthereumChainParams): Promise<void>;
|
|
196
|
-
/**
|
|
197
|
-
* Manually disconnect from the wallet
|
|
198
|
-
* @param {boolean} force
|
|
199
|
-
* @returns {Promise<void>}
|
|
200
|
-
*/
|
|
201
|
-
disconnect(force?: boolean): Promise<void>;
|
|
202
|
-
/**
|
|
203
|
-
* Add network to the current connected wallet
|
|
204
|
-
* @param {AddEthereumChainParams} chainParams
|
|
205
|
-
* @returns {Promise<void>}
|
|
206
|
-
*/
|
|
207
|
-
addNetwork(chainParams: AddEthereumChainParams): Promise<void>;
|
|
208
|
-
/**
|
|
209
|
-
* Switch network or add a new one if not exists in the current connected wallet
|
|
210
|
-
* @param {number|AddEthereumChainParams} chainIdOrParams
|
|
211
|
-
* @returns {Promise<void>}
|
|
212
|
-
*/
|
|
213
|
-
switchNetwork(chainIdOrParams: number | AddEthereumChainParams): Promise<void>;
|
|
214
|
-
/**
|
|
215
|
-
* Request to the wallet for watch asset
|
|
216
|
-
* @param {WatchAssetParameters} params
|
|
217
|
-
* @returns {Promise<true | undefined>}
|
|
218
|
-
*/
|
|
219
|
-
watchAsset(params: WatchAssetParameters): Promise<true | undefined>;
|
|
220
|
-
/**
|
|
221
|
-
* An independent RPC connection that allows you to receive data from the blockchain without being
|
|
222
|
-
* able to send transactions.
|
|
223
|
-
*
|
|
224
|
-
* This connection does not require connection permissions and wrapped on `Web3` interface.
|
|
225
|
-
* @returns {Web3|undefined}
|
|
226
|
-
*/
|
|
227
|
-
get connection(): Web3 | undefined;
|
|
228
|
-
/**
|
|
229
|
-
* Returns current Web3 Instance
|
|
230
|
-
*/
|
|
231
|
-
get provider(): Web3 | undefined;
|
|
232
|
-
/**
|
|
233
|
-
* Returns computed wallet balance value
|
|
234
|
-
* @returns {EvmWalletServiceData["balance"]}
|
|
235
|
-
*/
|
|
236
|
-
get balance(): EvmWalletServiceData['balance'];
|
|
237
|
-
/**
|
|
238
|
-
* List of the supported networks
|
|
239
|
-
* @returns {EvmWalletServiceData["networks"]}
|
|
240
|
-
*/
|
|
241
|
-
get networks(): EvmWalletServiceData['networks'];
|
|
242
|
-
/**
|
|
243
|
-
* Returns `true` if wallet contract is updating
|
|
244
|
-
* @returns {EvmWalletServiceState["isSyncing"]}
|
|
245
|
-
*/
|
|
246
|
-
get isSyncing(): EvmWalletServiceState['isSyncing'];
|
|
247
|
-
/**
|
|
248
|
-
A unique identifier of the connected wallet (provider)
|
|
249
|
-
* @returns {EvmWalletServiceState["providerId"]}
|
|
250
|
-
*/
|
|
251
|
-
get providerId(): EvmWalletServiceState['providerId'];
|
|
252
|
-
/**
|
|
253
|
-
* Returns computed wallet address value
|
|
254
|
-
* @returns {string|undefined}
|
|
255
|
-
*/
|
|
256
|
-
get address(): string | undefined;
|
|
257
|
-
/**
|
|
258
|
-
* Returns wallet native currency
|
|
259
|
-
* @returns {Readonly<NativeCurrency<string>>}
|
|
260
|
-
*/
|
|
261
|
-
get currency(): Readonly<NativeCurrency<string>>;
|
|
262
|
-
/**
|
|
263
|
-
* Returns `true` if provider is available.
|
|
264
|
-
* That means extension is installed and activated, else `false`
|
|
265
|
-
* @returns {boolean}
|
|
266
|
-
*/
|
|
267
|
-
get hasProvider(): boolean;
|
|
268
|
-
/**
|
|
269
|
-
* Returns `true` if wallet is connected
|
|
270
|
-
* @returns {boolean}
|
|
271
|
-
*/
|
|
272
|
-
get isConnected(): boolean;
|
|
273
|
-
/**
|
|
274
|
-
* Returns `true` if wallet is initialized and connected
|
|
275
|
-
* @returns {boolean}
|
|
276
|
-
*/
|
|
277
|
-
get isReady(): boolean;
|
|
278
|
-
/**
|
|
279
|
-
* Checks network support
|
|
280
|
-
* @returns {boolean}
|
|
281
|
-
*/
|
|
282
|
-
get isUnsupportedNetwork(): boolean;
|
|
283
|
-
/**
|
|
284
|
-
* Returns current network config
|
|
285
|
-
* @returns {Readonly<EvmNetworkConfig|undefined>}
|
|
286
|
-
*/
|
|
287
|
-
get network(): Readonly<EvmNetworkConfig | undefined>;
|
|
288
|
-
/**
|
|
289
|
-
Returns details about current connected provider
|
|
290
|
-
* @returns {EvmWalletProviderConfig["info"]|undefined}
|
|
291
|
-
*/
|
|
292
|
-
get providerInfo(): EvmWalletProviderConfig['info'] | undefined;
|
|
293
|
-
/**
|
|
294
|
-
* The list of the supported providers
|
|
295
|
-
* @returns {Readonly<EvmWalletProviderConfig[]|undefined>}
|
|
296
|
-
*/
|
|
297
|
-
get providers(): Readonly<EvmWalletProviderConfig[]>;
|
|
298
|
-
/**
|
|
299
|
-
* Returns current network chain id
|
|
300
|
-
* @returns {EthereumConnector["chainId"]}
|
|
301
|
-
*/
|
|
302
|
-
get chainId(): EthereumConnector['chainId'];
|
|
303
|
-
/**
|
|
304
|
-
* Returns `true` if wallet is connecting
|
|
305
|
-
* @returns {EthereumConnector["isConnecting"]}
|
|
306
|
-
*/
|
|
307
|
-
get isConnecting(): EthereumConnector['isConnecting'];
|
|
308
|
-
/**
|
|
309
|
-
* Returns `true` if wallet is disconnecting
|
|
310
|
-
* @returns {EthereumConnector["isDisconnecting"]}
|
|
311
|
-
*/
|
|
312
|
-
get isDisconnecting(): EthereumConnector['isDisconnecting'];
|
|
313
|
-
/**
|
|
314
|
-
* Returns `true` if wallet is initialized
|
|
315
|
-
* @returns {EthereumConnector["isInitialized"]}
|
|
316
|
-
*/
|
|
317
|
-
get isInitialized(): EthereumConnector['isInitialized'];
|
|
318
|
-
/**
|
|
319
|
-
* Returns `true` if wallet is initializing
|
|
320
|
-
* @returns {EthereumConnector["isInitializing"]}
|
|
321
|
-
*/
|
|
322
|
-
get isInitializing(): EthereumConnector['isInitializing'];
|
|
323
|
-
/**
|
|
324
|
-
* Sync account balance
|
|
325
|
-
*/
|
|
326
|
-
protected syncBalance(): Promise<void>;
|
|
327
|
-
/**
|
|
328
|
-
* Trying to resolve EVM Wallet connection
|
|
329
|
-
* @protected
|
|
330
|
-
*/
|
|
331
|
-
protected _init(): Promise<void>;
|
|
332
|
-
protected accountDisposer: IReactionDisposer | undefined;
|
|
333
|
-
protected networkDisposer: IReactionDisposer | undefined;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
declare function getEvmProviderPlatformLink(links: EvmProviderPlatformLinks): [EvmProviderAvailablePlatforms, string | undefined] | undefined;
|
|
337
|
-
|
|
338
|
-
declare function parseChainId(chainId: string | number): number;
|
|
339
|
-
|
|
340
|
-
declare function isRecentConnectionMeta(value: any): value is RecentConnectionMeta;
|
|
341
|
-
declare function storeRecentConnectionMeta(meta: RecentConnectionMeta | undefined, storageKey?: string): void;
|
|
342
|
-
declare function getRecentConnectionMeta(storageKey?: string): RecentConnectionMeta | undefined;
|
|
343
|
-
|
|
344
|
-
declare function toChainParams(network: EvmNetworkConfig): AddEthereumChainParams;
|
|
345
|
-
|
|
346
|
-
export { type AddEthereumChainParams, EIP6963Connector, type EIP6963ConnectorCtorParams, EIP6963Event, EVM_RECENT_CONNECTION, EthereumConnectionType, EthereumConnector, type EthereumConnectorCtorParams, type EthereumConnectorData, type EthereumConnectorState, type EvmNetworkConfig, type EvmProviderAvailablePlatforms, type EvmProviderPlatformLinks, type EvmWalletProviderConfig, EvmWalletService, type EvmWalletServiceCtorParams, type EvmWalletServiceData, type EvmWalletServiceState, MetaMask, type MetaMaskCtorParams, type RecentConnectionMeta, type SupportedProviders, WalletConnect, type WalletConnectCtorParams, type WalletConnectOptions, type WatchAssetParameters, getEvmProviderPlatformLink, getRecentConnectionMeta, isRecentConnectionMeta, parseChainId, storeRecentConnectionMeta, toChainParams };
|
package/dist/sdk.d.ts
DELETED
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
import Web3, { Web3APISpec, Web3EthExecutionAPI, EIP1193Provider, Web3BaseProvider, MetaMaskProvider, ProviderRpcError, EthExecutionAPI, EIP6963ProviderInfo, ProviderConnectInfo } from 'web3';
|
|
2
|
-
import { NetworkConfigBase, AbstractStore, NativeCurrency } from '@broxus/js-core';
|
|
3
|
-
import detectEthereumProvider from '@metamask/detect-provider';
|
|
4
|
-
import EthereumProvider, { EthereumProviderOptions } from '@walletconnect/ethereum-provider';
|
|
5
|
-
import { IReactionDisposer } from 'mobx';
|
|
6
|
-
|
|
7
|
-
type EvmBasedNetwork = 'evm';
|
|
8
|
-
interface EvmNetworkConfig extends NetworkConfigBase<string> {
|
|
9
|
-
transactionType?: string | string[];
|
|
10
|
-
type: EvmBasedNetwork;
|
|
11
|
-
}
|
|
12
|
-
type SupportedProviders<API extends Web3APISpec = Web3EthExecutionAPI> = EIP1193Provider<API> | Web3BaseProvider<API> | MetaMaskProvider<API>;
|
|
13
|
-
declare enum EthereumConnectionType {
|
|
14
|
-
INJECTED = "INJECTED",
|
|
15
|
-
COINBASE_WALLET = "COINBASE_WALLET",
|
|
16
|
-
WALLET_CONNECT_V2 = "WALLET_CONNECT_V2",
|
|
17
|
-
EIP_6963_INJECTED = "EIP_6963_INJECTED"
|
|
18
|
-
}
|
|
19
|
-
declare enum EIP6963Event {
|
|
20
|
-
REQUEST_PROVIDER = "eip6963:requestProvider",
|
|
21
|
-
ANNOUNCE_PROVIDER = "eip6963:announceProvider"
|
|
22
|
-
}
|
|
23
|
-
interface WatchAssetParameters {
|
|
24
|
-
address: string;
|
|
25
|
-
decimals: number;
|
|
26
|
-
image?: string;
|
|
27
|
-
symbol: string;
|
|
28
|
-
}
|
|
29
|
-
interface AddEthereumChainParams {
|
|
30
|
-
blockExplorerUrls?: string[];
|
|
31
|
-
chainId: number;
|
|
32
|
-
chainName: string;
|
|
33
|
-
iconUrls?: string[];
|
|
34
|
-
nativeCurrency: {
|
|
35
|
-
decimals: 18;
|
|
36
|
-
name: string;
|
|
37
|
-
symbol: string;
|
|
38
|
-
};
|
|
39
|
-
rpcUrls: string[];
|
|
40
|
-
}
|
|
41
|
-
interface RecentConnectionMeta {
|
|
42
|
-
chainId?: string;
|
|
43
|
-
disconnected?: boolean;
|
|
44
|
-
providerId: string;
|
|
45
|
-
type?: EthereumConnectionType;
|
|
46
|
-
}
|
|
47
|
-
type EvmProviderAvailablePlatforms = 'ios' | 'android' | 'chromeExtension' | 'firefoxExtension';
|
|
48
|
-
type EvmProviderPlatformLinks = Partial<Record<EvmProviderAvailablePlatforms, string>>;
|
|
49
|
-
interface EvmWalletProviderConfig {
|
|
50
|
-
connector: EthereumConnector;
|
|
51
|
-
id: string;
|
|
52
|
-
info: {
|
|
53
|
-
description?: string;
|
|
54
|
-
icon?: string;
|
|
55
|
-
links?: EvmProviderPlatformLinks & {
|
|
56
|
-
homepage?: string;
|
|
57
|
-
universalLink?: string;
|
|
58
|
-
};
|
|
59
|
-
name: string;
|
|
60
|
-
rdns?: string;
|
|
61
|
-
};
|
|
62
|
-
isRecent?: boolean;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
interface EthereumConnectorCtorParams {
|
|
66
|
-
onDisconnect?: (err: ProviderRpcError) => Promise<void> | void;
|
|
67
|
-
}
|
|
68
|
-
interface EthereumConnectorData {
|
|
69
|
-
accounts?: string[];
|
|
70
|
-
chainId?: number;
|
|
71
|
-
}
|
|
72
|
-
interface EthereumConnectorState {
|
|
73
|
-
isConnecting?: boolean;
|
|
74
|
-
isDisconnecting?: boolean;
|
|
75
|
-
isInitialized?: boolean;
|
|
76
|
-
isInitializing?: boolean;
|
|
77
|
-
}
|
|
78
|
-
declare abstract class EthereumConnector extends AbstractStore<EthereumConnectorData, EthereumConnectorState> {
|
|
79
|
-
protected readonly params?: Readonly<EthereumConnectorCtorParams> | undefined;
|
|
80
|
-
readonly type?: EthereumConnectionType;
|
|
81
|
-
/**
|
|
82
|
-
* An
|
|
83
|
-
* EIP-1193 ({@link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md}) and
|
|
84
|
-
* EIP-1102 ({@link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1102.md}) compliant provider.
|
|
85
|
-
* May also comply with EIP-3085 ({@link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3085.md}).
|
|
86
|
-
* This property must be defined while the connector is active.
|
|
87
|
-
*/
|
|
88
|
-
provider?: SupportedProviders<EthExecutionAPI>;
|
|
89
|
-
protected constructor(params?: Readonly<EthereumConnectorCtorParams> | undefined);
|
|
90
|
-
abstract connect(...args: unknown[]): Promise<void>;
|
|
91
|
-
abstract disconnect(...args: unknown[]): Promise<void>;
|
|
92
|
-
addNetwork(chainParams: AddEthereumChainParams): Promise<void>;
|
|
93
|
-
switchNetwork(chainIdOrParams: number | AddEthereumChainParams): Promise<void>;
|
|
94
|
-
watchAsset(params: WatchAssetParameters): Promise<true>;
|
|
95
|
-
get accounts(): EthereumConnectorData['accounts'];
|
|
96
|
-
get chainId(): EthereumConnectorData['chainId'];
|
|
97
|
-
get isConnecting(): EthereumConnectorState['isConnecting'];
|
|
98
|
-
get isDisconnecting(): EthereumConnectorState['isDisconnecting'];
|
|
99
|
-
get isInitialized(): EthereumConnectorState['isInitialized'];
|
|
100
|
-
get isInitializing(): EthereumConnectorState['isInitializing'];
|
|
101
|
-
protected handleAccountsChanged(accounts: string[]): void;
|
|
102
|
-
protected handleChainChanged(chainId: string): void;
|
|
103
|
-
protected handleDisconnect(err: ProviderRpcError): void;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
interface EIP6963ConnectorCtorParams extends EthereumConnectorCtorParams {
|
|
107
|
-
info: EIP6963ProviderInfo;
|
|
108
|
-
provider: Readonly<SupportedProviders<EthExecutionAPI>>;
|
|
109
|
-
}
|
|
110
|
-
declare class EIP6963Connector extends EthereumConnector {
|
|
111
|
-
protected readonly params: Readonly<EIP6963ConnectorCtorParams>;
|
|
112
|
-
readonly type = EthereumConnectionType.EIP_6963_INJECTED;
|
|
113
|
-
constructor(params: Readonly<EIP6963ConnectorCtorParams>);
|
|
114
|
-
connect(chainIdOrParams?: number | AddEthereumChainParams): Promise<void>;
|
|
115
|
-
disconnect(): Promise<void>;
|
|
116
|
-
protected init(): Promise<void>;
|
|
117
|
-
protected handleConnect({ chainId }: ProviderConnectInfo): void;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
interface MetaMaskEthereumProvider extends MetaMaskProvider<EthExecutionAPI> {
|
|
121
|
-
get accounts(): string[];
|
|
122
|
-
get chainId(): string;
|
|
123
|
-
isConnected?: () => boolean;
|
|
124
|
-
providers?: MetaMaskEthereumProvider[];
|
|
125
|
-
}
|
|
126
|
-
interface MetaMaskCtorParams extends EthereumConnectorCtorParams {
|
|
127
|
-
options?: Parameters<typeof detectEthereumProvider>[0];
|
|
128
|
-
}
|
|
129
|
-
declare class MetaMask extends EthereumConnector {
|
|
130
|
-
protected readonly params?: Readonly<MetaMaskCtorParams> | undefined;
|
|
131
|
-
readonly type = EthereumConnectionType.INJECTED;
|
|
132
|
-
provider?: MetaMaskEthereumProvider;
|
|
133
|
-
constructor(params?: Readonly<MetaMaskCtorParams> | undefined);
|
|
134
|
-
connect(chainIdOrParams?: number | AddEthereumChainParams): Promise<void>;
|
|
135
|
-
disconnect(): Promise<void>;
|
|
136
|
-
protected init(): Promise<void>;
|
|
137
|
-
protected handleConnect({ chainId }: ProviderConnectInfo): void;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
interface WalletConnectOptions extends Omit<EthereumProviderOptions, 'rpcMap'> {
|
|
141
|
-
rpcMap?: Record<number, string | string[]>;
|
|
142
|
-
}
|
|
143
|
-
interface WalletConnectCtorParams extends EthereumConnectorCtorParams {
|
|
144
|
-
options: WalletConnectOptions;
|
|
145
|
-
}
|
|
146
|
-
declare class WalletConnect extends EthereumConnector {
|
|
147
|
-
protected readonly params: Readonly<WalletConnectCtorParams>;
|
|
148
|
-
readonly type = EthereumConnectionType.WALLET_CONNECT_V2;
|
|
149
|
-
provider?: EthereumProvider;
|
|
150
|
-
protected readonly options: WalletConnectOptions;
|
|
151
|
-
constructor(params: Readonly<WalletConnectCtorParams>);
|
|
152
|
-
connect(chainIdOrParams?: number | AddEthereumChainParams): Promise<void>;
|
|
153
|
-
disconnect(): Promise<void>;
|
|
154
|
-
protected init(): Promise<void>;
|
|
155
|
-
protected createProvider(): Promise<EthereumProvider>;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
declare const EVM_RECENT_CONNECTION = "EVM_RECENT_CONNECTION";
|
|
159
|
-
|
|
160
|
-
interface EvmWalletServiceCtorParams {
|
|
161
|
-
autoInit?: boolean;
|
|
162
|
-
defaultNetworkId?: number;
|
|
163
|
-
/**
|
|
164
|
-
* List of supported networks
|
|
165
|
-
*/
|
|
166
|
-
networks?: Readonly<EvmNetworkConfig[]>;
|
|
167
|
-
providerId?: string;
|
|
168
|
-
/**
|
|
169
|
-
* List of supported Providers
|
|
170
|
-
*/
|
|
171
|
-
providers?: Readonly<EvmWalletProviderConfig[]>;
|
|
172
|
-
}
|
|
173
|
-
interface EvmWalletServiceData {
|
|
174
|
-
balance?: string;
|
|
175
|
-
networks: Readonly<EvmNetworkConfig[]>;
|
|
176
|
-
}
|
|
177
|
-
interface EvmWalletServiceState {
|
|
178
|
-
isSyncing?: boolean;
|
|
179
|
-
providerId?: string;
|
|
180
|
-
}
|
|
181
|
-
declare class EvmWalletService extends AbstractStore<EvmWalletServiceData, EvmWalletServiceState> {
|
|
182
|
-
protected readonly params?: Readonly<EvmWalletServiceCtorParams> | undefined;
|
|
183
|
-
readonly name = "EvmWalletService";
|
|
184
|
-
constructor(params?: Readonly<EvmWalletServiceCtorParams> | undefined);
|
|
185
|
-
/**
|
|
186
|
-
* Define current provider connector
|
|
187
|
-
* @returns {EthereumConnector|undefined}
|
|
188
|
-
*/
|
|
189
|
-
get connector(): EthereumConnector | undefined;
|
|
190
|
-
init(): Promise<void>;
|
|
191
|
-
/**
|
|
192
|
-
* Manually connect to the wallet
|
|
193
|
-
* @returns {Promise<void>}
|
|
194
|
-
*/
|
|
195
|
-
connect(networkIdOParams?: number | AddEthereumChainParams): Promise<void>;
|
|
196
|
-
/**
|
|
197
|
-
* Manually disconnect from the wallet
|
|
198
|
-
* @param {boolean} force
|
|
199
|
-
* @returns {Promise<void>}
|
|
200
|
-
*/
|
|
201
|
-
disconnect(force?: boolean): Promise<void>;
|
|
202
|
-
/**
|
|
203
|
-
* Add network to the current connected wallet
|
|
204
|
-
* @param {AddEthereumChainParams} chainParams
|
|
205
|
-
* @returns {Promise<void>}
|
|
206
|
-
*/
|
|
207
|
-
addNetwork(chainParams: AddEthereumChainParams): Promise<void>;
|
|
208
|
-
/**
|
|
209
|
-
* Switch network or add a new one if not exists in the current connected wallet
|
|
210
|
-
* @param {number|AddEthereumChainParams} chainIdOrParams
|
|
211
|
-
* @returns {Promise<void>}
|
|
212
|
-
*/
|
|
213
|
-
switchNetwork(chainIdOrParams: number | AddEthereumChainParams): Promise<void>;
|
|
214
|
-
/**
|
|
215
|
-
* Request to the wallet for watch asset
|
|
216
|
-
* @param {WatchAssetParameters} params
|
|
217
|
-
* @returns {Promise<true | undefined>}
|
|
218
|
-
*/
|
|
219
|
-
watchAsset(params: WatchAssetParameters): Promise<true | undefined>;
|
|
220
|
-
/**
|
|
221
|
-
* An independent RPC connection that allows you to receive data from the blockchain without being
|
|
222
|
-
* able to send transactions.
|
|
223
|
-
*
|
|
224
|
-
* This connection does not require connection permissions and wrapped on `Web3` interface.
|
|
225
|
-
* @returns {Web3|undefined}
|
|
226
|
-
*/
|
|
227
|
-
get connection(): Web3 | undefined;
|
|
228
|
-
/**
|
|
229
|
-
* Returns current Web3 Instance
|
|
230
|
-
*/
|
|
231
|
-
get provider(): Web3 | undefined;
|
|
232
|
-
/**
|
|
233
|
-
* Returns computed wallet balance value
|
|
234
|
-
* @returns {EvmWalletServiceData["balance"]}
|
|
235
|
-
*/
|
|
236
|
-
get balance(): EvmWalletServiceData['balance'];
|
|
237
|
-
/**
|
|
238
|
-
* List of the supported networks
|
|
239
|
-
* @returns {EvmWalletServiceData["networks"]}
|
|
240
|
-
*/
|
|
241
|
-
get networks(): EvmWalletServiceData['networks'];
|
|
242
|
-
/**
|
|
243
|
-
* Returns `true` if wallet contract is updating
|
|
244
|
-
* @returns {EvmWalletServiceState["isSyncing"]}
|
|
245
|
-
*/
|
|
246
|
-
get isSyncing(): EvmWalletServiceState['isSyncing'];
|
|
247
|
-
/**
|
|
248
|
-
A unique identifier of the connected wallet (provider)
|
|
249
|
-
* @returns {EvmWalletServiceState["providerId"]}
|
|
250
|
-
*/
|
|
251
|
-
get providerId(): EvmWalletServiceState['providerId'];
|
|
252
|
-
/**
|
|
253
|
-
* Returns computed wallet address value
|
|
254
|
-
* @returns {string|undefined}
|
|
255
|
-
*/
|
|
256
|
-
get address(): string | undefined;
|
|
257
|
-
/**
|
|
258
|
-
* Returns wallet native currency
|
|
259
|
-
* @returns {Readonly<NativeCurrency<string>>}
|
|
260
|
-
*/
|
|
261
|
-
get currency(): Readonly<NativeCurrency<string>>;
|
|
262
|
-
/**
|
|
263
|
-
* Returns `true` if provider is available.
|
|
264
|
-
* That means extension is installed and activated, else `false`
|
|
265
|
-
* @returns {boolean}
|
|
266
|
-
*/
|
|
267
|
-
get hasProvider(): boolean;
|
|
268
|
-
/**
|
|
269
|
-
* Returns `true` if wallet is connected
|
|
270
|
-
* @returns {boolean}
|
|
271
|
-
*/
|
|
272
|
-
get isConnected(): boolean;
|
|
273
|
-
/**
|
|
274
|
-
* Returns `true` if wallet is initialized and connected
|
|
275
|
-
* @returns {boolean}
|
|
276
|
-
*/
|
|
277
|
-
get isReady(): boolean;
|
|
278
|
-
/**
|
|
279
|
-
* Checks network support
|
|
280
|
-
* @returns {boolean}
|
|
281
|
-
*/
|
|
282
|
-
get isUnsupportedNetwork(): boolean;
|
|
283
|
-
/**
|
|
284
|
-
* Returns current network config
|
|
285
|
-
* @returns {Readonly<EvmNetworkConfig|undefined>}
|
|
286
|
-
*/
|
|
287
|
-
get network(): Readonly<EvmNetworkConfig | undefined>;
|
|
288
|
-
/**
|
|
289
|
-
Returns details about current connected provider
|
|
290
|
-
* @returns {EvmWalletProviderConfig["info"]|undefined}
|
|
291
|
-
*/
|
|
292
|
-
get providerInfo(): EvmWalletProviderConfig['info'] | undefined;
|
|
293
|
-
/**
|
|
294
|
-
* The list of the supported providers
|
|
295
|
-
* @returns {Readonly<EvmWalletProviderConfig[]|undefined>}
|
|
296
|
-
*/
|
|
297
|
-
get providers(): Readonly<EvmWalletProviderConfig[]>;
|
|
298
|
-
/**
|
|
299
|
-
* Returns current network chain id
|
|
300
|
-
* @returns {EthereumConnector["chainId"]}
|
|
301
|
-
*/
|
|
302
|
-
get chainId(): EthereumConnector['chainId'];
|
|
303
|
-
/**
|
|
304
|
-
* Returns `true` if wallet is connecting
|
|
305
|
-
* @returns {EthereumConnector["isConnecting"]}
|
|
306
|
-
*/
|
|
307
|
-
get isConnecting(): EthereumConnector['isConnecting'];
|
|
308
|
-
/**
|
|
309
|
-
* Returns `true` if wallet is disconnecting
|
|
310
|
-
* @returns {EthereumConnector["isDisconnecting"]}
|
|
311
|
-
*/
|
|
312
|
-
get isDisconnecting(): EthereumConnector['isDisconnecting'];
|
|
313
|
-
/**
|
|
314
|
-
* Returns `true` if wallet is initialized
|
|
315
|
-
* @returns {EthereumConnector["isInitialized"]}
|
|
316
|
-
*/
|
|
317
|
-
get isInitialized(): EthereumConnector['isInitialized'];
|
|
318
|
-
/**
|
|
319
|
-
* Returns `true` if wallet is initializing
|
|
320
|
-
* @returns {EthereumConnector["isInitializing"]}
|
|
321
|
-
*/
|
|
322
|
-
get isInitializing(): EthereumConnector['isInitializing'];
|
|
323
|
-
/**
|
|
324
|
-
* Sync account balance
|
|
325
|
-
*/
|
|
326
|
-
protected syncBalance(): Promise<void>;
|
|
327
|
-
/**
|
|
328
|
-
* Trying to resolve EVM Wallet connection
|
|
329
|
-
* @protected
|
|
330
|
-
*/
|
|
331
|
-
protected _init(): Promise<void>;
|
|
332
|
-
protected accountDisposer: IReactionDisposer | undefined;
|
|
333
|
-
protected networkDisposer: IReactionDisposer | undefined;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
declare function getEvmProviderPlatformLink(links: EvmProviderPlatformLinks): [EvmProviderAvailablePlatforms, string | undefined] | undefined;
|
|
337
|
-
|
|
338
|
-
declare function parseChainId(chainId: string | number): number;
|
|
339
|
-
|
|
340
|
-
declare function isRecentConnectionMeta(value: any): value is RecentConnectionMeta;
|
|
341
|
-
declare function storeRecentConnectionMeta(meta: RecentConnectionMeta | undefined, storageKey?: string): void;
|
|
342
|
-
declare function getRecentConnectionMeta(storageKey?: string): RecentConnectionMeta | undefined;
|
|
343
|
-
|
|
344
|
-
declare function toChainParams(network: EvmNetworkConfig): AddEthereumChainParams;
|
|
345
|
-
|
|
346
|
-
export { type AddEthereumChainParams, EIP6963Connector, type EIP6963ConnectorCtorParams, EIP6963Event, EVM_RECENT_CONNECTION, EthereumConnectionType, EthereumConnector, type EthereumConnectorCtorParams, type EthereumConnectorData, type EthereumConnectorState, type EvmNetworkConfig, type EvmProviderAvailablePlatforms, type EvmProviderPlatformLinks, type EvmWalletProviderConfig, EvmWalletService, type EvmWalletServiceCtorParams, type EvmWalletServiceData, type EvmWalletServiceState, MetaMask, type MetaMaskCtorParams, type RecentConnectionMeta, type SupportedProviders, WalletConnect, type WalletConnectCtorParams, type WalletConnectOptions, type WatchAssetParameters, getEvmProviderPlatformLink, getRecentConnectionMeta, isRecentConnectionMeta, parseChainId, storeRecentConnectionMeta, toChainParams };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|