@rango-dev/widget-embedded 0.30.1-next.7 → 0.30.1-next.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.30.1-next.7",
3
+ "version": "0.30.1-next.9",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -24,15 +24,15 @@
24
24
  "dependencies": {
25
25
  "@lingui/core": "4.2.1",
26
26
  "@lingui/react": "4.2.1",
27
- "@rango-dev/logging-core": "^0.5.1-next.0",
28
- "@rango-dev/provider-all": "^0.35.2-next.0",
29
- "@rango-dev/queue-manager-core": "^0.26.0",
30
- "@rango-dev/queue-manager-rango-preset": "^0.35.2-next.0",
31
- "@rango-dev/queue-manager-react": "^0.26.0",
32
- "@rango-dev/signer-solana": "^0.30.1-next.0",
33
- "@rango-dev/ui": "^0.36.1-next.2",
34
- "@rango-dev/wallets-react": "^0.21.2-next.0",
35
- "@rango-dev/wallets-shared": "^0.35.1",
27
+ "@rango-dev/logging-core": "^0.5.1-next.1",
28
+ "@rango-dev/provider-all": "^0.35.2-next.2",
29
+ "@rango-dev/queue-manager-core": "^0.26.1-next.0",
30
+ "@rango-dev/queue-manager-rango-preset": "^0.35.2-next.1",
31
+ "@rango-dev/queue-manager-react": "^0.26.1-next.0",
32
+ "@rango-dev/signer-solana": "^0.30.1-next.1",
33
+ "@rango-dev/ui": "^0.36.1-next.3",
34
+ "@rango-dev/wallets-react": "^0.21.2-next.1",
35
+ "@rango-dev/wallets-shared": "^0.35.2-next.0",
36
36
  "bignumber.js": "^9.1.1",
37
37
  "copy-to-clipboard": "^3.3.3",
38
38
  "dayjs": "^1.11.7",
@@ -53,4 +53,4 @@
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  }
56
- }
56
+ }
@@ -260,14 +260,26 @@ export function WalletList(props: PropTypes) {
260
260
  })
261
261
  : conciseAddress;
262
262
 
