@rango-dev/widget-embedded 0.1.11-next.19 → 0.1.11-next.21

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.1.11-next.19",
3
+ "version": "0.1.11-next.21",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -36,7 +36,7 @@ export function BalanceErrors({ messages }: PropTypes) {
36
36
  <List showListStyle={showListStyle}>
37
37
  {messages.map((warning) => (
38
38
  <ListItem showListStyle={showListStyle}>
39
- <Message variant="body3">- {warning}</Message>
39
+ <Message variant="body2">{warning}</Message>
40
40
  </ListItem>
41
41
  ))}
42
42
  </List>
package/src/lib.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import { SwapContainer } from '@rango-dev/ui';
2
- import React, { useEffect, useState } from 'react';
2
+ import React, { useEffect, useMemo, useState } from 'react';
3
3
  import { AppRouter } from './components/AppRouter';
4
4
  import { useMetaStore } from './store/meta';
5
5
  import { Events, Provider } from '@rango-dev/wallets-core';
@@ -21,6 +21,7 @@ import './i18n';
21
21
  import QueueManager from './QueueManager';
22
22
  import { useUiStore } from './store/ui';
23
23
  import { navigationRoutes } from './constants/navigationRoutes';
24
+ import { initConfig } from './utils/configs';
24
25
 
25
26
  export type WidgetProps = {
26
27
  config?: WidgetConfig;
@@ -45,6 +46,14 @@ export const SwapBox: React.FC<WidgetProps> = ({ config }) => {
45
46
  .filter(isEvmBlockchain)
46
47
  .map((chain) => chain.name);
47
48
 
49
+ useMemo(() => {
50
+ if (config?.apiKey) {
51
+ initConfig({
52
+ API_KEY: config?.apiKey,
53
+ });
54
+ }
55
+ }, [config]);
56
+
48
57
  const onUpdateState: EventHandler = (
49
58
  type,
50
59
  event,
@@ -191,12 +191,12 @@ export function Home() {
191
191
  {hasLimitError(bestRoute) && (
192
192
  <Alert type="error" title={`${swap?.swapperId} Limit`}>
193
193
  <>
194
- <Typography variant="body3">
194
+ <Typography variant="body2">
195
195
  {`${fromAmountRangeError}, Yours: ${numberToString(
196
196
  swap?.fromAmount || null
197
197
  )} ${swap?.from.symbol}`}
198
198
  </Typography>
199
- <Typography variant="body3">{recommendation}</Typography>
199
+ <Typography variant="body2">{recommendation}</Typography>
200
200
  </>
201
201
  </Alert>
202
202
  )}
@@ -19,6 +19,12 @@ export function setConfig(name: keyof Configs, value: any) {
19
19
  }
20
20
 
21
21
  export function initConfig(nextConfigs: Configs) {
22
- configs = structuredClone(nextConfigs);
22
+ let clonedConfigs;
23
+ if (typeof structuredClone === 'function') {
24
+ clonedConfigs = structuredClone(nextConfigs);
25
+ } else {
26
+ clonedConfigs = JSON.parse(JSON.stringify(nextConfigs));
27
+ }
28
+ configs = clonedConfigs;
23
29
  return configs;
24
30
  }