@rango-dev/widget-embedded 0.30.1-next.6 → 0.30.1-next.8

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 (32) hide show
  1. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -653
  2. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
  3. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  4. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  5. package/dist/components/CustomDestination/CustomDestination.d.ts +4 -0
  6. package/dist/components/CustomDestination/CustomDestination.d.ts.map +1 -0
  7. package/dist/components/CustomDestination/CustomDestination.styles.d.ts +495 -0
  8. package/dist/components/CustomDestination/CustomDestination.styles.d.ts.map +1 -0
  9. package/dist/components/CustomDestination/CustomDestination.types.d.ts +7 -0
  10. package/dist/components/CustomDestination/CustomDestination.types.d.ts.map +1 -0
  11. package/dist/components/Quote/Quote.styles.d.ts +2 -2
  12. package/dist/components/RefreshModal/RefreshModal.styles.d.ts +2 -2
  13. package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
  14. package/dist/index.js +2 -2
  15. package/dist/index.js.map +4 -4
  16. package/dist/pages/WalletsPage.d.ts.map +1 -1
  17. package/dist/types/config.d.ts +5 -0
  18. package/dist/types/config.d.ts.map +1 -1
  19. package/dist/utils/swap.d.ts +1 -1
  20. package/dist/utils/swap.d.ts.map +1 -1
  21. package/dist/widget-embedded.build.json +1 -1
  22. package/package.json +3 -3
  23. package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +1 -49
  24. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +59 -178
  25. package/src/components/ConfirmWalletsModal/WalletList.tsx +16 -4
  26. package/src/components/CustomDestination/CustomDestination.styles.ts +45 -0
  27. package/src/components/CustomDestination/CustomDestination.tsx +148 -0
  28. package/src/components/CustomDestination/CustomDestination.types.ts +7 -0
  29. package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +28 -13
  30. package/src/pages/WalletsPage.tsx +25 -11
  31. package/src/types/config.ts +3 -1
  32. package/src/utils/swap.ts +4 -4
@@ -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
  />
@@ -179,6 +179,8 @@ export type TrezorManifest = {
179
179
  * @property {boolean} customDestination - A boolean value indicating whether the user can input a custom
180
180
  * address for the transaction. If set to true, the widget will allow the user to input a custom
181
181
  * address for the destination.
182
+ * @property {{[blockchain: string]: string }} defaultCustomDestinations - The `defaultCustomDestinations` property is a map of supported `blockchain` names to an arbitrary blockchain address.
183
+ * You could use it to set a default custom destination for some blockchains. e.g. {'BSC': '0x2be.....c1','ETH': '0x2be.....c1'}
182
184
  * @property {string} language - The language property is an optional string that specifies the
183
185
  * default language in which the widget should be displayed. If not provided, the widget will default to the
184
186
  * language of the user's browser.
@@ -219,6 +221,7 @@ export type WidgetConfig = {
219
221
  wallets?: (WalletType | ProviderInterface)[];
220
222
  multiWallets?: boolean;
221
223
  customDestination?: boolean;
224
+ defaultCustomDestinations?: { [blockchain: string]: string };
222
225
  language?: Language;
223
226
  theme?: WidgetTheme;
224
227
  externalWallets?: boolean;
@@ -227,7 +230,6 @@ export type WidgetConfig = {
227
230
  variant?: WidgetVariant;
228
231
  enableCentralizedSwappers?: boolean;
229
232
  signers?: SignersConfig;
230
-
231
233
  // These are likely to change or remove at anytime. Please use with a caution.
232
234
  __UNSTABLE_OR_INTERNAL__?: {
233
235
  walletConnectListedDesktopWalletLink?: string;
package/src/utils/swap.ts CHANGED
@@ -722,7 +722,7 @@ export function shouldRetrySwap(pendingSwap: PendingSwap) {
722
722
 
723
723
  export function isConfirmSwapDisabled(
724
724
  fetching: boolean,
725
- showCustomDestination: boolean,
725
+ isCustomDestinationOpen: boolean,
726
726
  customDestination: string | null,
727
727
  quote: SelectedQuote | null,
728
728
  selectedWallets: { walletType: string; chain: string }[],
@@ -752,9 +752,9 @@ export function isConfirmSwapDisabled(
752
752
  : false;
753
753
 
754
754
  return (
755
- (!showCustomDestination && !everyWalletSelected) ||
756
- (showCustomDestination && !customDestination) ||
757
- (showCustomDestination &&
755
+ (!isCustomDestinationOpen && !everyWalletSelected) ||
756
+ (isCustomDestinationOpen && !customDestination) ||
757
+ (isCustomDestinationOpen &&
758
758
  !!customDestination &&
759
759
  (!customDestinationIsValid || !everyRequiredWalletSelected))
760
760
  );