@skip-go/widget 2.4.0 → 2.4.2

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,223 +1,5 @@
1
1
  # Skip Go Widget
2
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/).
3
+ We document everything about Skip Go Widget in [docs.skip.build/go/widget](https://docs.skip.build/go/widget)
4
4
 
5
- ### Polyfilling Node core modules
6
-
7
- If you encounter an error like "Buffer is not defined" when importing and using @skip-go/widget, it may be necessary to polyfill Node.js modules because Skip Go Widget relies on them.
8
-
9
- Here are some polyfill plugins for common environments:
10
-
11
- - [Webpack](https://www.npmjs.com/package/node-polyfill-webpack-plugin),
12
- - [Rollup](https://www.npmjs.com/package/rollup-plugin-polyfill-node),
13
- - [Vite](https://www.npmjs.com/package/vite-plugin-node-polyfills),
14
- - [ESBuild](https://www.npmjs.com/package/esbuild-plugins-node-modules-polyfill)
15
-
16
- ### Wrap the widget with a fixed container
17
-
18
- It is recommended to wrap the widget with a container element that has a fixed size. This helps to prevent layout shifting as the widget uses shadow-dom (which currently needs to be rendered client-side)
19
-
20
- ## Installation
21
-
22
- To install the package, run the following command:
23
-
24
- ```bash
25
- npm install @skip-go/widget
26
- ```
27
-
28
- ## React Component usage
29
-
30
- import the `SwapWidget` from `'@skip-go/widget'` to render the swap interface:
31
-
32
- ```tsx
33
- import { SwapWidget } from '@skip-go/widget';
34
-
35
- const SwapPage = () => {
36
- return (
37
- <div
38
- style={{
39
- width: '450px',
40
- height: '820px',
41
- }}
42
- >
43
- <SwapWidget
44
- colors={{
45
- primary: '#FF4FFF',
46
- }}
47
- />
48
- </div>
49
- );
50
- };
51
- ```
52
-
53
- ### SwapWidget props
54
-
55
- The `SwapWidget` component accepts the following props:
56
-
57
- ````tsx
58
- interface SwapWidgetProps {
59
- defaultRoute?: {
60
- // Default route for the widget.
61
- amountIn?: number;
62
- amountOut?: number;
63
- srcChainID?: string;
64
- srcAssetDenom?: string;
65
- destChainID?: string;
66
- destAssetDenom?: string;
67
- };
68
- routeConfig?: {
69
- experimentalFeatures?: ['hyperlane'];
70
- allowMultiTx?: boolean;
71
- allowUnsafe?: boolean;
72
- bridges?: ('IBC' | 'AXELAR' | 'CCTP' | 'HYPERLANE')[];
73
- swapVenues?: {
74
- name: string;
75
- chainID: string;
76
- }[];
77
- };
78
- /**
79
- * Filter chains and assets in selection
80
- *
81
- * Record<chainID, assetDenoms>
82
- * if assetDenoms is undefined, all assets are allowed
83
- * @example
84
- * ```ts
85
- * {
86
- * source: {
87
- * 'noble-1': undefined,
88
- * },
89
- * destination: {
90
- * 'cosmoshub-4': [
91
- * 'uatom',
92
- * 'ibc/2181AAB0218EAC24BC9F86BD1364FBBFA3E6E3FCC25E88E3E68C15DC6E752D86',
93
- * ],
94
- * 'agoric-3': [
95
- * 'ibc/FE98AAD68F02F03565E9FA39A5E627946699B2B07115889ED812D8BA639576A9',
96
- * ],
97
- * 'osmosis-1': undefined,
98
- * }
99
- * ```
100
- */
101
- filter?: {
102
- source?: Record<string, string[] | undefined>;
103
- destination?: Record<string, string[] | undefined>;
104
- };
105
- className?: string;
106
- style?: React.CSSProperties;
107
- settings?: {
108
- customGasAmount?: number; // custom gas amount for validation defaults to 200_000
109
- slippage?: number; //percentage of slippage 0-100. defaults to 3
110
- };
111
- onlyTestnet?: boolean; // Only show testnet chains
112
- toasterProps?: {
113
- // Refer to [ToasterProps](https://react-hot-toast.com/docs/toast-options) for more details. Defaults to `{ position: 'top-right' }`
114
- position?: ToastPosition;
115
- toastOptions?: DefaultToastOptions;
116
- reverseOrder?: boolean;
117
- gutter?: number;
118
- containerStyle?: React.CSSProperties;
119
- containerClassName?: string;
120
- children?: (toast: Toast) => JSX.Element;
121
- };
122
- endpointOptions?: {
123
- // Endpoint options to override endpoints. Defaults to Skip proxied endpoints. Please reach out to us first if you want to be whitelisted.
124
- endpoints?: Record<string, EndpointOptions>;
125
- getRpcEndpointForChain?: (chainID: string) => Promise<string>;
126
- getRestEndpointForChain?: (chainID: string) => Promise<string>;
127
- };
128
- 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.
129
- theme?: {
130
- backgroundColor: string; // background color
131
- textColor: string; // text color
132
- borderColor: string; // border color
133
- brandColor: string; // color used for confirmation buttons
134
- highlightColor: string; // color used when hovering over buttons, and in select chain/asset dropdown
135
- };
136
- persistSwapWidgetState?: boolean; // whether or not swap widget state should persist after refresh. Defaults to true
137
-
138
- // Pass in callback functions to handle events in the widget.
139
- onWalletConnected?: ({
140
- walletName: string,
141
- chainId: string,
142
- address?: string,
143
- }) => void;
144
-
145
- onWalletDisconnected?: ({
146
- chainType?: string
147
- }) => void;
148
-
149
- onTransactionBroadcasted?: ({
150
- txHash: string,
151
- chainId: string,
152
- explorerLink: string,
153
- }) => void;
154
-
155
- onTransactionComplete?: ({
156
- txHash: string,
157
- chainId: string,
158
- explorerLink: string,
159
- }) => void;
160
-
161
- onTransactionFailed?: ({
162
- error: string;
163
- }) => void;
164
- }
165
- ````
166
-
167
- # Experimental features (still in development)
168
-
169
- ## Web Component usage
170
-
171
- The web component is created with the `@r2wc/react-to-web-component` library.
172
-
173
- In order to register the web-component, you must first call the `initializeSwapWidget` function:
174
-
175
- ```tsx
176
- import { initializeSwapWidget } from '@skip-go/widget';
177
-
178
- initializeSwapWidget();
179
- ```
180
-
181
- et voilà! you can now use the `swap-widget` web-component as `<swap-widget></swap-widget>`
182
-
183
- The props for the web component are the same as `SwapWidgetProps` except that all props
184
- are passed to the web-component via attributes in kebab-case as strings or stringified objects ie.
185
-
186
- ```tsx
187
- <div
188
- style={{
189
- width: '450px',
190
- height: '820px',
191
- }}
192
- >
193
- <SwapWidget
194
- className="test-class"
195
- onlyTestnet={true}
196
- theme={{
197
- brandColor: '#FF4FFF',
198
- }}
199
- defaultRoute={{
200
- srcChainID: 'osmosis-1',
201
- srcAssetDenom:
202
- 'ibc/1480b8fd20ad5fcae81ea87584d269547dd4d436843c1d20f15e00eb64743ef4',
203
- }}
204
- />
205
- </div>
206
- ```
207
-
208
- becomes
209
-
210
- ```tsx
211
- <div style="width:450px;height:820px;">
212
- <swap-widget
213
- class-name="test-class"
214
- onlyTestnet="true"
215
- theme='{"brandColor":"#FF4FFF"}'
216
- default-route={JSON.stringify({
217
- srcChainID: 'osmosis-1',
218
- srcAssetDenom:
219
- 'ibc/1480b8fd20ad5fcae81ea87584d269547dd4d436843c1d20f15e00eb64743ef4',
220
- })}
221
- ></swap-widget>
222
- </div>
223
- ```
5
+ [Here](https://github.com/skip-mev/skip-go/blob/main/docs/widget/) is where all of the markdown lives
@@ -1,2 +1,61 @@
1
- import { Abi } from "viem";
1
+ import { Abi } from 'viem';
2
2
  export declare const multicall3ABI: Abi;
3
+ export declare const seiPrecompileAddrABI: readonly [{
4
+ readonly inputs: readonly [{
5
+ readonly internalType: "string";
6
+ readonly name: "v";
7
+ readonly type: "string";
8
+ }, {
9
+ readonly internalType: "string";
10
+ readonly name: "r";
11
+ readonly type: "string";
12
+ }, {
13
+ readonly internalType: "string";
14
+ readonly name: "s";
15
+ readonly type: "string";
16
+ }, {
17
+ readonly internalType: "string";
18
+ readonly name: "customMessage";
19
+ readonly type: "string";
20
+ }];
21
+ readonly name: "associate";
22
+ readonly outputs: readonly [{
23
+ readonly internalType: "string";
24
+ readonly name: "seiAddr";
25
+ readonly type: "string";
26
+ }, {
27
+ readonly internalType: "address";
28
+ readonly name: "evmAddr";
29
+ readonly type: "address";
30
+ }];
31
+ readonly stateMutability: "nonpayable";
32
+ readonly type: "function";
33
+ }, {
34
+ readonly inputs: readonly [{
35
+ readonly internalType: "address";
36
+ readonly name: "addr";
37
+ readonly type: "address";
38
+ }];
39
+ readonly name: "getSeiAddr";
40
+ readonly outputs: readonly [{
41
+ readonly internalType: "string";
42
+ readonly name: "response";
43
+ readonly type: "string";
44
+ }];
45
+ readonly stateMutability: "view";
46
+ readonly type: "function";
47
+ }, {
48
+ readonly inputs: readonly [{
49
+ readonly internalType: "string";
50
+ readonly name: "addr";
51
+ readonly type: "string";
52
+ }];
53
+ readonly name: "getEvmAddr";
54
+ readonly outputs: readonly [{
55
+ readonly internalType: "address";
56
+ readonly name: "response";
57
+ readonly type: "address";
58
+ }];
59
+ readonly stateMutability: "view";
60
+ readonly type: "function";
61
+ }];
@@ -1,4 +1,3 @@
1
- import { AssetsRequest } from '@skip-go/client';
2
- export declare function useAssets(options?: AssetsRequest): import("@tanstack/react-query/build/legacy/types").UseQueryResult<{
3
- [k: string]: import("@skip-go/client/dist/shared-CpfDn0H3").b[];
4
- }, Error>;
1
+ import { Asset, AssetsRequest } from '@skip-go/client';
2
+ import { UseQueryResult } from '@tanstack/react-query';
3
+ export declare function useAssets(options?: AssetsRequest): UseQueryResult<Record<string, Asset[]>>;
@@ -1,4 +1,5 @@
1
1
  import { Chain } from '@skip-go/client';
2
+ import { UseQueryResult } from '@tanstack/react-query';
2
3
  import { ChainAddresses, SetChainAddressesParam } from '../ui/PreviewRoute/types';
3
4
  export declare const useAutoSetAddress: ({ chain, chainID, index, enabled, signRequired, chainAddresses, setChainAddresses, }: {
4
5
  chain?: Chain | undefined;
@@ -8,4 +9,4 @@ export declare const useAutoSetAddress: ({ chain, chainID, index, enabled, signR
8
9
  signRequired?: boolean | undefined;
9
10
  chainAddresses: ChainAddresses;
10
11
  setChainAddresses: (v: SetChainAddressesParam) => void;
11
- }) => import("@tanstack/react-query/build/legacy/types").UseQueryResult<null, Error>;
12
+ }) => UseQueryResult;
@@ -1,4 +1,5 @@
1
- import { Asset, SkipRouter } from '@skip-go/client';
1
+ import { Asset, SkipClient } from '@skip-go/client';
2
+ import { UseQueryResult } from '@tanstack/react-query';
2
3
  import { PublicClient } from 'viem';
3
4
  import { Chain } from './use-chains';
4
5
  interface Args {
@@ -8,8 +9,8 @@ interface Args {
8
9
  enabled?: boolean;
9
10
  solanaRpcUrl?: string;
10
11
  }
11
- export declare function useBalancesByChain({ address, chain, assets, enabled, }: Args): import("@tanstack/react-query/build/legacy/types").UseQueryResult<Record<string, string> | undefined, Error>;
12
+ export declare function useBalancesByChain({ address, chain, assets, enabled, }: Args): UseQueryResult<Record<string, string> | undefined>;
12
13
  export declare function getBalancesByChain(rpcURL: string, address: string, chainID: string, assets: Asset[]): Promise<Record<string, string>>;
13
- export declare function getEvmChainBalances(skipClient: SkipRouter, publicClient: PublicClient, address: string, chainID: string): Promise<Record<string, string>>;
14
+ export declare function getEvmChainBalances(skipClient: SkipClient, publicClient: PublicClient, address: string, chainID: string): Promise<Record<string, string>>;
14
15
  export declare const getSvmChainBalances: (rpcUrl: string, address: string, chainID: string, assets: Asset[]) => Promise<Record<string, string>>;
15
16
  export {};
@@ -1,7 +1,8 @@
1
1
  import { Bridge } from '@skip-go/client';
2
+ import { UseQueryResult } from '@tanstack/react-query';
2
3
  export type UseBridgesQueryArgs<T = Bridge[]> = {
3
4
  enabled?: boolean;
4
5
  select?: (arr?: Bridge[]) => T;
5
6
  };
6
- export declare function useBridges<T = Bridge[]>(args?: UseBridgesQueryArgs<T>): import("@tanstack/react-query/build/legacy/types").UseQueryResult<T, Error>;
7
- export declare function useBridgeByID(bridgeID?: Bridge['id']): import("@tanstack/react-query/build/legacy/types").UseQueryResult<Bridge | undefined, Error>;
7
+ export declare function useBridges<T = Bridge[]>(args?: UseBridgesQueryArgs<T>): UseQueryResult<T>;
8
+ export declare function useBridgeByID(bridgeID?: Bridge['id']): UseQueryResult<Bridge | undefined>;
@@ -1,4 +1,5 @@
1
1
  import { ChainTransaction, TransferState, StatusState } from '@skip-go/client';
2
+ import { UseQueryResult } from '@tanstack/react-query';
2
3
  interface TransferSequence {
3
4
  srcChainID: string;
4
5
  destChainID: string;
@@ -8,6 +9,12 @@ interface TransferSequence {
8
9
  };
9
10
  state: TransferState;
10
11
  }
12
+ interface TxsStatus {
13
+ isSuccess: boolean;
14
+ isSettled: boolean;
15
+ transferSequence: TransferSequence[];
16
+ states: StatusState[];
17
+ }
11
18
  export declare const useBroadcastedTxsStatus: ({ txs, txsRequired, enabled, }: {
12
19
  txsRequired: number;
13
20
  txs: {
@@ -15,10 +22,5 @@ export declare const useBroadcastedTxsStatus: ({ txs, txsRequired, enabled, }: {
15
22
  txHash: string;
16
23
  }[] | undefined;
17
24
  enabled?: boolean | undefined;
18
- }) => import("@tanstack/react-query/build/legacy/types").UseQueryResult<{
19
- isSuccess: boolean;
20
- isSettled: boolean;
21
- transferSequence: TransferSequence[];
22
- states: StatusState[];
23
- } | undefined, Error>;
25
+ }) => UseQueryResult<TxsStatus>;
24
26
  export {};
@@ -1,4 +1,5 @@
1
1
  import { Chain as SkipChain } from '@skip-go/client';
2
+ import { UseQueryResult } from '@tanstack/react-query';
2
3
  export type Chain = SkipChain & {
3
4
  prettyName: string;
4
5
  };
@@ -6,5 +7,5 @@ export type UseChainsQueryArgs<T = Chain[]> = {
6
7
  enabled?: boolean;
7
8
  select?: (arr?: Chain[]) => T;
8
9
  };
9
- export declare function useChains<T = Chain[]>(args?: UseChainsQueryArgs<T>): import("@tanstack/react-query/build/legacy/types").UseQueryResult<T, Error>;
10
- export declare function useChainByID(chainID?: string): import("@tanstack/react-query/build/legacy/types").UseQueryResult<Chain | undefined, Error>;
10
+ export declare function useChains<T = Chain[]>(args?: UseChainsQueryArgs<T>): UseQueryResult<T>;
11
+ export declare function useChainByID(chainID?: string): UseQueryResult<Chain | undefined>;
@@ -1,6 +1,7 @@
1
1
  export interface MinimalWallet {
2
2
  walletName: string;
3
3
  walletPrettyName: string;
4
+ walletChainType: 'evm' | 'cosmos' | 'svm';
4
5
  walletInfo: {
5
6
  logo?: string | {
6
7
  major: string;
@@ -1,4 +1,5 @@
1
- import { BridgeType, ExperimentalFeature, SmartSwapOptions, SwapVenueRequest } from '@skip-go/client';
1
+ import { BridgeType, ExperimentalFeature, RouteResponse, SmartSwapOptions, SwapVenueRequest } from '@skip-go/client';
2
+ import { UseQueryResult } from '@tanstack/react-query';
2
3
  export interface RouteConfig {
3
4
  experimentalFeatures?: ExperimentalFeature[];
4
5
  allowMultiTx?: boolean;
@@ -16,5 +17,5 @@ interface UseRouteArgs extends RouteConfig {
16
17
  destinationAssetChainID?: string;
17
18
  enabled?: boolean;
18
19
  }
19
- export declare function useRoute({ direction, amount, sourceAsset, sourceAssetChainID, destinationAsset, destinationAssetChainID, enabled, swapVenues, bridges, experimentalFeatures, allowMultiTx, allowUnsafe, smartSwapOptions, }: UseRouteArgs): import("@tanstack/react-query/build/legacy/types").UseQueryResult<import("@skip-go/client/dist/shared-CpfDn0H3").R | undefined, Error>;
20
+ export declare function useRoute({ direction, amount, sourceAsset, sourceAssetChainID, destinationAsset, destinationAssetChainID, enabled, swapVenues, bridges, experimentalFeatures, allowMultiTx, allowUnsafe, smartSwapOptions, }: UseRouteArgs): UseQueryResult<RouteResponse | undefined>;
20
21
  export {};
@@ -1,4 +1,4 @@
1
- export declare function useSkipClient(): import("@skip-go/client").SkipRouter;
1
+ export declare function useSkipClient(): import("@skip-go/client").SkipClient;
2
2
  export declare function useSkipConfig(): {
3
3
  apiURL: string | undefined;
4
4
  endpointOptions: {
@@ -1,8 +1,9 @@
1
+ import { UseQueryResult } from '@tanstack/react-query';
1
2
  export type Args = {
2
3
  chainId: string;
3
4
  denom: string;
4
5
  coingeckoID?: string;
5
6
  value: string;
6
7
  };
7
- export declare function useUsdValue(args: Args): import("@tanstack/react-query/build/legacy/types").UseQueryResult<number, Error>;
8
- export declare function useUsdDiffValue([args1, args2]: [Args, Args]): import("@tanstack/react-query/build/legacy/types").UseQueryResult<number, Error>;
8
+ export declare function useUsdValue(args: Args): UseQueryResult<number>;
9
+ export declare function useUsdDiffValue([args1, args2]: [Args, Args]): UseQueryResult<number, Error>;