@skip-go/widget 1.1.0 → 1.2.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.
package/README.md CHANGED
@@ -1,159 +1,132 @@
1
- # Skip Go Widget
2
-
3
- The `@skip-go/widget` package is an npm package providing a React component for a full swap interface using the [Skip API](https://skip.build/).
4
-
5
- ## Installation
6
-
7
- To install the package, run the following command:
8
-
9
- ```bash
10
- npm install @skip-go/widget
11
- ```
12
-
13
- ## Quick Start Guide
14
-
15
- ### 1. Wrap Your App with `SwapWidgetProvider`
16
-
17
- First, wrap your application or the relevant page with the `SwapWidgetProvider` component:
18
-
19
- ```tsx
20
- import { SwapWidgetProvider } from '@skip-go/widget';
21
-
22
- function App() {
23
- return (
24
- <SwapWidgetProvider>
25
- <YourApp />
26
- </SwapWidgetProvider>
27
- );
28
- }
29
- ```
30
-
31
- ### 2. Use the `SwapWidget` Component
32
-
33
- Next, import the css and use the `SwapWidget` component to render the swap interface:
34
-
35
- ```tsx
36
- import { SwapWidget } from '@skip-go/widget';
37
- import '@skip-go/widget/style.css';
38
-
39
- const SwapPage = () => {
40
- return (
41
- <div
42
- style={{
43
- width: '450px',
44
- height: '820px',
45
- }}
46
- >
47
- <SwapWidget
48
- colors={{
49
- primary: '#FF4FFF',
50
- }}
51
- />
52
- </div>
53
- );
54
- };
55
- ```
56
-
57
- ## Component Props
58
-
59
- ### SwapWidget
60
-
61
- The `SwapWidget` component accepts the following props:
62
-
63
- ```tsx
64
- interface SwapWidgetProps {
65
- colors?: {
66
- primary?: string; // Custom primary color for the widget. Defaults to `#FF486E`.
67
- };
68
- defaultRoute?: {
69
- // Default route for the widget.
70
- amountIn?: number;
71
- amountOut?: number;
72
- srcChainID?: string;
73
- srcAssetDenom?: string;
74
- destChainID?: string;
75
- destAssetDenom?: string;
76
- };
77
- routeConfig?: {
78
- experimentalFeatures?: ['hyperlane'];
79
- allowMultiTx?: boolean;
80
- allowUnsafe?: boolean;
81
- bridges?: ('IBC' | 'AXELAR' | 'CCTP' | 'HYPERLANE')[];
82
- swapVenues?: {
83
- name: string;
84
- chainID: string;
85
- }[];
86
- };
87
- className?: string;
88
- style?: React.CSSProperties;
89
- settings?: {
90
- customGasAmount?: number; // custom gas amount for validation defaults to 200_000
91
- slippage?: number; //percentage of slippage 0-100. defaults to 3
92
- };
93
- onlyTestnet?: boolean; // Only show testnet chains
94
- }
95
- ```
96
-
97
- ### SwapWidgetProvider
98
-
99
- The `SwapWidgetProvider` component accepts the following prop:
100
-
101
- - `toasterProps` (Optional): Props for the toaster component. Refer to [ToasterProps](https://react-hot-toast.com/docs/toast-options) for more details. Defaults to `{ position: 'top-right' }`.
102
- - `endpointOptions` (Optional): Endpoint options to override endpoints. Defaults to Skip proxied endpoints. Please reach out to us first if you want to be whitelisted.
103
-
104
- ```ts
105
- endpointOptions?: {
106
- // Endpoint options to override endpoints. Defaults to Skip proxied endpoints. Please reach out to us first if you want to be whitelisted.
107
- endpoints?: Record<string, EndpointOptions>;
108
- getRpcEndpointForChain?: (chainID: string) => Promise<string>;
109
- getRestEndpointForChain?: (chainID: string) => Promise<string>;
110
- };
111
- ```
112
-
113
- - `apiURL` (Optional): Custom API URL to override Skip API endpoint. Defaults to Skip proxied endpoints. Please reach out to us first if you want to be whitelisted.
114
-
115
- By following these steps, you can easily integrate the Skip Go Widget into your React application and customize it to meet your specific needs.
116
-
117
- ### Web Component
118
-
119
- The web component is created with the `@r2wc/react-to-web-component` library.
120
-
121
- In order to register the web-component, you must call the `initializeSwapWidget` function:
122
-
123
- ```tsx
124
- import { initializeSwapWidget } from '@skip-go/widget';
125
-
126
- initializeSwapWidget();
127
- ```
128
-
129
- voila! you can now use the `swap-widget` web-component
130
-
131
- The props for the web component are the same as `SwapWidgetProps` and `SwapWidgetProviderProps` except that
132
- they are sent to the web-component as attributes in kebab-case as strings or stringified objects ie.
133
-
134
- ```tsx
135
- interface SwapWidgetProps {
136
- colors
137
- defaultRoute
138
- routeConfig
139
- ```
140
-
141
- becomes
142
-
143
- ```tsx
144
- <swap-widget
145
- class-name="classname"
146
- colors='{"primary":"#FF4FFF"}'
147
- default-route={JSON.stringify({
148
- srcChainID: 'osmosis-1',
149
- srcAssetDenom:
150
- 'ibc/1480b8fd20ad5fcae81ea87584d269547dd4d436843c1d20f15e00eb64743ef4',
151
- })}
152
- ></swap-widget>
153
- ```
154
-
155
- the web-component exposes the `SwapWidgetProviderProps` as attributes on swap-widget as well
156
-
157
- ```tsx
158
- <swap-widget toaster-props="" endpoint-options="" api-url=""></swap-widget>
159
- ```
1
+ # Skip Go Widget
2
+
3
+ The `@skip-go/widget` package is an npm package providing a React component for a full swap interface using the [Skip Go API](https://skip.build/).
4
+
5
+ ## Installation
6
+
7
+ To install the package, run the following command:
8
+
9
+ ```bash
10
+ npm install @skip-go/widget
11
+ ```
12
+
13
+ ## React Component usage
14
+
15
+ import the `SwapWidget` from `'@skip-go/widget'` to render the swap interface:
16
+
17
+ ```tsx
18
+ import { SwapWidget } from '@skip-go/widget';
19
+
20
+ const SwapPage = () => {
21
+ return (
22
+ <div
23
+ style={{
24
+ width: '450px',
25
+ height: '820px',
26
+ }}
27
+ >
28
+ <SwapWidget
29
+ colors={{
30
+ primary: '#FF4FFF',
31
+ }}
32
+ />
33
+ </div>
34
+ );
35
+ };
36
+ ```
37
+
38
+ ### SwapWidget props
39
+
40
+ The `SwapWidget` component accepts the following props:
41
+
42
+ ```tsx
43
+ interface SwapWidgetProps {
44
+ colors?: {
45
+ primary?: string; // Custom primary color for the widget. Defaults to `#FF486E`.
46
+ };
47
+ defaultRoute?: {
48
+ // Default route for the widget.
49
+ amountIn?: number;
50
+ amountOut?: number;
51
+ srcChainID?: string;
52
+ srcAssetDenom?: string;
53
+ destChainID?: string;
54
+ destAssetDenom?: string;
55
+ };
56
+ routeConfig?: {
57
+ experimentalFeatures?: ['hyperlane'];
58
+ allowMultiTx?: boolean;
59
+ allowUnsafe?: boolean;
60
+ bridges?: ('IBC' | 'AXELAR' | 'CCTP' | 'HYPERLANE')[];
61
+ swapVenues?: {
62
+ name: string;
63
+ chainID: string;
64
+ }[];
65
+ };
66
+ className?: string;
67
+ style?: React.CSSProperties;
68
+ settings?: {
69
+ customGasAmount?: number; // custom gas amount for validation defaults to 200_000
70
+ slippage?: number; //percentage of slippage 0-100. defaults to 3
71
+ };
72
+ onlyTestnet?: boolean; // Only show testnet chains
73
+ toasterProps?: {
74
+ // Refer to [ToasterProps](https://react-hot-toast.com/docs/toast-options) for more details. Defaults to `{ position: 'top-right' }`
75
+ position?: ToastPosition;
76
+ toastOptions?: DefaultToastOptions;
77
+ reverseOrder?: boolean;
78
+ gutter?: number;
79
+ containerStyle?: React.CSSProperties;
80
+ containerClassName?: string;
81
+ children?: (toast: Toast) => JSX.Element;
82
+ };
83
+ endpointOptions?: {
84
+ // Endpoint options to override endpoints. Defaults to Skip proxied endpoints. Please reach out to us first if you want to be whitelisted.
85
+ endpoints?: Record<string, EndpointOptions>;
86
+ getRpcEndpointForChain?: (chainID: string) => Promise<string>;
87
+ getRestEndpointForChain?: (chainID: string) => Promise<string>;
88
+ };
89
+ apiURL?: string; // Custom API URL to override Skip API endpoint. Defaults to Skip proxied endpoints. Please reach out to us first if you want to be whitelisted.
90
+ }
91
+ ```
92
+
93
+ ## Web Component usage
94
+
95
+ The web component is created with the `@r2wc/react-to-web-component` library.
96
+
97
+ In order to register the web-component, you must first call the `initializeSwapWidget` function:
98
+
99
+ ```tsx
100
+ import { initializeSwapWidget } from '@skip-go/widget';
101
+
102
+ initializeSwapWidget();
103
+ ```
104
+
105
+ et voilà! you can now use the `swap-widget` web-component as `<swap-widget></swap-widget>`
106
+
107
+ The props for the web component are the same as `SwapWidgetProps` except that
108
+ they are sent to the web-component as attributes in kebab-case as strings or stringified objects ie.
109
+
110
+ ```tsx
111
+ interface SwapWidgetProps {
112
+ colors
113
+ defaultRoute
114
+ routeConfig
115
+ ```
116
+
117
+ becomes
118
+
119
+ ```tsx
120
+ <swap-widget
121
+ class-name="classname"
122
+ colors='{"primary":"#FF4FFF"}'
123
+ default-route={JSON.stringify({
124
+ srcChainID: 'osmosis-1',
125
+ srcAssetDenom:
126
+ 'ibc/1480b8fd20ad5fcae81ea87584d269547dd4d436843c1d20f15e00eb64743ef4',
127
+ })}
128
+ toaster-props=""
129
+ endpoint-options=""
130
+ api-url=""
131
+ ></swap-widget>
132
+ ```
@@ -0,0 +1 @@
1
+ export declare const useDeleteInjectedStylesFromReactHotToast: () => void;
@@ -0,0 +1 @@
1
+ export declare const useFixRadixUiWheelEvent: () => void;
@@ -0,0 +1,2 @@
1
+ import { ReactNode } from 'react';
2
+ export declare const useForceClientRender: (reactNode: ReactNode) => ReactNode;
@@ -0,0 +1 @@
1
+ export declare const useInjectFontsToDocumentHead: () => void;
@@ -0,0 +1 @@
1
+ export declare const useInjectStyleToDocumentHead: () => void;
@@ -0,0 +1 @@
1
+ export declare const useInjectStylesToDocumentHead: () => void;
package/build/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import './styles/global.css';
2
1
  export { SwapWidgetProvider } from './provider';
3
2
  export { SwapWidget, SwapWidgetProps } from './ui';
4
3
  export { initializeSwapWidget } from './ui/WebComponent';