@rango-dev/wallets-react 0.48.1-next.5 → 0.49.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.
Files changed (83) hide show
  1. package/dist/context.d.ts.map +1 -0
  2. package/dist/helpers.d.ts +1 -1
  3. package/dist/hooks.d.ts +3 -0
  4. package/dist/hooks.d.ts.map +1 -0
  5. package/dist/hub/autoConnect.d.ts +2 -4
  6. package/dist/hub/autoConnect.d.ts.map +1 -1
  7. package/dist/hub/constants.d.ts +0 -1
  8. package/dist/hub/constants.d.ts.map +1 -1
  9. package/dist/hub/helpers.d.ts +2 -0
  10. package/dist/hub/helpers.d.ts.map +1 -1
  11. package/dist/hub/lastConnectedWallets.d.ts +1 -2
  12. package/dist/hub/lastConnectedWallets.d.ts.map +1 -1
  13. package/dist/hub/mod.d.ts +1 -1
  14. package/dist/hub/mod.d.ts.map +1 -1
  15. package/dist/hub/persistor.d.ts +11 -0
  16. package/dist/hub/persistor.d.ts.map +1 -0
  17. package/dist/{legacy → hub}/useAutoConnect.d.ts +1 -1
  18. package/dist/hub/useAutoConnect.d.ts.map +1 -0
  19. package/dist/hub/useHubAdapter.d.ts +1 -5
  20. package/dist/hub/useHubAdapter.d.ts.map +1 -1
  21. package/dist/hub/utils.d.ts +7 -8
  22. package/dist/hub/utils.d.ts.map +1 -1
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +1 -1
  26. package/dist/index.js.map +4 -4
  27. package/dist/legacy/mod.d.ts +2 -4
  28. package/dist/legacy/mod.d.ts.map +1 -1
  29. package/dist/legacy/types.d.ts +89 -69
  30. package/dist/legacy/types.d.ts.map +1 -1
  31. package/dist/provider.d.ts +1 -1
  32. package/dist/provider.d.ts.map +1 -1
  33. package/dist/types.d.ts +39 -0
  34. package/dist/types.d.ts.map +1 -0
  35. package/package.json +6 -11
  36. package/src/{legacy/context.ts → context.ts} +0 -3
  37. package/src/helpers.ts +1 -1
  38. package/src/hooks.ts +13 -0
  39. package/src/hub/autoConnect.ts +26 -35
  40. package/src/hub/constants.ts +0 -1
  41. package/src/hub/helpers.ts +8 -1
  42. package/src/hub/lastConnectedWallets.ts +3 -51
  43. package/src/hub/mod.ts +1 -5
  44. package/src/hub/persistor.ts +19 -0
  45. package/src/{legacy → hub}/useAutoConnect.ts +2 -2
  46. package/src/hub/useHubAdapter.ts +37 -35
  47. package/src/hub/utils.ts +20 -55
  48. package/src/index.ts +2 -2
  49. package/src/legacy/mod.ts +6 -9
  50. package/src/legacy/types.ts +112 -97
  51. package/src/provider.tsx +8 -4
  52. package/src/types.ts +58 -0
  53. package/CHANGELOG.md +0 -343
  54. package/dist/helpers/index.d.ts +0 -2
  55. package/dist/helpers/index.d.ts.map +0 -1
  56. package/dist/helpers/index.js +0 -2
  57. package/dist/helpers/index.js.map +0 -7
  58. package/dist/legacy/autoConnect.d.ts +0 -7
  59. package/dist/legacy/autoConnect.d.ts.map +0 -1
  60. package/dist/legacy/context.d.ts.map +0 -1
  61. package/dist/legacy/helpers.d.ts +0 -31
  62. package/dist/legacy/helpers.d.ts.map +0 -1
  63. package/dist/legacy/hooks.d.ts +0 -10
  64. package/dist/legacy/hooks.d.ts.map +0 -1
  65. package/dist/legacy/useAutoConnect.d.ts.map +0 -1
  66. package/dist/legacy/useLegacyProviders.d.ts +0 -7
  67. package/dist/legacy/useLegacyProviders.d.ts.map +0 -1
  68. package/dist/legacy/utils.d.ts +0 -3
  69. package/dist/legacy/utils.d.ts.map +0 -1
  70. package/dist/test-utils/fixtures.d.ts +0 -14
  71. package/dist/test-utils/fixtures.d.ts.map +0 -1
  72. package/dist/useProviders.d.ts +0 -4
  73. package/dist/useProviders.d.ts.map +0 -1
  74. package/helpers/package.json +0 -8
  75. package/src/helpers/index.ts +0 -1
  76. package/src/legacy/autoConnect.ts +0 -69
  77. package/src/legacy/helpers.ts +0 -193
  78. package/src/legacy/hooks.ts +0 -54
  79. package/src/legacy/useLegacyProviders.ts +0 -246
  80. package/src/legacy/utils.ts +0 -7
  81. package/src/test-utils/fixtures.ts +0 -164
  82. package/src/useProviders.ts +0 -121
  83. /package/dist/{legacy/context.d.ts → context.d.ts} +0 -0
