@rango-dev/wallets-react 0.0.0-experimental-936229e8-20251208
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/CHANGELOG.md +265 -0
- package/dist/helpers/index.d.ts +2 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +2 -0
- package/dist/helpers/index.js.map +7 -0
- package/dist/hub/autoConnect.d.ts +11 -0
- package/dist/hub/autoConnect.d.ts.map +1 -0
- package/dist/hub/constants.d.ts +3 -0
- package/dist/hub/constants.d.ts.map +1 -0
- package/dist/hub/helpers.d.ts +33 -0
- package/dist/hub/helpers.d.ts.map +1 -0
- package/dist/hub/lastConnectedWallets.d.ts +22 -0
- package/dist/hub/lastConnectedWallets.d.ts.map +1 -0
- package/dist/hub/mod.d.ts +3 -0
- package/dist/hub/mod.d.ts.map +1 -0
- package/dist/hub/types.d.ts +4 -0
- package/dist/hub/types.d.ts.map +1 -0
- package/dist/hub/useHubAdapter.d.ts +11 -0
- package/dist/hub/useHubAdapter.d.ts.map +1 -0
- package/dist/hub/useHubRefs.d.ts +7 -0
- package/dist/hub/useHubRefs.d.ts.map +1 -0
- package/dist/hub/utils.d.ts +52 -0
- package/dist/hub/utils.d.ts.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +7 -0
- package/dist/legacy/autoConnect.d.ts +8 -0
- package/dist/legacy/autoConnect.d.ts.map +1 -0
- package/dist/legacy/context.d.ts +3 -0
- package/dist/legacy/context.d.ts.map +1 -0
- package/dist/legacy/helpers.d.ts +23 -0
- package/dist/legacy/helpers.d.ts.map +1 -0
- package/dist/legacy/hooks.d.ts +10 -0
- package/dist/legacy/hooks.d.ts.map +1 -0
- package/dist/legacy/mod.d.ts +5 -0
- package/dist/legacy/mod.d.ts.map +1 -0
- package/dist/legacy/types.d.ts +143 -0
- package/dist/legacy/types.d.ts.map +1 -0
- package/dist/legacy/useAutoConnect.d.ts +8 -0
- package/dist/legacy/useAutoConnect.d.ts.map +1 -0
- package/dist/legacy/useLegacyProviders.d.ts +7 -0
- package/dist/legacy/useLegacyProviders.d.ts.map +1 -0
- package/dist/legacy/utils.d.ts +3 -0
- package/dist/legacy/utils.d.ts.map +1 -0
- package/dist/provider.d.ts +5 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/test-utils/env.d.ts +7 -0
- package/dist/test-utils/env.d.ts.map +1 -0
- package/dist/test-utils/fixtures.d.ts +14 -0
- package/dist/test-utils/fixtures.d.ts.map +1 -0
- package/dist/useProviders.d.ts +4 -0
- package/dist/useProviders.d.ts.map +1 -0
- package/dist/wallets-react.build.json +1 -0
- package/helpers/package.json +8 -0
- package/package.json +50 -0
- package/readme.md +3 -0
- package/src/helpers/index.ts +1 -0
- package/src/hub/autoConnect.ts +276 -0
- package/src/hub/constants.ts +2 -0
- package/src/hub/helpers.ts +179 -0
- package/src/hub/lastConnectedWallets.ts +166 -0
- package/src/hub/mod.ts +6 -0
- package/src/hub/types.ts +12 -0
- package/src/hub/useHubAdapter.ts +516 -0
- package/src/hub/useHubRefs.ts +50 -0
- package/src/hub/utils.ts +393 -0
- package/src/index.ts +4 -0
- package/src/legacy/autoConnect.ts +66 -0
- package/src/legacy/context.ts +39 -0
- package/src/legacy/helpers.ts +183 -0
- package/src/legacy/hooks.ts +54 -0
- package/src/legacy/mod.ts +13 -0
- package/src/legacy/types.ts +195 -0
- package/src/legacy/useAutoConnect.ts +23 -0
- package/src/legacy/useLegacyProviders.ts +241 -0
- package/src/legacy/utils.ts +7 -0
- package/src/provider.tsx +18 -0
- package/src/test-utils/env.ts +10 -0
- package/src/test-utils/fixtures.ts +238 -0
- package/src/useProviders.ts +120 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { Provider, ProviderMetadata, VersionedProviders } from '@rango-dev/wallets-core';
|
|
2
|
+
import type { LegacyNamespaceInputForConnect, LegacyProviderInterface, LegacyNetwork as Network, LegacyEventHandler as WalletEventHandler, LegacyWalletInfo as WalletInfo, LegacyState as WalletState, LegacyWalletType as WalletType } from '@rango-dev/wallets-core/legacy';
|
|
3
|
+
import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
|
|
4
|
+
import type { NamespaceData } from '@rango-dev/wallets-core/store';
|
|
5
|
+
import type { BlockchainMeta, SignerFactory } from 'rango-types';
|
|
6
|
+
import type { PropsWithChildren } from 'react';
|
|
7
|
+
import { LegacyEvents as Events } from '@rango-dev/wallets-core/legacy';
|
|
8
|
+
type InstanceType = any;
|
|
9
|
+
export type State = {
|
|
10
|
+
[key: string]: WalletState | undefined;
|
|
11
|
+
};
|
|
12
|
+
export type ConnectResult = {
|
|
13
|
+
accounts: string[] | null;
|
|
14
|
+
network: Network | null;
|
|
15
|
+
provider: InstanceType;
|
|
16
|
+
};
|
|
17
|
+
export type Providers = {
|
|
18
|
+
[type in WalletType]?: InstanceType;
|
|
19
|
+
};
|
|
20
|
+
export type ExtendedWalletInfo = WalletInfo & {
|
|
21
|
+
properties?: ProviderMetadata['properties'];
|
|
22
|
+
isHub?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type ProviderContext = {
|
|
25
|
+
connect(type: WalletType, namespaces?: LegacyNamespaceInputForConnect[]): Promise<ConnectResult[]>;
|
|
26
|
+
disconnect(type: WalletType, namespaces?: Namespace[]): Promise<void>;
|
|
27
|
+
disconnectAll(): Promise<PromiseSettledResult<any>[]>;
|
|
28
|
+
state(type: WalletType): WalletState & {
|
|
29
|
+
namespaces?: Map<Namespace, NamespaceData>;
|
|
30
|
+
};
|
|
31
|
+
canSwitchNetworkTo(type: WalletType, network: Network, namespace?: LegacyNamespaceInputForConnect): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* `Provider` in legacy terms means injected instances by wallets into window (e.g. window.ethereum)
|
|
34
|
+
* that can be retrieved by `getInstance`.
|
|
35
|
+
*
|
|
36
|
+
* Note 1: Providers are lazy evaluated, which means you need to call `connect` (or `state`) first, then the value will be shown in object.
|
|
37
|
+
* before doing that, it's a key (wallet name or we call it `type` to be more specific) with null value. (e.g. {metamask: null})
|
|
38
|
+
*/
|
|
39
|
+
providers(): Providers;
|
|
40
|
+
getSigners(type: WalletType): Promise<SignerFactory>;
|
|
41
|
+
getWalletInfo(type: WalletType): ExtendedWalletInfo;
|
|
42
|
+
suggestAndConnect(type: WalletType, network: Network): Promise<ConnectResult>;
|
|
43
|
+
hubProvider(type: WalletType): Provider;
|
|
44
|
+
};
|
|
45
|
+
export type ProviderProps = PropsWithChildren<{
|
|
46
|
+
onUpdateState?: WalletEventHandler;
|
|
47
|
+
allBlockChains?: BlockchainMeta[];
|
|
48
|
+
autoConnect?: boolean;
|
|
49
|
+
providers: VersionedProviders[];
|
|
50
|
+
configs?: {
|
|
51
|
+
wallets?: (WalletType | LegacyProviderInterface | Provider)[];
|
|
52
|
+
};
|
|
53
|
+
}>;
|
|
54
|
+
export { Events };
|
|
55
|
+
export type ProviderConnectResult = {
|
|
56
|
+
accounts: string[];
|
|
57
|
+
chainId: string;
|
|
58
|
+
derivationPath?: string;
|
|
59
|
+
};
|
|
60
|
+
export type GetInstanceOptions = {
|
|
61
|
+
network?: Network;
|
|
62
|
+
currentProvider: InstanceType;
|
|
63
|
+
meta: BlockchainMeta[];
|
|
64
|
+
getState: () => WalletState;
|
|
65
|
+
/**
|
|
66
|
+
* We always get the instance once and reuse it whenever we needs. By using this option
|
|
67
|
+
* We can force the library to get a new instance and replace it with the old one.
|
|
68
|
+
*
|
|
69
|
+
* Originally, we used this option for wallet connect 1 and its switching network challenge.
|
|
70
|
+
*/
|
|
71
|
+
force?: boolean;
|
|
72
|
+
updateChainId: (chainId: number | string) => void;
|
|
73
|
+
};
|
|
74
|
+
export type GetInstance = (() => InstanceType) | ((options: GetInstanceOptions) => Promise<InstanceType>);
|
|
75
|
+
export type TryGetInstance = (() => InstanceType) | ((options: Pick<GetInstanceOptions, 'force' | 'network'>) => Promise<InstanceType>);
|
|
76
|
+
export type Connect = (options: {
|
|
77
|
+
instance: InstanceType;
|
|
78
|
+
network?: Network;
|
|
79
|
+
meta: BlockchainMeta[];
|
|
80
|
+
}) => Promise<ProviderConnectResult | ProviderConnectResult[]>;
|
|
81
|
+
export type Disconnect = (options: {
|
|
82
|
+
instance: InstanceType;
|
|
83
|
+
destroyInstance: () => void;
|
|
84
|
+
}) => Promise<void>;
|
|
85
|
+
type CleanupSubscribe = () => void;
|
|
86
|
+
export type Subscribe = (options: {
|
|
87
|
+
instance: InstanceType;
|
|
88
|
+
state: WalletState;
|
|
89
|
+
meta: BlockchainMeta[];
|
|
90
|
+
updateChainId: (chainId: string) => void;
|
|
91
|
+
updateAccounts: (accounts: string[], chainId?: string) => void;
|
|
92
|
+
connect: (network?: Network) => void;
|
|
93
|
+
disconnect: () => void;
|
|
94
|
+
}) => CleanupSubscribe | void;
|
|
95
|
+
export type SwitchNetwork = (options: {
|
|
96
|
+
instance: InstanceType;
|
|
97
|
+
network: Network;
|
|
98
|
+
meta: BlockchainMeta[];
|
|
99
|
+
newInstance?: TryGetInstance;
|
|
100
|
+
getState?: () => WalletState;
|
|
101
|
+
updateChainId: (chainId: string) => void;
|
|
102
|
+
}) => Promise<void>;
|
|
103
|
+
export type Suggest = (options: {
|
|
104
|
+
instance: InstanceType;
|
|
105
|
+
network: Network;
|
|
106
|
+
meta: BlockchainMeta[];
|
|
107
|
+
}) => Promise<void>;
|
|
108
|
+
export type CanSwitchNetwork = (options: {
|
|
109
|
+
network: Network;
|
|
110
|
+
meta: BlockchainMeta[];
|
|
111
|
+
provider: InstanceType;
|
|
112
|
+
}) => boolean;
|
|
113
|
+
export type CanEagerConnect = (options: {
|
|
114
|
+
instance: InstanceType;
|
|
115
|
+
meta: BlockchainMeta[];
|
|
116
|
+
}) => Promise<boolean>;
|
|
117
|
+
export interface WalletActions {
|
|
118
|
+
connect: Connect;
|
|
119
|
+
getInstance: InstanceType;
|
|
120
|
+
disconnect?: Disconnect;
|
|
121
|
+
subscribe?: Subscribe;
|
|
122
|
+
suggest?: Suggest;
|
|
123
|
+
switchNetwork?: SwitchNetwork;
|
|
124
|
+
getSigners: (provider: InstanceType) => Promise<SignerFactory>;
|
|
125
|
+
canSwitchNetworkTo?: CanSwitchNetwork;
|
|
126
|
+
canEagerConnect?: CanEagerConnect;
|
|
127
|
+
getWalletInfo(allBlockChains: BlockchainMeta[]): WalletInfo;
|
|
128
|
+
}
|
|
129
|
+
export interface WalletConfig {
|
|
130
|
+
type: WalletType;
|
|
131
|
+
defaultNetwork?: Network;
|
|
132
|
+
checkInstallation?: boolean;
|
|
133
|
+
isAsyncInstance?: boolean;
|
|
134
|
+
isAsyncSwitchNetwork?: boolean;
|
|
135
|
+
}
|
|
136
|
+
export type WalletProviders = Map<WalletType, {
|
|
137
|
+
actions: WalletActions;
|
|
138
|
+
config: WalletConfig;
|
|
139
|
+
}>;
|
|
140
|
+
export type ProviderInterface = {
|
|
141
|
+
config: WalletConfig;
|
|
142
|
+
} & WalletActions;
|
|
143
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/legacy/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,8BAA8B,EAC9B,uBAAuB,EACvB,aAAa,IAAI,OAAO,EACxB,kBAAkB,IAAI,kBAAkB,EACxC,gBAAgB,IAAI,UAAU,EAC9B,WAAW,IAAI,WAAW,EAC1B,gBAAgB,IAAI,UAAU,EAC/B,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC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YAAY;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,MAAM,eAAe,GAAG,GAAG,CAC/B,UAAU,EACV;IACE,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,EAAE,YAAY,CAAC;CACtB,CACF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GAAG,aAAa,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ProviderProps } from './types.js';
|
|
2
|
+
export declare function useAutoConnect(props: Pick<ProviderProps, 'allBlockChains' | 'autoConnect'> & {
|
|
3
|
+
/**
|
|
4
|
+
* A function to run autoConnect on instances
|
|
5
|
+
*/
|
|
6
|
+
autoConnectHandler: () => void;
|
|
7
|
+
}): void;
|
|
8
|
+
//# sourceMappingURL=useAutoConnect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAutoConnect.d.ts","sourceRoot":"","sources":["../../src/legacy/useAutoConnect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAMhD,wBAAgB,cAAc,CAC5B,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,gBAAgB,GAAG,aAAa,CAAC,GAAG;IAC7D;;OAEG;IACH,kBAAkB,EAAE,MAAM,IAAI,CAAC;CAChC,QAUF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ProviderContext, ProviderProps } from './types.js';
|
|
2
|
+
import type { LegacyProviderInterface } from '@rango-dev/wallets-core/legacy';
|
|
3
|
+
export type LegacyProviderProps = Omit<ProviderProps, 'providers'> & {
|
|
4
|
+
providers: LegacyProviderInterface[];
|
|
5
|
+
};
|
|
6
|
+
export declare function useLegacyProviders(props: LegacyProviderProps): ProviderContext;
|
|
7
|
+
//# sourceMappingURL=useLegacyProviders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLegacyProviders.d.ts","sourceRoot":"","sources":["../../src/legacy/useLegacyProviders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAuB9E,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,GAAG;IACnE,SAAS,EAAE,uBAAuB,EAAE,CAAC;CACtC,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,mBAAmB,GACzB,eAAe,CAkNjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/legacy/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,gBAAgB,GAAG,aAAa,CAAC,GAC3D,OAAO,CAET"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,qBAQrC;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detecting wether our code is running in a test environment or not.
|
|
3
|
+
*
|
|
4
|
+
* Note: This is only useful when HappyDOM or jsdom has been added to test runner.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isRunningInTestEnvironmentWithDom(): boolean;
|
|
7
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/test-utils/env.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,iCAAiC,IAAI,OAAO,CAE3D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LegacyProviderInterface } from '@rango-dev/wallets-core/legacy';
|
|
2
|
+
import type { BlockchainMeta, GenericSigner } from 'rango-types';
|
|
3
|
+
import type { EvmTransaction } from 'rango-types/mainApi';
|
|
4
|
+
export declare const legacyAddress = "0x000000000000000000000000000000000000dead";
|
|
5
|
+
export declare class MockEvmSigner implements GenericSigner<EvmTransaction> {
|
|
6
|
+
signMessage(_msg: string, _address: string, _chainId: string | null): Promise<string>;
|
|
7
|
+
signAndSendTx(_tx: EvmTransaction, _address: string, _chainId: string | null): Promise<{
|
|
8
|
+
hash: string;
|
|
9
|
+
response?: any;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
export declare const legacyProvider: LegacyProviderInterface;
|
|
13
|
+
export declare const blockchainsMeta: BlockchainMeta[];
|
|
14
|
+
//# sourceMappingURL=fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/test-utils/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAI1D,eAAO,MAAM,aAAa,+CAA+C,CAAC;AAE1E,qBAAa,aAAc,YAAW,aAAa,CAAC,cAAc,CAAC;IAC3D,WAAW,CACf,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GAAG,IAAI,GACtB,OAAO,CAAC,MAAM,CAAC;IAGZ,aAAa,CACjB,GAAG,EAAE,cAAc,EACnB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GAAG,IAAI,GACtB,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;CAK7C;AAED,eAAO,MAAM,cAAc,EAAE,uBA0C5B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,cAAc,EAsK3C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useProviders.d.ts","sourceRoot":"","sources":["../src/useProviders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EACf,aAAa,EAEd,MAAM,YAAY,CAAC;AAiBpB,iBAAS,YAAY,CAAC,KAAK,EAAE,aAAa,mBA+FzC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/hub/constants.ts":{"bytes":146,"imports":[],"format":"esm"},"src/hub/lastConnectedWallets.ts":{"bytes":5519,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"src/hub/constants.ts","kind":"import-statement","original":"./constants.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/helpers.ts":{"bytes":4652,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"src/hub/constants.ts","kind":"import-statement","original":"../hub/constants.js"},{"path":"src/hub/lastConnectedWallets.ts","kind":"import-statement","original":"../hub/lastConnectedWallets.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/context.ts":{"bytes":960,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/autoConnect.ts":{"bytes":2046,"imports":[{"path":"src/hub/lastConnectedWallets.ts","kind":"import-statement","original":"../hub/lastConnectedWallets.js"},{"path":"src/legacy/mod.ts","kind":"import-statement","original":"./mod.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/hooks.ts":{"bytes":1545,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/context.ts","kind":"import-statement","original":"./context.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/utils.ts":{"bytes":230,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/useAutoConnect.ts":{"bytes":628,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/useLegacyProviders.ts":{"bytes":7510,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/autoConnect.ts","kind":"import-statement","original":"./autoConnect.js"},{"path":"src/legacy/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/legacy/hooks.ts","kind":"import-statement","original":"./hooks.js"},{"path":"src/legacy/useAutoConnect.ts","kind":"import-statement","original":"./useAutoConnect.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/mod.ts":{"bytes":321,"imports":[{"path":"src/hub/constants.ts","kind":"import-statement","original":"../hub/constants.js"},{"path":"src/legacy/context.ts","kind":"import-statement","original":"./context.js"},{"path":"src/legacy/useLegacyProviders.ts","kind":"import-statement","original":"./useLegacyProviders.js"}],"format":"esm"},"src/hub/helpers.ts":{"bytes":5339,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/cosmos","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/tron","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/utxo","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"ts-results","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/utils.ts":{"bytes":11267,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/legacy/mod.ts","kind":"import-statement","original":"../legacy/mod.js"},{"path":"src/hub/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/hub/lastConnectedWallets.ts","kind":"import-statement","original":"./lastConnectedWallets.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/autoConnect.ts":{"bytes":9242,"imports":[{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"ts-results","kind":"import-statement","external":true},{"path":"src/legacy/mod.ts","kind":"import-statement","original":"../legacy/mod.js"},{"path":"src/hub/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/hub/lastConnectedWallets.ts","kind":"import-statement","original":"./lastConnectedWallets.js"},{"path":"src/hub/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/useHubRefs.ts":{"bytes":1271,"imports":[{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/hub/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/useHubAdapter.ts":{"bytes":17100,"imports":[{"path":"@rango-dev/wallets-core/namespaces/evm","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"ts-results","kind":"import-statement","external":true},{"path":"src/legacy/mod.ts","kind":"import-statement","original":"../legacy/mod.js"},{"path":"src/legacy/useAutoConnect.ts","kind":"import-statement","original":"../legacy/useAutoConnect.js"},{"path":"src/hub/autoConnect.ts","kind":"import-statement","original":"./autoConnect.js"},{"path":"src/hub/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/hub/lastConnectedWallets.ts","kind":"import-statement","original":"./lastConnectedWallets.js"},{"path":"src/hub/useHubRefs.ts","kind":"import-statement","original":"./useHubRefs.js"},{"path":"src/hub/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/mod.ts":{"bytes":162,"imports":[{"path":"src/hub/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"src/hub/useHubAdapter.ts","kind":"import-statement","original":"./useHubAdapter.js"}],"format":"esm"},"src/useProviders.ts":{"bytes":3661,"imports":[{"path":"src/hub/mod.ts","kind":"import-statement","original":"./hub/mod.js"},{"path":"src/legacy/mod.ts","kind":"import-statement","original":"./legacy/mod.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/provider.tsx":{"bytes":405,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/context.ts","kind":"import-statement","original":"./legacy/context.js"},{"path":"src/useProviders.ts","kind":"import-statement","original":"./useProviders.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/types.ts":{"bytes":5763,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":173,"imports":[{"path":"src/legacy/helpers.ts","kind":"import-statement","original":"./legacy/helpers.js"},{"path":"src/provider.tsx","kind":"import-statement","original":"./provider.js"},{"path":"src/legacy/hooks.ts","kind":"import-statement","original":"./legacy/hooks.js"},{"path":"src/legacy/types.ts","kind":"import-statement","original":"./legacy/types.js"}],"format":"esm"},"src/helpers/index.ts":{"bytes":55,"imports":[{"path":"src/hub/mod.ts","kind":"import-statement","original":"../hub/mod.js"}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":115562},"dist/index.js":{"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/cosmos","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/tron","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/utxo","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"ts-results","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/evm","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"ts-results","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"ts-results","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true}],"exports":["Events","Provider","availableWallets","checkWalletProviders","choose","clearPersistance","connectedWallets","defaultWalletState","isAsync","makeEventHandler","needsCheckInstallation","stateReducer","tryPersistWallet","tryRemoveWalletFromPersistance","useWallets"],"entryPoint":"src/index.ts","inputs":{"src/legacy/helpers.ts":{"bytesInOutput":1407},"src/hub/constants.ts":{"bytesInOutput":65},"src/hub/lastConnectedWallets.ts":{"bytesInOutput":1311},"src/index.ts":{"bytesInOutput":0},"src/provider.tsx":{"bytesInOutput":133},"src/legacy/context.ts":{"bytesInOutput":465},"src/hub/utils.ts":{"bytesInOutput":3150},"src/legacy/mod.ts":{"bytesInOutput":0},"src/legacy/useLegacyProviders.ts":{"bytesInOutput":2214},"src/legacy/autoConnect.ts":{"bytesInOutput":395},"src/legacy/hooks.ts":{"bytesInOutput":460},"src/legacy/useAutoConnect.ts":{"bytesInOutput":197},"src/legacy/utils.ts":{"bytesInOutput":94},"src/hub/helpers.ts":{"bytesInOutput":1994},"src/hub/mod.ts":{"bytesInOutput":0},"src/hub/useHubAdapter.ts":{"bytesInOutput":6023},"src/hub/autoConnect.ts":{"bytesInOutput":2524},"src/hub/useHubRefs.ts":{"bytesInOutput":497},"src/useProviders.ts":{"bytesInOutput":1026},"src/legacy/types.ts":{"bytesInOutput":63}},"bytes":22460},"dist/helpers/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":73180},"dist/helpers/index.js":{"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/cosmos","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/tron","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/utxo","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"ts-results","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/evm","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"ts-results","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"ts-results","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"exports":["getAllLegacyProviders"],"entryPoint":"src/helpers/index.ts","inputs":{"src/hub/utils.ts":{"bytesInOutput":421},"src/hub/constants.ts":{"bytesInOutput":65},"src/legacy/mod.ts":{"bytesInOutput":0},"src/legacy/context.ts":{"bytesInOutput":461},"src/legacy/useLegacyProviders.ts":{"bytesInOutput":52},"src/hub/lastConnectedWallets.ts":{"bytesInOutput":1311},"src/legacy/helpers.ts":{"bytesInOutput":59},"src/legacy/hooks.ts":{"bytesInOutput":109},"src/legacy/useAutoConnect.ts":{"bytesInOutput":48},"src/hub/helpers.ts":{"bytesInOutput":482},"src/hub/mod.ts":{"bytesInOutput":0},"src/hub/useHubAdapter.ts":{"bytesInOutput":256},"src/hub/autoConnect.ts":{"bytesInOutput":225},"src/hub/useHubRefs.ts":{"bytesInOutput":97},"src/helpers/index.ts":{"bytesInOutput":0}},"bytes":3735}}}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rango-dev/wallets-react",
|
|
3
|
+
"version": "0.0.0-experimental-936229e8-20251208",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"source": "./src/index.ts",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./helpers": {
|
|
14
|
+
"types": "./dist/helpers/index.d.ts",
|
|
15
|
+
"default": "./dist/helpers/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"src",
|
|
21
|
+
"helpers"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "node ../../scripts/build/command.mjs --path wallets/react --inputs src/index.ts,src/helpers/index.ts",
|
|
25
|
+
"ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json",
|
|
26
|
+
"clean": "rimraf dist",
|
|
27
|
+
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
|
|
28
|
+
"lint": "eslint \"**/*.{ts,tsx}\"",
|
|
29
|
+
"test": "vitest",
|
|
30
|
+
"coverage": "vitest run --coverage"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@types/react": "^17.0.0 || ^18.0.0",
|
|
34
|
+
"react": "^17.0.0 || ^18.0.0",
|
|
35
|
+
"react-dom": "^17.0.0 || ^18.0.0"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@rango-dev/wallets-core": "^0.0.0-experimental-936229e8-20251208",
|
|
39
|
+
"@rango-dev/wallets-shared": "^0.0.0-experimental-936229e8-20251208",
|
|
40
|
+
"rango-types": "^0.1.89",
|
|
41
|
+
"ts-results": "^3.3.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/react": "^18.0.25",
|
|
45
|
+
"@types/react-dom": "^18.0.25"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getAllLegacyProviders } from '../hub/mod.js';
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import type { AllProxiedNamespaces } from './types.js';
|
|
2
|
+
import type { UseAdapterParams } from './useHubAdapter.js';
|
|
3
|
+
import type { Hub } from '@rango-dev/wallets-core';
|
|
4
|
+
import type {
|
|
5
|
+
LegacyNamespaceInputForConnect,
|
|
6
|
+
LegacyProviderInterface,
|
|
7
|
+
} from '@rango-dev/wallets-core/legacy';
|
|
8
|
+
import type {
|
|
9
|
+
Accounts,
|
|
10
|
+
AccountsWithActiveChain,
|
|
11
|
+
Namespace,
|
|
12
|
+
} from '@rango-dev/wallets-core/namespaces/common';
|
|
13
|
+
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
14
|
+
|
|
15
|
+
import { Provider } from '@rango-dev/wallets-core';
|
|
16
|
+
import { legacyIsEvmNamespace } from '@rango-dev/wallets-core/legacy';
|
|
17
|
+
import { cosmosBlockchains } from 'rango-types';
|
|
18
|
+
import { Result } from 'ts-results';
|
|
19
|
+
|
|
20
|
+
import { HUB_LAST_CONNECTED_WALLETS } from '../legacy/mod.js';
|
|
21
|
+
|
|
22
|
+
import { runSequentiallyWithoutFailure } from './helpers.js';
|
|
23
|
+
import { LastConnectedWalletsFromStorage } from './lastConnectedWallets.js';
|
|
24
|
+
import {
|
|
25
|
+
convertNamespaceNetworkToEvmChainId,
|
|
26
|
+
isCosmosNamespace,
|
|
27
|
+
isEvmNamespace,
|
|
28
|
+
} from './utils.js';
|
|
29
|
+
|
|
30
|
+
// Getting connected wallets from storage
|
|
31
|
+
const lastConnectedWalletsFromStorage = new LastConnectedWalletsFromStorage(
|
|
32
|
+
HUB_LAST_CONNECTED_WALLETS
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Run `.connect` action on some selected namespaces (passed as param) for a provider.
|
|
37
|
+
*/
|
|
38
|
+
async function eagerConnect(
|
|
39
|
+
type: string,
|
|
40
|
+
namespacesInput: LegacyNamespaceInputForConnect[] | undefined,
|
|
41
|
+
params: {
|
|
42
|
+
getHub: () => Hub;
|
|
43
|
+
allBlockChains: UseAdapterParams['allBlockChains'];
|
|
44
|
+
}
|
|
45
|
+
) {
|
|
46
|
+
const { getHub, allBlockChains } = params;
|
|
47
|
+
const wallet = getHub().get(type);
|
|
48
|
+
if (!wallet) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`You should add ${type} to provider first then call 'connect'.`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!namespacesInput) {
|
|
55
|
+
throw new Error('Passing namespace to `connect` is required. ');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const targetNamespaces: [
|
|
59
|
+
LegacyNamespaceInputForConnect,
|
|
60
|
+
AllProxiedNamespaces
|
|
61
|
+
][] = [];
|
|
62
|
+
namespacesInput.forEach((namespaceInput) => {
|
|
63
|
+
const targetNamespace: Namespace = namespaceInput.namespace;
|
|
64
|
+
|
|
65
|
+
const result = wallet.findByNamespace(targetNamespace);
|
|
66
|
+
|
|
67
|
+
if (!result) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
`We couldn't find any provider matched with your request namespace. (requested namespace: ${namespaceInput.namespace})`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
targetNamespaces.push([namespaceInput, result]);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const connectNamespacesPromises = targetNamespaces.map(
|
|
77
|
+
([info, namespace]) => {
|
|
78
|
+
const evmChain = legacyIsEvmNamespace(info)
|
|
79
|
+
? convertNamespaceNetworkToEvmChainId(info, allBlockChains || [])
|
|
80
|
+
: undefined;
|
|
81
|
+
const chain = evmChain || info.network;
|
|
82
|
+
|
|
83
|
+
return async () => {
|
|
84
|
+
let connectNamespacePromise: () => Promise<
|
|
85
|
+
Accounts | AccountsWithActiveChain
|
|
86
|
+
>;
|
|
87
|
+
if (isEvmNamespace(namespace)) {
|
|
88
|
+
connectNamespacePromise = async () => namespace.connect(chain);
|
|
89
|
+
} else if (isCosmosNamespace(namespace)) {
|
|
90
|
+
const cosmosBlockChains = cosmosBlockchains(
|
|
91
|
+
params.allBlockChains || []
|
|
92
|
+
).filter((chain) => !!chain.chainId);
|
|
93
|
+
connectNamespacePromise = async () => {
|
|
94
|
+
return namespace.connect({
|
|
95
|
+
chainIds: cosmosBlockChains
|
|
96
|
+
.filter((chain) => chain.info && !chain.info.experimental)
|
|
97
|
+
?.map((chain) => chain.chainId!),
|
|
98
|
+
customChainIds: cosmosBlockChains
|
|
99
|
+
.filter((chain) => chain.info?.experimental)
|
|
100
|
+
.map((chain) => chain.chainId!),
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
} else {
|
|
104
|
+
connectNamespacePromise = async () => namespace.connect();
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
await connectNamespacePromise();
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
109
|
+
} catch (e: any) {
|
|
110
|
+
/*
|
|
111
|
+
* Since we check for connect failures using `instanceof Error`
|
|
112
|
+
* this check is added here to make sure the thrown error always is an instance of `Error`
|
|
113
|
+
*/
|
|
114
|
+
if (e instanceof Error) {
|
|
115
|
+
throw e;
|
|
116
|
+
}
|
|
117
|
+
throw new Error(e);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Sometimes calling methods on a instance in parallel, would cause an error in wallet.
|
|
125
|
+
* We are running a method at a time to make sure we are covering this.
|
|
126
|
+
* e.g. when we are trying to eagerConnect evm and solana on phantom at the same time, the last namespace throw an error.
|
|
127
|
+
*/
|
|
128
|
+
const connectNamespacesResult = await runSequentiallyWithoutFailure(
|
|
129
|
+
connectNamespacesPromises
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
const failedNamespaces: LegacyNamespaceInputForConnect[] = targetNamespaces
|
|
133
|
+
.filter((_, index) => connectNamespacesResult[index].err)
|
|
134
|
+
.map((targetNamespace) => targetNamespace[0]);
|
|
135
|
+
|
|
136
|
+
if (failedNamespaces.length > 0) {
|
|
137
|
+
lastConnectedWalletsFromStorage.removeNamespacesFromWallet(
|
|
138
|
+
type,
|
|
139
|
+
failedNamespaces.map((namespace) => namespace.namespace)
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const atLeastOneNamespaceConnectedSuccessfully = connectNamespacesResult.some(
|
|
144
|
+
(result) => result.ok
|
|
145
|
+
);
|
|
146
|
+
if (!atLeastOneNamespaceConnectedSuccessfully) {
|
|
147
|
+
throw new Error(`No namespace connected for ${type}`);
|
|
148
|
+
}
|
|
149
|
+
return Result.all(
|
|
150
|
+
...connectNamespacesResult.filter((result) => result.ok)
|
|
151
|
+
).unwrap();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Run `.canEagerConnect` action on some selected namespaces of a wallet.
|
|
156
|
+
*/
|
|
157
|
+
async function tryRunCanEagerConnect(
|
|
158
|
+
namespaces: LegacyNamespaceInputForConnect[],
|
|
159
|
+
wallet: Provider
|
|
160
|
+
): Promise<{
|
|
161
|
+
successNamespaces: LegacyNamespaceInputForConnect[];
|
|
162
|
+
failedNamespaces: LegacyNamespaceInputForConnect[];
|
|
163
|
+
}> {
|
|
164
|
+
const foundNamespaces: LegacyNamespaceInputForConnect[] = [];
|
|
165
|
+
const successNamespaces: LegacyNamespaceInputForConnect[] = [];
|
|
166
|
+
const failedNamespaces: LegacyNamespaceInputForConnect[] = [];
|
|
167
|
+
const canEagerConnectPromises: (() => Promise<boolean>)[] = [];
|
|
168
|
+
|
|
169
|
+
// 1. Try find namespace instances and create canEagerConnect promises
|
|
170
|
+
namespaces.forEach((namespace) => {
|
|
171
|
+
const namespaceInstance = wallet.findByNamespace(namespace.namespace);
|
|
172
|
+
if (namespaceInstance) {
|
|
173
|
+
foundNamespaces.push(namespace);
|
|
174
|
+
canEagerConnectPromises.push(
|
|
175
|
+
async () => await namespaceInstance.canEagerConnect()
|
|
176
|
+
);
|
|
177
|
+
} else {
|
|
178
|
+
failedNamespaces.push(namespace);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// 2. Run canEagerConnect sequentially on namespaces
|
|
183
|
+
const canEagerConnectResults = await runSequentiallyWithoutFailure(
|
|
184
|
+
canEagerConnectPromises
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
// 3. Separate success and failed namespaces based on canEagerConnect result
|
|
188
|
+
foundNamespaces.forEach((namespace, index) => {
|
|
189
|
+
if (canEagerConnectResults[index].ok && canEagerConnectResults[index].val) {
|
|
190
|
+
successNamespaces.push(namespace);
|
|
191
|
+
} else {
|
|
192
|
+
failedNamespaces.push(namespace);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
return { successNamespaces, failedNamespaces };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/*
|
|
200
|
+
* Get last connected wallets and last connected namespaces for each of them from storage
|
|
201
|
+
* Then run `.connect` on each namespace if `.canEagerConnect` returns true.
|
|
202
|
+
*/
|
|
203
|
+
export async function autoConnect(deps: {
|
|
204
|
+
getHub: () => Hub;
|
|
205
|
+
allBlockChains: UseAdapterParams['allBlockChains'];
|
|
206
|
+
wallets?: (WalletType | LegacyProviderInterface | Provider)[];
|
|
207
|
+
}): Promise<void> {
|
|
208
|
+
const { getHub, allBlockChains, wallets } = deps;
|
|
209
|
+
const lastConnectedWallets = lastConnectedWalletsFromStorage.list();
|
|
210
|
+
const walletIds = Object.keys(lastConnectedWallets);
|
|
211
|
+
|
|
212
|
+
const walletsToRemoveFromPersistence: string[] = [];
|
|
213
|
+
|
|
214
|
+
if (walletIds.length) {
|
|
215
|
+
const eagerConnectQueue: Promise<unknown>[] = [];
|
|
216
|
+
|
|
217
|
+
const configWalletNames = wallets?.map((wallet) => {
|
|
218
|
+
if (typeof wallet === 'string') {
|
|
219
|
+
return wallet;
|
|
220
|
+
}
|
|
221
|
+
if (wallet instanceof Provider) {
|
|
222
|
+
return wallet.id;
|
|
223
|
+
}
|
|
224
|
+
return wallet.config.type;
|
|
225
|
+
});
|
|
226
|
+
// Run `.connect` if `.canEagerConnect` returns `true`.
|
|
227
|
+
walletIds.forEach(async (providerName) => {
|
|
228
|
+
if (configWalletNames && !configWalletNames.includes(providerName)) {
|
|
229
|
+
console.warn(
|
|
230
|
+
'Trying to run auto connect for a wallet which is not included in config. Desired wallet:',
|
|
231
|
+
providerName
|
|
232
|
+
);
|
|
233
|
+
walletsToRemoveFromPersistence.push(providerName);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const wallet = getHub().get(providerName);
|
|
238
|
+
|
|
239
|
+
const lastConnectedNamespaces: LegacyNamespaceInputForConnect[] =
|
|
240
|
+
lastConnectedWallets[providerName].map((namespace) => ({
|
|
241
|
+
namespace: namespace.namespace,
|
|
242
|
+
network: namespace.network,
|
|
243
|
+
}));
|
|
244
|
+
|
|
245
|
+
if (!lastConnectedNamespaces.length || !wallet) {
|
|
246
|
+
walletsToRemoveFromPersistence.push(providerName);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const { successNamespaces, failedNamespaces } =
|
|
251
|
+
await tryRunCanEagerConnect(lastConnectedNamespaces, wallet);
|
|
252
|
+
|
|
253
|
+
if (!successNamespaces.length) {
|
|
254
|
+
walletsToRemoveFromPersistence.push(providerName);
|
|
255
|
+
return;
|
|
256
|
+
} else if (failedNamespaces.length) {
|
|
257
|
+
lastConnectedWalletsFromStorage.removeNamespacesFromWallet(
|
|
258
|
+
wallet.id,
|
|
259
|
+
failedNamespaces.map((namespace) => namespace.namespace)
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
eagerConnectQueue.push(
|
|
263
|
+
eagerConnect(providerName, successNamespaces, {
|
|
264
|
+
allBlockChains,
|
|
265
|
+
getHub,
|
|
266
|
+
}).catch((error) => console.warn(error))
|
|
267
|
+
);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
lastConnectedWalletsFromStorage.removeWallets(
|
|
271
|
+
walletsToRemoveFromPersistence
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
await Promise.all(eagerConnectQueue);
|
|
275
|
+
}
|
|
276
|
+
}
|