@rango-dev/wallets-core 0.61.1-next.1 → 0.61.1-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/hub/provider/types.d.ts +5 -2
  2. package/dist/hub/provider/types.d.ts.map +1 -1
  3. package/dist/mod.js +1 -1
  4. package/dist/mod.js.map +2 -2
  5. package/dist/namespaces/common/mod.js +1 -1
  6. package/dist/namespaces/evm/mod.js +1 -1
  7. package/dist/namespaces/solana/mod.js +1 -1
  8. package/dist/namespaces/starknet/mod.js +1 -1
  9. package/dist/namespaces/tron/mod.js +1 -1
  10. package/dist/namespaces/utxo/mod.js +1 -1
  11. package/dist/utils/mod.js +1 -1
  12. package/dist/utils/mod.js.map +3 -3
  13. package/dist/utils/versions.d.ts +4 -8
  14. package/dist/utils/versions.d.ts.map +1 -1
  15. package/package.json +3 -8
  16. package/readme.md +4 -1
  17. package/src/hub/provider/types.ts +5 -5
  18. package/src/mod.ts +1 -1
  19. package/src/utils/versions.test.ts +3 -2
  20. package/src/utils/versions.ts +4 -13
  21. package/dist/legacy/helpers.d.ts +0 -12
  22. package/dist/legacy/helpers.d.ts.map +0 -1
  23. package/dist/legacy/mod.d.ts +0 -8
  24. package/dist/legacy/mod.d.ts.map +0 -1
  25. package/dist/legacy/mod.js +0 -2
  26. package/dist/legacy/mod.js.map +0 -7
  27. package/dist/legacy/persistor.d.ts +0 -11
  28. package/dist/legacy/persistor.d.ts.map +0 -1
  29. package/dist/legacy/types.d.ts +0 -229
  30. package/dist/legacy/types.d.ts.map +0 -1
  31. package/dist/legacy/utils.d.ts +0 -8
  32. package/dist/legacy/utils.d.ts.map +0 -1
  33. package/dist/legacy/wallet.d.ts +0 -65
  34. package/dist/legacy/wallet.d.ts.map +0 -1
  35. package/legacy/package.json +0 -8
  36. package/src/legacy/helpers.ts +0 -75
  37. package/src/legacy/mod.ts +0 -44
  38. package/src/legacy/persistor.ts +0 -19
  39. package/src/legacy/types.ts +0 -274
  40. package/src/legacy/utils.ts +0 -20
  41. package/src/legacy/wallet.ts +0 -552