@@ -1,72 +1,92 @@
1
- import type { Provider, ProviderMetadata } from '@hub3js/core';
2
- import type { NamespaceData } from '@hub3js/core/store';
3
- import type { VersionedProviders } from '@hub3js/core/utils';
1
+ import type { DerivationPathProperty, NamespacesProperty, ProviderMetadata, WalletType } from '@hub3js/core';
4
2
  import type { Namespace } from '@hub3js/namespaces';
5
- 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 { Network } from '@rango-dev/internal-blockchains';
6
4
  import type { BlockchainMeta, SignerFactory } from 'rango-types';
7
- import type { PropsWithChildren } from 'react';
8
- import { LegacyEvents as Events } from '@rango-dev/wallets-core/legacy';
9
- type InstanceType = any;
10
- export type State = {
11
- [key: string]: WalletState | undefined;
5
+ export type NamespaceMeta = NamespacesProperty['value']['data'][number];
6
+ export type NeedsNamespace = NamespacesProperty['value'];
7
+ export type NeedsDerivationPath = DerivationPathProperty['value'];
8
+ export type InstallObjects = {
9
+ CHROME?: string;
10
+ FIREFOX?: string;
11
+ EDGE?: string;
12
+ BRAVE?: string;
13
+ DEFAULT: string;
12
14
  };
13
- export type ConnectResult = {
15
+ export type WalletInfo = {
16
+ name: string;
17
+ img: string;
18
+ installLink: InstallObjects | string;
19
+ /**
20
+ * @deprecated we don't use this value anymore.
21
+ */
22
+ color: string;
23
+ supportedChains: BlockchainMeta[];
24
+ showOnMobile?: boolean;
25
+ isContractWallet?: boolean;
26
+ mobileWallet?: boolean;
27
+ needsDerivationPath?: NeedsDerivationPath;
28
+ needsNamespace?: NeedsNamespace;
29
+ };
30
+ export type WalletState = {
31
+ connected: boolean;
32
+ connecting: boolean;
33
+ /**
34
+ * @deprecated it always returns `false`. don't use it.
35
+ */
36
+ reachable: boolean;
37
+ installed: boolean;
14
38
  accounts: string[] | null;
15
39
  network: Network | null;
16
- provider: InstanceType;
40
+ derivationPath?: string;
17
41
  };
18
- export type Providers = {
19
- [type in WalletType]?: InstanceType;
42
+ type NamespaceData = {
43
+ namespace: Namespace;
44
+ derivationPath?: string;
45
+ };
46
+ export type NamespaceInputForConnect<T extends Namespace = Namespace> = {
47
+ /**
48
+ * By default, you should specify namespace (e.g. evm).
49
+ */
50
+ namespace: T;
51
+ /**
52
+ * In some cases, we need to connect a specific network on a namespace. e.g. Polygon on EVM.
53
+ */
54
+ network: Network | undefined;
55
+ derivationPath?: string;
56
+ };
57
+ export declare enum Events {
58
+ CONNECTED = "connected",
59
+ CONNECTING = "connecting",
60
+ REACHABLE = "reachable",
61
+ INSTALLED = "installed",
62
+ ACCOUNTS = "accounts",
63
+ NETWORK = "network",
64
+ NAMESPACE_DISCONNECTED = "namespace_disconnected",
65
+ PROVIDER_DISCONNECTED = "provider_disconnected"
66
+ }
67
+ export type EventInfo = {
68
+ supportedBlockchains: BlockchainMeta[];
69
+ isContractWallet: boolean;
70
+ isHub: boolean;
71
+ namespace?: Namespace;
72
+ derivationPath?: string;
73
+ };
74
+ export type EventHandler = (type: WalletType, event: Events, value: any, coreState: WalletState, info: EventInfo) => void;
75
+ export type ConnectResult = {
76
+ accounts: string[] | null;
77
+ network: Network | null;
20
78
  };
21
79
  export type ExtendedWalletInfo = WalletInfo & {
22
80
  properties?: ProviderMetadata['properties'];
23
81
  isHub?: boolean;
24
82
  };
25
- export type ProviderContext = {
26
- connect(type: WalletType, namespaces?: LegacyNamespaceInputForConnect[]): Promise<ConnectResult[]>;
27
- disconnect(type: WalletType, namespaces?: Namespace[]): Promise<void>;
28
- disconnectAll(): Promise<PromiseSettledResult<any>[]>;
29
- state(type: WalletType): WalletState & {
30
- namespaces?: Map<Namespace, NamespaceData>;
31
- };
32
- canSwitchNetworkTo(type: WalletType, network: Network, namespace?: LegacyNamespaceInputForConnect): boolean;
33
- /**
34
- * `Provider` in legacy terms means injected instances by wallets into window (e.g. window.ethereum)
35
- * that can be retrieved by `getInstance`.
36
- *
37
- * Note 1: Providers are lazy evaluated, which means you need to call `connect` (or `state`) first, then the value will be shown in object.
38
- * 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})
39
- */
40
- providers(): Providers;
41
- getSigners(type: WalletType): Promise<SignerFactory>;
42
- getWalletInfo(type: WalletType): ExtendedWalletInfo;
43
- suggestAndConnect(type: WalletType, namespace: LegacyNamespaceInputForConnect): Promise<ConnectResult>;
44
- hubProvider(type: WalletType): Provider;
45
- };
46
- export type ProviderProps = PropsWithChildren<{
47
- onUpdateState?: WalletEventHandler;
48
- allBlockChains?: BlockchainMeta[];
49
- autoConnect?: boolean;
50
- providers: VersionedProviders[];
51
- configs?: {
52
- wallets?: (WalletType | LegacyProviderInterface | Provider)[];
53
- walletOptions?: {
54
- [key: WalletType]: {
55
- provider?: unknown;
56
- namespaces?: {
57
- [namespaceId: string]: unknown;
58
- };
59
- };
60
- };
61
- };
62
- }>;
63
- export { Events };
64
- export type ProviderConnectResult = {
83
+ type InstanceType = any;
84
+ type ProviderConnectResult = {
65
85
  accounts: string[];
66
86
  chainId: string;
67
87
  derivationPath?: string;
68
88
  };
69
- export type GetInstanceOptions = {
89
+ type GetInstanceOptions = {
70
90
  network?: Network;
71
91
  currentProvider: InstanceType;
72
92
  meta: BlockchainMeta[];
@@ -80,19 +100,19 @@ export type GetInstanceOptions = {
80
100
  force?: boolean;
81
101
  updateChainId: (chainId: number | string) => void;
82
102
  };
83
- export type GetInstance = (() => InstanceType) | ((options: GetInstanceOptions) => Promise<InstanceType>);
84
- export type TryGetInstance = (() => InstanceType) | ((options: Pick<GetInstanceOptions, 'force' | 'network'>) => Promise<InstanceType>);
85
- export type Connect = (options: {
103
+ type TryGetInstance = (() => InstanceType) | ((options: Pick<GetInstanceOptions, 'force' | 'network'>) => Promise<InstanceType>);
104
+ type Connect = (options: {
86
105
  instance: InstanceType;
87
106
  network?: Network;
88
107
  meta: BlockchainMeta[];
108
+ namespaces?: NamespaceData[];
89
109
  }) => Promise<ProviderConnectResult | ProviderConnectResult[]>;
90
- export type Disconnect = (options: {
110
+ type Disconnect = (options: {
91
111
  instance: InstanceType;
92
112
  destroyInstance: () => void;
93
113
  }) => Promise<void>;
94
114
  type CleanupSubscribe = () => void;
95
- export type Subscribe = (options: {
115
+ type Subscribe = (options: {
96
116
  instance: InstanceType;
97
117
  state: WalletState;
98
118
  meta: BlockchainMeta[];
@@ -101,7 +121,7 @@ export type Subscribe = (options: {
101
121
  connect: (network?: Network) => void;
102
122
  disconnect: () => void;
103
123
  }) => CleanupSubscribe | void;
104
- export type SwitchNetwork = (options: {
124
+ type SwitchNetwork = (options: {
105
125
  instance: InstanceType;
106
126
  network: Network;
107
127
  meta: BlockchainMeta[];
@@ -109,21 +129,21 @@ export type SwitchNetwork = (options: {
109
129
  getState?: () => WalletState;
110
130
  updateChainId: (chainId: string) => void;
111
131
  }) => Promise<void>;
112
- export type Suggest = (options: {
132
+ type Suggest = (options: {
113
133
  instance: InstanceType;
114
134
  network: Network;
115
135
  meta: BlockchainMeta[];
116
136
  }) => Promise<void>;
117
- export type CanSwitchNetwork = (options: {
137
+ type CanSwitchNetwork = (options: {
118
138
  network: Network;
119
139
  meta: BlockchainMeta[];
120
140
  provider: InstanceType;
121
141
  }) => boolean;
122
- export type CanEagerConnect = (options: {
142
+ type CanEagerConnect = (options: {
123
143
  instance: InstanceType;
124
144
  meta: BlockchainMeta[];
125
145
  }) => Promise<boolean>;
126
- export interface WalletActions {
146
+ interface WalletActions {
127
147
  connect: Connect;
128
148
  getInstance: InstanceType;
129
149
  disconnect?: Disconnect;
@@ -135,18 +155,18 @@ export interface WalletActions {
135
155
  canEagerConnect?: CanEagerConnect;
136
156
  getWalletInfo(allBlockChains: BlockchainMeta[]): WalletInfo;
137
157
  }
138
- export interface WalletConfig {
158
+ interface WalletConfig {
139
159
  type: WalletType;
140
160
  defaultNetwork?: Network;
141
161
  checkInstallation?: boolean;
142
162
  isAsyncInstance?: boolean;
143
163
  isAsyncSwitchNetwork?: boolean;
144
164
  }
145
- export type WalletProviders = Map<WalletType, {
146
- actions: WalletActions;
147
- config: WalletConfig;
148
- }>;
165
+ /**
166
+ * @deprecated Pass a hub `Provider` instead. This type will be removed in future versions.
167
+ */
149
168
  export type ProviderInterface = {
150
169
  config: WalletConfig;
151
170
  } & WalletActions;
171
+ export {};
152
172
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/legacy/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,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,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAGxE,KAAK,YAAY,GAAG,GAAG,CAAC;AAExB,MAAM,MAAM,KAAK,GAAG;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;CAC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G,aAAa,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ProviderProps } from './legacy/types.js';
1
+ import type { ProviderProps } from './types.js';
2
2
  import React from 'react';
3
3
  declare function Provider(props: ProviderProps): React.JSX.Element;
4
4
  export default Provider;
@@ -1 +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"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,qBAWrC;AAED,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { ConnectResult, EventHandler, ExtendedWalletInfo, NamespaceInputForConnect, WalletState } from './legacy/types.js';
2
+ import type { Provider, WalletType } from '@hub3js/core';
3
+ import type { NamespaceData as HubNamespaceData } from '@hub3js/core/store';
4
+ import type { VersionedProviders } from '@hub3js/core/utils';
5
+ import type { Namespace } from '@hub3js/namespaces';
6
+ import type { Network } from '@rango-dev/internal-blockchains';
7
+ import type { BlockchainMeta, SignerFactory } from 'rango-types';
8
+ import type { PropsWithChildren } from 'react';
9
+ export type ProviderContext = {
10
+ connect(type: WalletType, namespaces?: NamespaceInputForConnect[]): Promise<ConnectResult[]>;
11
+ disconnect(type: WalletType, namespaces?: Namespace[]): Promise<void>;
12
+ disconnectAll(): Promise<PromiseSettledResult<any>[]>;
13
+ state(type: WalletType): WalletState & {
14
+ namespaces?: Map<Namespace, HubNamespaceData>;
15
+ };
16
+ canSwitchNetworkTo(type: WalletType, network: Network, namespace?: NamespaceInputForConnect): boolean;
17
+ getSigners(type: WalletType): Promise<SignerFactory>;
18
+ getWalletInfo(type: WalletType): ExtendedWalletInfo;
19
+ suggestAndConnect(type: WalletType, namespace: NamespaceInputForConnect): Promise<ConnectResult>;
20
+ hubProvider(type: WalletType): Provider;
21
+ };
22
+ export type ProviderProps = PropsWithChildren<{
23
+ onUpdateState?: EventHandler;
24
+ allBlockChains?: BlockchainMeta[];
25
+ autoConnect?: boolean;
26
+ providers: VersionedProviders[];
27
+ configs?: {
28
+ wallets?: (WalletType | Provider)[];
29
+ walletOptions?: {
30
+ [key: WalletType]: {
31
+ provider?: unknown;
32
+ namespaces?: {
33
+ [namespaceId: string]: unknown;
34
+ };
35
+ };
36
+ };
37
+ };
38
+ }>;
39
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,wBAAwB,EACxB,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,CACL,IAAI,EAAE,UAAU,EAChB,UAAU,CAAC,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,GAAG,OAAO,CAAC;iBAChC,CAAC;aACH,CAAC;SACH,CAAC;KACH,CAAC;CACH,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/wallets-react",
3
- "version": "0.48.1-next.5",
3
+ "version": "0.49.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -9,19 +9,14 @@
9
9
  ".": {
10
10
  "types": "./dist/index.d.ts",
11
11
  "default": "./dist/index.js"
12
- },
13
- "./helpers": {
14
- "types": "./dist/helpers/index.d.ts",
15
- "default": "./dist/helpers/index.js"
16
12
  }
17
13
  },
18
14
  "files": [
19
15
  "dist",
20
- "src",
21
- "helpers"
16
+ "src"
22
17
  ],
23
18
  "scripts": {
24
- "build": "yarn run rangutopia library build --inputs src/index.ts,src/helpers/index.ts",
19
+ "build": "yarn run rangutopia library build --inputs src/index.ts",
25
20
  "ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json",
26
21
  "clean": "rimraf dist",
27
22
  "format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
@@ -43,9 +38,9 @@
43
38
  "@hub3js/std": "^0.4.0",
44
39
  "@hub3js/sui": "^0.4.0",
45
40
  "@hub3js/tvm": "^0.4.0",
46
- "@rango-dev/internal-blockchains": "^0.1.1-next.2",
41
+ "@rango-dev/internal-blockchains": "^0.2.0",
47
42
  "@rango-dev/logging-core": "^0.14.0",
48
- "@rango-dev/wallets-core": "^0.61.1-next.2",
43
+ "@rango-dev/wallets-core": "^0.62.0",
49
44
  "caip": "^1.1.1",
50
45
  "rango-types": "^0.5.0",
51
46
  "ts-results": "^3.3.0"
@@ -58,4 +53,4 @@
58
53
  "publishConfig": {
59
54
  "access": "public"
60
55
  }
61
- }
56
+ }
@@ -22,9 +22,6 @@ const defaultContext: ProviderContext = {
22
22
  canSwitchNetworkTo() {
23
23
  throw new Error(defaultErrorMessage);
24
24
  },
25
- providers() {
26
- throw new Error(defaultErrorMessage);
27
- },
28
25
  getWalletInfo() {
29
26
  throw new Error(defaultErrorMessage);
30
27
  },
package/src/helpers.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ProviderContext } from './index.js';
1
+ import type { ProviderContext } from './types.js';
2
2
 
3
3
  import { debug } from '@rango-dev/logging-core';
4
4
 
package/src/hooks.ts ADDED
@@ -0,0 +1,13 @@
1
+ import type { ProviderContext } from './types.js';
2
+
3
+ import { useContext } from 'react';
4
+
5
+ import { WalletContext } from './context.js';
6
+
7
+ export function useWallets(): ProviderContext {
8
+ const context = useContext(WalletContext);
9
+ if (!context) {
10
+ throw Error('useWallet can only be used within the Provider component');
11
+ }
12
+ return context;
13
+ }
@@ -1,20 +1,13 @@
1
1
  import type { AllProxiedNamespaces } from './types.js';
2
2
  import type { UseAdapterParams } from './useHubAdapter.js';
3
- import type { Hub } from '@hub3js/core';
3
+ import type { NamespaceInputForConnect } from '../legacy/types.js';
4
+ import type { Hub, Provider, WalletType } from '@hub3js/core';
4
5
  import type { DefaultNamespaces, Namespace } from '@hub3js/namespaces';
5
6
  import type { Accounts, AccountsWithActiveChain } from '@hub3js/std/types';
6
- import type {
7
- LegacyNamespaceInputForConnect,
8
- LegacyProviderInterface,
9
- LegacyWalletType as WalletType,
10
- } from '@rango-dev/wallets-core/legacy';
11
-
12
- import { Provider } from '@hub3js/core';
13
- import { legacyIsEvmNamespace } from '@rango-dev/wallets-core/legacy';
14
- import { Result } from 'ts-results';
15
7
 
16
- import { HUB_LAST_CONNECTED_WALLETS } from '../legacy/mod.js';
8
+ import { Result } from 'ts-results';
17
9
 
10
+ import { HUB_LAST_CONNECTED_WALLETS } from './constants.js';
18
11
  import { runSequentiallyWithoutFailure } from './helpers.js';
19
12
  import { LastConnectedWalletsFromStorage } from './lastConnectedWallets.js';
20
13
  import {
@@ -22,6 +15,12 @@ import {
22
15
  isEvmNamespace,
23
16
  } from './utils.js';
24
17
 
18
+ function isEvmNamespaceInput(
19
+ namespace: NamespaceInputForConnect
20
+ ): namespace is NamespaceInputForConnect<'EVM'> {
21
+ return namespace.namespace === 'EVM';
22
+ }
23
+
25
24
  // Getting connected wallets from storage
26
25
  const lastConnectedWalletsFromStorage = new LastConnectedWalletsFromStorage(
27
26
  HUB_LAST_CONNECTED_WALLETS
@@ -32,7 +31,7 @@ const lastConnectedWalletsFromStorage = new LastConnectedWalletsFromStorage(
32
31
  */
33
32
  async function eagerConnect(
34
33
  type: string,
35
- namespacesInput: LegacyNamespaceInputForConnect[] | undefined,
34
+ namespacesInput: NamespaceInputForConnect[] | undefined,
36
35
  params: {
37
36
  getHub: () => Hub;
38
37
  allBlockChains: UseAdapterParams['allBlockChains'];
@@ -50,10 +49,8 @@ async function eagerConnect(
50
49
  throw new Error('Passing namespace to `connect` is required. ');
51
50
  }
52
51
 
53
- const targetNamespaces: [
54
- LegacyNamespaceInputForConnect,
55
- AllProxiedNamespaces
56
- ][] = [];
52
+ const targetNamespaces: [NamespaceInputForConnect, AllProxiedNamespaces][] =
53
+ [];
57
54
  namespacesInput.forEach((namespaceInput) => {
58
55
  const targetNamespace: Namespace = namespaceInput.namespace;
59
56
 
@@ -70,7 +67,7 @@ async function eagerConnect(
70
67
 
71
68
  const connectNamespacesPromises = targetNamespaces.map(
72
69
  ([info, namespace]) => {
73
- const evmChain = legacyIsEvmNamespace(info)
70
+ const evmChain = isEvmNamespaceInput(info)
74
71
  ? convertNamespaceNetworkToEvmChainId(info, allBlockChains || [])
75
72
  : undefined;
76
73
  const chain = evmChain || info.network;
@@ -110,7 +107,7 @@ async function eagerConnect(
110
107
  connectNamespacesPromises
111
108
  );
112
109
 
113
- const failedNamespaces: LegacyNamespaceInputForConnect[] = targetNamespaces
110
+ const failedNamespaces: NamespaceInputForConnect[] = targetNamespaces
114
111
  .filter((_, index) => connectNamespacesResult[index].err)
115
112
  .map((targetNamespace) => targetNamespace[0]);
116
113
 
@@ -136,15 +133,15 @@ async function eagerConnect(
136
133
  * Run `.canEagerConnect` action on some selected namespaces of a wallet.
137
134
  */
138
135
  async function tryRunCanEagerConnect(
139
- namespaces: LegacyNamespaceInputForConnect[],
136
+ namespaces: NamespaceInputForConnect[],
140
137
  wallet: Provider<DefaultNamespaces>
141
138
  ): Promise<{
142
- successNamespaces: LegacyNamespaceInputForConnect[];
143
- failedNamespaces: LegacyNamespaceInputForConnect[];
139
+ successNamespaces: NamespaceInputForConnect[];
140
+ failedNamespaces: NamespaceInputForConnect[];
144
141
  }> {
145
- const foundNamespaces: LegacyNamespaceInputForConnect[] = [];
146
- const successNamespaces: LegacyNamespaceInputForConnect[] = [];
147
- const failedNamespaces: LegacyNamespaceInputForConnect[] = [];
142
+ const foundNamespaces: NamespaceInputForConnect[] = [];
143
+ const successNamespaces: NamespaceInputForConnect[] = [];
144
+ const failedNamespaces: NamespaceInputForConnect[] = [];
148
145
  const canEagerConnectPromises: (() => Promise<boolean>)[] = [];
149
146
 
150
147
  // 1. Try find namespace instances and create canEagerConnect promises
@@ -184,7 +181,7 @@ async function tryRunCanEagerConnect(
184
181
  export async function autoConnect(deps: {
185
182
  getHub: () => Hub;
186
183
  allBlockChains: UseAdapterParams['allBlockChains'];
187
- wallets?: (WalletType | LegacyProviderInterface | Provider)[];
184
+ wallets?: (WalletType | Provider)[];
188
185
  }): Promise<void> {
189
186
  const { getHub, allBlockChains, wallets } = deps;
190
187
  const lastConnectedWallets = lastConnectedWalletsFromStorage.list();
@@ -195,15 +192,9 @@ export async function autoConnect(deps: {
195
192
  if (walletIds.length) {
196
193
  const eagerConnectQueue: Promise<unknown>[] = [];
197
194
 
198
- const configWalletNames = wallets?.map((wallet) => {
199
- if (typeof wallet === 'string') {
200
- return wallet;
201
- }
202
- if (wallet instanceof Provider) {
203
- return wallet.id;
204
- }
205
- return wallet.config.type;
206
- });
195
+ const configWalletNames = wallets?.map((wallet) =>
196
+ typeof wallet === 'string' ? wallet : wallet.id
197
+ );
207
198
  // Run `.connect` if `.canEagerConnect` returns `true`.
208
199
  walletIds.forEach(async (providerName) => {
209
200
  if (configWalletNames && !configWalletNames.includes(providerName)) {
@@ -217,7 +208,7 @@ export async function autoConnect(deps: {
217
208
 
218
209
  const wallet = getHub().get(providerName);
219
210
 
220
- const lastConnectedNamespaces: LegacyNamespaceInputForConnect[] =
211
+ const lastConnectedNamespaces: NamespaceInputForConnect[] =
221
212
  lastConnectedWallets[providerName].map((namespace) => ({
222
213
  namespace: namespace.namespace,
223
214
  network: namespace.network,
@@ -1,2 +1 @@
1
- export const LEGACY_LAST_CONNECTED_WALLETS = 'last-connected-wallets';
2
1
  export const HUB_LAST_CONNECTED_WALLETS = 'hub-v1-last-connected-wallets';
@@ -1,4 +1,5 @@
1
1
  import type { AllProxiedNamespaces } from './types.js';
2
+ import type { ProviderProps } from '../types.js';
2
3
  import type { Accounts, AccountsWithActiveChain } from '@hub3js/std/types';
3
4
  import type { Result } from 'ts-results';
4
5
 
@@ -10,7 +11,7 @@ import {
10
11
  CAIP_ZCASH_CHAIN_ID,
11
12
  } from '@hub3js/bip122';
12
13
  import { CAIP_NAMESPACE as CAIP_TON_NAMESPACE } from '@hub3js/tvm';
13
- import { legacyFormatAddressWithNetwork as formatAddressWithNetwork } from '@rango-dev/wallets-core/legacy';
14
+ import { formatAddressWithNetwork } from '@rango-dev/internal-blockchains';
14
15
  import { CAIP_TRON_CHAIN_ID } from '@rango-dev/wallets-core/namespaces/tron';
15
16
  import { AccountId, type ChainIdParams } from 'caip';
16
17
  import { Err, Ok } from 'ts-results';
@@ -179,3 +180,9 @@ export function createQueue(options?: {
179
180
 
180
181
  return queueTask;
181
182
  }
183
+
184
+ export function shouldTryAutoConnect(
185
+ props: Pick<ProviderProps, 'allBlockChains' | 'autoConnect'>
186
+ ): boolean {
187
+ return !!props.allBlockChains?.length && !!props.autoConnect;
188
+ }