263
- const onClick = async () => {
263
+ const onSelectableWalletClick = async () => {
264
264
  if (wallet.state === WalletState.DISCONNECTED) {
265
- if (!!wallet.namespaces) {
266
- handleOpenNamespacesModal(wallet);
265
+ if (!!wallet.namespaces?.length) {
266
+ if (wallet.namespaces.length > 1) {
267
+ handleOpenNamespacesModal(wallet);
268
+ } else if (wallet.needsDerivationPath) {
269
+ setDerivationPathModalState({
270
+ open: true,
271
+ providerType: wallet.type,
272
+ providerImage: wallet.image,
273
+ namespace: wallet.namespaces[0],
274
+ });
275
+ } else {
276
+ void handleClick(wallet.type);
277
+ }
267
278
  } else {
268
279
  void handleClick(wallet.type);
269
280
  }
270
281
  } else if (!!wallet.namespaces && !conciseAddress) {
282
+ // wallet is connected on a different namespace
271
283
  await disconnectWallet(wallet.type);
272
284
  handleOpenNamespacesModal(wallet);
273
285
  } else if (couldAddExperimentalChain) {
@@ -409,7 +421,7 @@ export function WalletList(props: PropTypes) {
409
421
  <SelectableWallet
410
422
  key={wallet.type}
411
423
  description={connectedWalletDescription}
412
- onClick={onClick}
424
+ onClick={onSelectableWalletClick}
413
425
  selected={isSelected(wallet.type, chain)}
414
426
  disabled={!isActiveTab}
415
427
  {...wallet}
@@ -68,6 +68,33 @@ export const WalletStateContent = (props: WalletStateContentProps) => {
68
68
  }
69
69
  };
70
70
 
71
+ const handleWalletItemClick = () => {
72
+ if (!!walletType && !!walletInfo) {
73
+ if (!!walletInfo.namespaces?.length) {
74
+ if (walletInfo.namespaces.length > 1) {
75
+ setNamespacesModalState({
76
+ open: true,
77
+ providerType: walletType,
78
+ providerImage: walletInfo.img,
79
+ availableNamespaces: walletInfo.namespaces,
80
+ singleNamespace: walletInfo.singleNamespace,
81
+ });
82
+ } else if (walletInfo.needsDerivationPath) {
83
+ setDerivationPathModalState({
84
+ open: true,
85
+ providerType: walletType,
86
+ providerImage: walletInfo.img,
87
+ namespace: walletInfo.namespaces[0],
88
+ });
89
+ } else {
90
+ connect(walletType).catch((error) => debug(error));
91
+ }
92
+ } else {
93
+ connect(walletType).catch((error) => debug(error));
94
+ }
95
+ }
96
+ };
97
+
71
98
  const handleConfirmNamespaces = (selectedNamespaces: Namespace[]) => {
72
99
  if (
73
100
  !!walletInfo?.needsDerivationPath &&
@@ -117,19 +144,7 @@ export const WalletStateContent = (props: WalletStateContentProps) => {
117
144
  link={walletInfo.installLink}
118
145
  disabled={walletButtonDisabled}
119
146
  // TODO we need to show an error modal when user reject the connection
120
- onClick={async () => {
121
- if (walletInfo.namespaces) {
122
- setNamespacesModalState({
123
- open: true,
124
- providerType: walletType,
125
- providerImage: walletInfo.img,
126
- availableNamespaces: walletInfo.namespaces,
127
- singleNamespace: walletInfo.singleNamespace,
128
- });
129
- } else {
130
- connect(walletType).catch((error) => debug(error));
131
- }
132
- }}
147
+ onClick={handleWalletItemClick}
133
148
  />
134
149
  </WalletContainer>
135
150
  )}
@@ -126,21 +126,35 @@ export function WalletsPage() {
126
126
 
127
127
  const filteredWallets = filterWalletsByCategory(list, blockchainCategory);
128
128
 
129
- const handleWalletItemClick = (type: string, wallet: WalletInfoWithExtra) => {
129
+ const handleWalletItemClick = (wallet: WalletInfoWithExtra) => {
130
130
  if (isSingleWalletActive(list, config.multiWallets)) {
131
131
  return;
132
132
  }
133
133
 
134
- if (!!wallet.namespaces && wallet.state === WalletState.DISCONNECTED) {
135
- setNamespacesModalState({
136
- open: true,
137
- providerType: type,
138
- providerImage: wallet.image,
139
- availableNamespaces: wallet.namespaces,
140
- singleNamespace: wallet.singleNamespace,
141
- });
134
+ if (
135
+ !!wallet.namespaces?.length &&
136
+ wallet.state === WalletState.DISCONNECTED
137
+ ) {
138
+ if (wallet.namespaces.length > 1) {
139
+ setNamespacesModalState({
140
+ open: true,
141
+ providerType: wallet.type,
142
+ providerImage: wallet.image,
143
+ availableNamespaces: wallet.namespaces,
144
+ singleNamespace: wallet.singleNamespace,
145
+ });
146
+ } else if (wallet.needsDerivationPath) {
147
+ setDerivationPathModalState({
148
+ open: true,
149
+ providerType: wallet.type,
150
+ providerImage: wallet.image,
151
+ namespace: wallet.namespaces[0],
152
+ });
153
+ } else {
154
+ void handleClick(wallet.type);
155
+ }
142
156
  } else {
143
- void handleClick(type);
157
+ void handleClick(wallet.type);
144
158
  }
145
159
  };
146
160
 
@@ -208,7 +222,7 @@ export function WalletsPage() {
208
222
  key={key}
209
223
  {...wallet}
210
224
  container={getContainer()}
211
- onClick={(type) => handleWalletItemClick(type, wallet)}
225
+ onClick={() => handleWalletItemClick(wallet)}
212
226
  isLoading={fetchMetaStatus === 'loading'}
213
227
  disabled={!isActiveTab}
214
228
  />