@skip-go/widget 2.4.0 → 2.4.1-alpha.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 +2 -220
- package/build/hooks/use-assets.d.ts +3 -4
- package/build/hooks/use-auto-set-address.d.ts +2 -1
- package/build/hooks/use-balances-by-chain.d.ts +4 -3
- package/build/hooks/use-bridges.d.ts +3 -2
- package/build/hooks/use-broadcasted-txs.d.ts +8 -6
- package/build/hooks/use-chains.d.ts +3 -2
- package/build/hooks/use-route.d.ts +3 -2
- package/build/hooks/use-skip-client.d.ts +1 -1
- package/build/hooks/use-usd-value.d.ts +3 -2
- package/build/index.es.js +71 -5
- package/build/index.es.js.map +1 -1
- package/build/lib/penumbra.d.ts +7 -0
- package/build/lib/wagmi.d.ts +2 -8986
- package/build/provider/index.d.ts +2 -2
- package/build/provider/skip-provider.d.ts +3 -3
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -1,223 +1,5 @@
|
|
|
1
1
|
# Skip Go Widget
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
We document everything about Skip Go Widget in [docs.skip.build/go/widget](https://docs.skip.build/go/widget)
|
|
4
4
|
|
|
5
|
-
|
|
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,4 +1,3 @@
|
|
|
1
|
-
import { AssetsRequest } from '@skip-go/client';
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
}) =>
|
|
12
|
+
}) => UseQueryResult;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Asset,
|
|
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):
|
|
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:
|
|
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>):
|
|
7
|
-
export declare function useBridgeByID(bridgeID?: Bridge['id']):
|
|
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
|
-
}) =>
|
|
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>):
|
|
10
|
-
export declare function useChainByID(chainID?: string):
|
|
10
|
+
export declare function useChains<T = Chain[]>(args?: UseChainsQueryArgs<T>): UseQueryResult<T>;
|
|
11
|
+
export declare function useChainByID(chainID?: string): UseQueryResult<Chain | undefined>;
|
|
@@ -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):
|
|
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,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):
|
|
8
|
-
export declare function useUsdDiffValue([args1, args2]: [Args, Args]):
|
|
8
|
+
export declare function useUsdValue(args: Args): UseQueryResult<number>;
|
|
9
|
+
export declare function useUsdDiffValue([args1, args2]: [Args, Args]): UseQueryResult<number, Error>;
|
package/build/index.es.js
CHANGED
|
@@ -14,7 +14,7 @@ import { arbitrum, avalanche, base, bsc, celo, fantom, filecoin, kava, linea, ma
|
|
|
14
14
|
import { QueryClient, QueryClientProvider, useQuery, useMutation } from '@tanstack/react-query';
|
|
15
15
|
import { WalletProvider as WalletProvider$1, useWallet } from '@solana/wallet-adapter-react';
|
|
16
16
|
import { PhantomWalletAdapter, SolflareWalletAdapter, CoinbaseWalletAdapter, TrustWalletAdapter, LedgerWalletAdapter } from '@solana/wallet-adapter-wallets';
|
|
17
|
-
import {
|
|
17
|
+
import { SkipClient } from '@skip-go/client';
|
|
18
18
|
import { getWalletClient } from '@wagmi/core';
|
|
19
19
|
import { createContext, useContext, useMemo, useCallback, useRef, useState, useEffect, forwardRef, Fragment as Fragment$1 } from 'react';
|
|
20
20
|
import { create } from 'zustand';
|
|
@@ -24,6 +24,10 @@ import { ArrowTopRightOnSquareIcon, ArrowLeftIcon as ArrowLeftIcon$1, ChevronDow
|
|
|
24
24
|
import { ArrowLeftIcon, FaceFrownIcon, ChevronDownIcon, BackspaceIcon, TrashIcon, CubeIcon, ArrowRightIcon, ArrowTopRightOnSquareIcon as ArrowTopRightOnSquareIcon$1, CheckCircleIcon, ArrowPathIcon, XCircleIcon, CheckIcon, ClipboardDocumentIcon, ChevronRightIcon, ExclamationTriangleIcon, InformationCircleIcon, PencilSquareIcon as PencilSquareIcon$1, FingerPrintIcon, ArrowsUpDownIcon } from '@heroicons/react/20/solid';
|
|
25
25
|
import * as ScrollArea from '@radix-ui/react-scroll-area';
|
|
26
26
|
import toast, { Toaster } from 'react-hot-toast';
|
|
27
|
+
import { createPenumbraClient } from '@penumbra-zone/client';
|
|
28
|
+
import { ViewService } from '@penumbra-zone/protobuf';
|
|
29
|
+
import { bech32mAddress } from '@penumbra-zone/bech32m/penumbra';
|
|
30
|
+
import { bech32CompatAddress } from '@penumbra-zone/bech32m/penumbracompat1';
|
|
27
31
|
import { clsx } from 'clsx';
|
|
28
32
|
import { twMerge } from 'tailwind-merge';
|
|
29
33
|
import { styled, useTheme, StyleSheetManager, ThemeProvider } from 'styled-components';
|
|
@@ -311,7 +315,7 @@ const SkipContext = createContext(undefined);
|
|
|
311
315
|
function SkipProvider({ children, apiURL, endpointOptions, makeDestinationWallets, chainIDsToAffiliates, }) {
|
|
312
316
|
const { getWalletRepo } = useManager();
|
|
313
317
|
const { wallets } = useWallet();
|
|
314
|
-
const skipClient = new
|
|
318
|
+
const skipClient = new SkipClient({
|
|
315
319
|
chainIDsToAffiliates,
|
|
316
320
|
getCosmosSigner: async (chainID) => {
|
|
317
321
|
var _a, _b;
|
|
@@ -724,6 +728,15 @@ const PenumbraWalletListItem = ({ children, walletName, ...props }) => {
|
|
|
724
728
|
const defaultValues$3 = {};
|
|
725
729
|
const useCallbackStore = create()(() => defaultValues$3);
|
|
726
730
|
|
|
731
|
+
const penumbraBech32ChainIDs = ['noble-1', 'grand-1'];
|
|
732
|
+
const getPenumbraCompatibleAddress = ({ chainID, address, }) => {
|
|
733
|
+
if (!chainID)
|
|
734
|
+
return bech32mAddress(address);
|
|
735
|
+
return penumbraBech32ChainIDs.includes(chainID)
|
|
736
|
+
? bech32CompatAddress(address)
|
|
737
|
+
: bech32mAddress(address);
|
|
738
|
+
};
|
|
739
|
+
|
|
727
740
|
const useMakeWallets = () => {
|
|
728
741
|
const { data: chains } = useChains();
|
|
729
742
|
const { onWalletConnected, onWalletDisconnected } = useCallbackStore.getState();
|
|
@@ -747,6 +760,55 @@ const useMakeWallets = () => {
|
|
|
747
760
|
const chainType = (_a = getChain(chainID)) === null || _a === void 0 ? void 0 : _a.chainType;
|
|
748
761
|
let wallets = [];
|
|
749
762
|
if (chainType === 'cosmos') {
|
|
763
|
+
if (chainID.includes('penumbra')) {
|
|
764
|
+
const praxWallet = {
|
|
765
|
+
walletName: 'prax',
|
|
766
|
+
walletPrettyName: 'Prax Wallet',
|
|
767
|
+
walletInfo: {
|
|
768
|
+
logo: 'https://raw.githubusercontent.com/prax-wallet/web/e8b18f9b997708eab04f57e7a6c44f18b3cf13a8/apps/extension/public/prax-white-vertical.svg',
|
|
769
|
+
},
|
|
770
|
+
connect: async () => {
|
|
771
|
+
console.error('Prax wallet is not supported for connect');
|
|
772
|
+
toast.error('Prax wallet is not supported for connect');
|
|
773
|
+
},
|
|
774
|
+
getAddress: async ({ praxWallet }) => {
|
|
775
|
+
console.log('praxWallet', praxWallet);
|
|
776
|
+
const penumbraWalletIndex = praxWallet === null || praxWallet === void 0 ? void 0 : praxWallet.index;
|
|
777
|
+
const sourceChainID = praxWallet === null || praxWallet === void 0 ? void 0 : praxWallet.sourceChainID;
|
|
778
|
+
const prax_id = 'lkpmkhpnhknhmibgnmmhdhgdilepfghe';
|
|
779
|
+
const prax_origin = `chrome-extension://${prax_id}`;
|
|
780
|
+
const client = createPenumbraClient(prax_origin);
|
|
781
|
+
console.log(penumbraWalletIndex);
|
|
782
|
+
try {
|
|
783
|
+
await client.connect();
|
|
784
|
+
const viewService = client.service(ViewService);
|
|
785
|
+
const address = await viewService.addressByIndex({
|
|
786
|
+
addressIndex: {
|
|
787
|
+
account: penumbraWalletIndex ? penumbraWalletIndex : 0,
|
|
788
|
+
},
|
|
789
|
+
});
|
|
790
|
+
if (!address.address)
|
|
791
|
+
throw new Error('No address found');
|
|
792
|
+
const bech32Address = getPenumbraCompatibleAddress({
|
|
793
|
+
address: address.address,
|
|
794
|
+
chainID: sourceChainID,
|
|
795
|
+
});
|
|
796
|
+
return bech32Address;
|
|
797
|
+
}
|
|
798
|
+
catch (error) {
|
|
799
|
+
console.error(error);
|
|
800
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
801
|
+
// @ts-expect-error
|
|
802
|
+
toast.error(error === null || error === void 0 ? void 0 : error.message);
|
|
803
|
+
}
|
|
804
|
+
},
|
|
805
|
+
disconnect: async () => {
|
|
806
|
+
console.error('Prax wallet is not supported');
|
|
807
|
+
},
|
|
808
|
+
isWalletConnected: false,
|
|
809
|
+
};
|
|
810
|
+
return [praxWallet];
|
|
811
|
+
}
|
|
750
812
|
const chainName = chainIdToName(chainID);
|
|
751
813
|
const walletRepo = getWalletRepo(chainName);
|
|
752
814
|
wallets = walletRepo.wallets.map((wallet) => ({
|
|
@@ -3973,8 +4035,9 @@ const PraxWalletIndex = ({ praxWalletIndex, setPraxWalletIndex, }) => {
|
|
|
3973
4035
|
setPraxWalletIndex(Number(input));
|
|
3974
4036
|
setEditing(false);
|
|
3975
4037
|
};
|
|
3976
|
-
return isEditing ? (jsxs("div", { className: "flex items-center space-x-1 py-2 px-1", children: [jsx(StyledBorderDiv, { as: "input", type: "number", className: cn(`w-16 h-5.5 rounded-md border px-2 text-xs`), value: Number(input),
|
|
4038
|
+
return isEditing ? (jsxs("div", { className: "flex items-center space-x-1 py-2 px-1", children: [jsx(StyledBorderDiv, { as: "input", type: "number", className: cn(`w-16 h-5.5 rounded-md border px-2 text-xs`), value: Number(input), onClick: (e) => {
|
|
3977
4039
|
e.stopPropagation();
|
|
4040
|
+
}, onChange: (e) => {
|
|
3978
4041
|
if (Number(e.target.value) < 0) {
|
|
3979
4042
|
setInput(0);
|
|
3980
4043
|
return;
|
|
@@ -4067,6 +4130,7 @@ const SetAddressDialog = ({ open, onOpen, chain, index, signRequired, isDestinat
|
|
|
4067
4130
|
// currently only svm chainType that have isAvailable
|
|
4068
4131
|
return (jsxs(WalletListItem, { chainType: chainType, walletName: wallet.walletName, className: cn('group relative mb-2 data-[unsupported=true]:opacity-30', 'data-[unsupported=true]:before:absolute data-[unsupported=true]:before:inset-0 data-[unsupported=true]:before:cursor-not-allowed'), children: [jsxs(StyledThemedButton, { className: cn('flex w-full items-center gap-2 rounded-lg p-2 transition-colors focus:-outline-offset-2'), onClick: async () => {
|
|
4069
4132
|
var _a, _b;
|
|
4133
|
+
console.log('walletclicked', praxWalletIndex);
|
|
4070
4134
|
const resAddress = await ((_a = wallet.getAddress) === null || _a === void 0 ? void 0 : _a.call(wallet, {
|
|
4071
4135
|
signRequired,
|
|
4072
4136
|
context: isDestination ? 'destination' : 'recovery',
|
|
@@ -4162,7 +4226,8 @@ const useAutoSetAddress = ({ chain, chainID, index, enabled, signRequired, chain
|
|
|
4162
4226
|
if (index !== 0 &&
|
|
4163
4227
|
signRequired &&
|
|
4164
4228
|
(source === null || source === void 0 ? void 0 : source.chainType) === 'cosmos' &&
|
|
4165
|
-
cosmos
|
|
4229
|
+
cosmos &&
|
|
4230
|
+
!chain.chainID.includes('penumbra')) {
|
|
4166
4231
|
const walletSelected = wallets.find((wallet) => wallet.walletName === (cosmos === null || cosmos === void 0 ? void 0 : cosmos.walletName));
|
|
4167
4232
|
const address = await ((_a = walletSelected === null || walletSelected === void 0 ? void 0 : walletSelected.getAddress) === null || _a === void 0 ? void 0 : _a.call(walletSelected, { signRequired }));
|
|
4168
4233
|
if (walletSelected && address) {
|
|
@@ -4180,7 +4245,8 @@ const useAutoSetAddress = ({ chain, chainID, index, enabled, signRequired, chain
|
|
|
4180
4245
|
(destination === null || destination === void 0 ? void 0 : destination.chainType) === 'cosmos' &&
|
|
4181
4246
|
(destination === null || destination === void 0 ? void 0 : destination.source) !== 'input' &&
|
|
4182
4247
|
index !== 0 &&
|
|
4183
|
-
!signRequired
|
|
4248
|
+
!signRequired &&
|
|
4249
|
+
!chain.chainID.includes('penumbra')) {
|
|
4184
4250
|
const walletName = (_b = destination.source) === null || _b === void 0 ? void 0 : _b.walletName;
|
|
4185
4251
|
const walletSelected = wallets.find((wallet) => wallet.walletName === walletName);
|
|
4186
4252
|
const address = await ((_c = walletSelected === null || walletSelected === void 0 ? void 0 : walletSelected.getAddress) === null || _c === void 0 ? void 0 : _c.call(walletSelected, {}));
|