@@ -1,274 +0,0 @@
1
- import type { State as WalletState } from './wallet.js';
2
- import type { Namespace } from '../namespaces/common/mod.js';
3
- import type { BlockchainMeta, SignerFactory } from 'rango-types';
4
-
5
- export enum Networks {
6
- BTC = 'BTC',
7
- BSC = 'BSC',
8
- LTC = 'LTC',
9
- THORCHAIN = 'THOR',
10
- BCH = 'BCH',
11
- BINANCE = 'BNB',
12
- BLAST = 'BLAST',
13
- CELO = 'CELO',
14
- LINEA = 'LINEA',
15
- METIS = 'METIS',
16
- SONIC = 'SONIC',
17
- BERACHAIN = 'BERACHAIN',
18
- ZETA_CHAIN = 'ZETA_CHAIN',
19
- SCROLL = 'SCROLL',
20
- ZKSYNC = 'ZKSYNC',
21
- MONAD = 'MONAD',
22
- ETHEREUM = 'ETH',
23
- POLYGON = 'POLYGON',
24
- POLKADOT = '',
25
- TRON = 'TRON',
26
- DOGE = 'DOGE',
27
- HARMONY = 'HARMONY',
28
- AVAX_CCHAIN = 'AVAX_CCHAIN',
29
- FANTOM = 'FANTOM',
30
- MOONBEAM = 'MOONBEAM',
31
- ARBITRUM = 'ARBITRUM',
32
- BOBA = 'BOBA',
33
- OPTIMISM = 'OPTIMISM',
34
- FUSE = 'FUSE',
35
- CRONOS = 'CRONOS',
36
- SOLANA = 'SOLANA',
37
- MOONRIVER = 'MOONRIVER',
38
- GNOSIS = 'GNOSIS',
39
- MAYA = 'MAYA',
40
- STARKNET = 'STARKNET',
41
- STELLAR = 'STELLAR',
42
- TON = 'TON',
43
- BASE = 'BASE',
44
- SUI = 'SUI',
45
- XRPL = 'XRPL',
46
- ZCASH = 'ZCASH',
47
- HYPERLIQUID = 'HYPERLIQUID',
48
-
49
- // Using instead of null
50
- Unknown = 'Unkown',
51
- }
52
-
53
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
- type InstanceType = any;
55
-
56
- export type NamespaceData = {
57
- namespace: Namespace;
58
- derivationPath?: string;
59
- };
60
-
61
- export type WalletType = string;
62
- export type Network = string;
63
-
64
- export type InstallObjects = {
65
- CHROME?: string;
66
- FIREFOX?: string;
67
- EDGE?: string;
68
- BRAVE?: string;
69
- DEFAULT: string;
70
- };
71
-
72
- export type NamespaceMeta = {
73
- label: string;
74
- /**
75
- * By using a matched `blockchain.name` (in meta) and `id`, we show logo in Namespace modal
76
- * e.g. ETH
77
- */
78
- id: string;
79
- value: Namespace;
80
- unsupported?: boolean;
81
- isChainSupported: (chainId: string) => boolean;
82
- };
83
-
84
- interface NeedsNamespace {
85
- selection: 'single' | 'multiple';
86
- data: NamespaceMeta[];
87
- }
88
-
89
- interface NeedsDerivationPath {
90
- data: {
91
- id: string;
92
- label: string;
93
- namespace: Namespace;
94
- generateDerivationPath: (index: string) => string;
95
- }[];
96
- }
97
-
98
- export type WalletInfo = {
99
- name: string;
100
- img: string;
101
- installLink: InstallObjects | string;
102
- /**
103
- * @deprecated we don't use this value anymore.
104
- */
105
- color: string;
106
- supportedChains: BlockchainMeta[];
107
- showOnMobile?: boolean;
108
- isContractWallet?: boolean;
109
- mobileWallet?: boolean;
110
-
111
- needsDerivationPath?: NeedsDerivationPath;
112
- needsNamespace?: NeedsNamespace;
113
- };
114
-
115
- export type State = {
116
- [key: string]: WalletState | undefined;
117
- };
118
-
119
- export type ConnectResult = {
120
- accounts: string[] | null;
121
- network: Network | null;
122
- provider: InstanceType;
123
- };
124
-
125
- export type Providers = { [type in WalletType]?: InstanceType };
126
-
127
- export enum Events {
128
- CONNECTED = 'connected',
129
- CONNECTING = 'connecting',
130
- REACHABLE = 'reachable',
131
- INSTALLED = 'installed',
132
- ACCOUNTS = 'accounts',
133
- NETWORK = 'network',
134
- // Hub only events
135
- NAMESPACE_DISCONNECTED = 'namespace_disconnected',
136
-
137
- PROVIDER_DISCONNECTED = 'provider_disconnected',
138
- }
139
-
140
- export type ProviderConnectResult = {
141
- accounts: string[];
142
- chainId: string;
143
- derivationPath?: string;
144
- };
145
-
146
- export type GetInstanceOptions = {
147
- network?: Network;
148
- currentProvider: InstanceType;
149
- meta: BlockchainMeta[];
150
- getState: () => WalletState;
151
- /**
152
- * We always get the instance once and reuse it whenever we needs. By using this option
153
- * We can force the library to get a new instance and replace it with the old one.
154
- *
155
- * Originally, we used this option for wallet connect 1 and its switching network challenge.
156
- */
157
- force?: boolean;
158
- updateChainId: (chainId: number | string) => void;
159
- };
160
-
161
- export type GetInstance =
162
- | (() => InstanceType)
163
- | ((options: GetInstanceOptions) => Promise<InstanceType>);
164
-
165
- export type TryGetInstance =
166
- | (() => InstanceType)
167
- | ((
168
- options: Pick<GetInstanceOptions, 'force' | 'network'>
169
- ) => Promise<InstanceType>);
170
-
171
- export type Connect = (options: {
172
- instance: InstanceType;
173
- network?: Network;
174
- meta: BlockchainMeta[];
175
- namespaces?: NamespaceData[];
176
- }) => Promise<ProviderConnectResult | ProviderConnectResult[]>;
177
-
178
- export type Disconnect = (options: {
179
- instance: InstanceType;
180
- destroyInstance: () => void;
181
- }) => Promise<void>;
182
-
183
- type CleanupSubscribe = () => void;
184
-
185
- export type Subscribe = (options: {
186
- instance: InstanceType;
187
- state: WalletState;
188
- meta: BlockchainMeta[];
189
- updateChainId: (chainId: string) => void;
190
- updateAccounts: (accounts: string[], chainId?: string) => void;
191
- connect: (network?: Network) => void;
192
- disconnect: () => void;
193
- }) => CleanupSubscribe | void;
194
-
195
- export type SwitchNetwork = (options: {
196
- instance: InstanceType;
197
- network: Network;
198
- meta: BlockchainMeta[];
199
- newInstance?: TryGetInstance;
200
- getState?: () => WalletState;
201
- updateChainId: (chainId: string) => void;
202
- }) => Promise<void>;
203
-
204
- export type Suggest = (options: {
205
- instance: InstanceType;
206
- network: Network;
207
- meta: BlockchainMeta[];
208
- }) => Promise<void>;
209
-
210
- export type CanSwitchNetwork = (options: {
211
- network: Network;
212
- meta: BlockchainMeta[];
213
- provider: InstanceType;
214
- }) => boolean;
215
-
216
- export type CanEagerConnect = (options: {
217
- instance: InstanceType;
218
- meta: BlockchainMeta[];
219
- }) => Promise<boolean>;
220
-
221
- export type EagerConnectResult<I = unknown> = {
222
- accounts: string[] | null;
223
- network: string | null;
224
- provider: I | null;
225
- };
226
-
227
- export interface WalletActions {
228
- connect: Connect;
229
- getInstance: InstanceType;
230
- disconnect?: Disconnect;
231
- subscribe?: Subscribe;
232
- // unsubscribe, // coupled to subscribe.
233
-
234
- // Optional, but should be provided at the same time.
235
- suggest?: Suggest;
236
- switchNetwork?: SwitchNetwork;
237
- getSigners: (provider: InstanceType) => Promise<SignerFactory>;
238
- canSwitchNetworkTo?: CanSwitchNetwork;
239
- canEagerConnect?: CanEagerConnect;
240
- getWalletInfo(allBlockChains: BlockchainMeta[]): WalletInfo;
241
- }
242
-
243
- export interface WalletConfig {
244
- type: WalletType;
245
- defaultNetwork?: Network;
246
- checkInstallation?: boolean;
247
- isAsyncInstance?: boolean;
248
- isAsyncSwitchNetwork?: boolean;
249
- }
250
-
251
- export type WalletProviders = Map<
252
- WalletType,
253
- {
254
- actions: WalletActions;
255
- config: WalletConfig;
256
- }
257
- >;
258
-
259
- export type ProviderInterface = { config: WalletConfig } & WalletActions;
260
-
261
- // it comes from wallets.ts and `connect`
262
- type NetworkTypeFromLegacyConnect = Network | undefined;
263
-
264
- export type NamespaceInputForConnect<T extends Namespace = Namespace> = {
265
- /**
266
- * By default, you should specify namespace (e.g. evm).
267
- */
268
- namespace: T;
269
- /**
270
- * In some cases, we need to connect a specific network on a namespace. e.g. Polygon on EVM.
271
- */
272
- network: NetworkTypeFromLegacyConnect;
273
- derivationPath?: string;
274
- };
@@ -1,20 +0,0 @@
1
- import type { NamespaceInputForConnect } from './types.js';
2
-
3
- export async function eagerConnectHandler<R = unknown>(params: {
4
- canEagerConnect: () => Promise<boolean>;
5
- connectHandler: () => Promise<R>;
6
- providerName: string;
7
- }) {
8
- // Check if we can eagerly connect to the wallet
9
- if (await params.canEagerConnect()) {
10
- // Connect to wallet as usual
11
- return await params.connectHandler();
12
- }
13
- throw new Error(`can't restore connection for ${params.providerName}.`);
14
- }
15
-
16
- export function isEvmNamespace(
17
- namespace: NamespaceInputForConnect
18
- ): namespace is NamespaceInputForConnect<'EVM'> {
19
- return namespace.namespace === 'EVM';
20
- }