hyperliquid-deposit 1.0.0 → 1.0.1
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/dist/index.d.ts +11 -1
- package/dist/index.js +40 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -86,6 +86,11 @@ interface HyperliquidDepositProps {
|
|
|
86
86
|
modal?: React.CSSProperties;
|
|
87
87
|
overlay?: React.CSSProperties;
|
|
88
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* Optional: External wallet provider (e.g., from WalletConnect)
|
|
91
|
+
* Required for environments without window.ethereum (like Telegram mini apps)
|
|
92
|
+
*/
|
|
93
|
+
walletProvider?: any;
|
|
89
94
|
}
|
|
90
95
|
/**
|
|
91
96
|
* HyperliquidDeposit - A one-click deposit button for HyperLiquid
|
|
@@ -262,6 +267,11 @@ interface DetailedBridgeProgress {
|
|
|
262
267
|
txHash?: string;
|
|
263
268
|
txLink?: string;
|
|
264
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* Set an external wallet provider (e.g., from WalletConnect)
|
|
272
|
+
* This should be called before any bridge operations in environments without window.ethereum
|
|
273
|
+
*/
|
|
274
|
+
declare function setWalletProvider(provider: any): void;
|
|
265
275
|
declare class LiFiBridgeService {
|
|
266
276
|
private chains;
|
|
267
277
|
constructor();
|
|
@@ -318,4 +328,4 @@ declare function sortByMarketCap<T extends {
|
|
|
318
328
|
symbol: string;
|
|
319
329
|
}>(tokens: T[]): T[];
|
|
320
330
|
|
|
321
|
-
export { type BridgeParams, type BridgeProgress, type BridgeWidgetStyles, type ChainBalance, type ChainInfo, ChainTokenSelector, DepositModal, type DetailedBridgeProgress, HYPERLIQUID_BRIDGE_ADDRESS, HyperliquidDeposit, type HyperliquidDepositProps, HyprBridgeWidget, type HyprBridgeWidgetProps, LiFiBridgeService, MIN_HYPERLIQUID_DEPOSIT_USD, type SearchableToken, type StepInfo, TOP_TOKENS_BY_MARKETCAP, TokenSearchService, type WalletState, getTokenRank, isTopToken, sortByMarketCap, useHyperliquidDeposit };
|
|
331
|
+
export { type BridgeParams, type BridgeProgress, type BridgeWidgetStyles, type ChainBalance, type ChainInfo, ChainTokenSelector, DepositModal, type DetailedBridgeProgress, HYPERLIQUID_BRIDGE_ADDRESS, HyperliquidDeposit, type HyperliquidDepositProps, HyprBridgeWidget, type HyprBridgeWidgetProps, LiFiBridgeService, MIN_HYPERLIQUID_DEPOSIT_USD, type SearchableToken, type StepInfo, TOP_TOKENS_BY_MARKETCAP, TokenSearchService, type WalletState, getTokenRank, isTopToken, setWalletProvider, sortByMarketCap, useHyperliquidDeposit };
|
package/dist/index.js
CHANGED
|
@@ -180,6 +180,21 @@ var init_wallet = __esm({
|
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
182
|
var sdkInitialized = false;
|
|
183
|
+
var externalWalletProvider = null;
|
|
184
|
+
function setWalletProvider(provider) {
|
|
185
|
+
externalWalletProvider = provider;
|
|
186
|
+
sdkInitialized = false;
|
|
187
|
+
console.log("\u{1F50C} External wallet provider set");
|
|
188
|
+
}
|
|
189
|
+
function getWalletProvider() {
|
|
190
|
+
if (externalWalletProvider) {
|
|
191
|
+
return externalWalletProvider;
|
|
192
|
+
}
|
|
193
|
+
if (typeof window !== "undefined" && window.ethereum) {
|
|
194
|
+
return window.ethereum;
|
|
195
|
+
}
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
183
198
|
var LiFiBridgeService = class {
|
|
184
199
|
chains = [];
|
|
185
200
|
constructor() {
|
|
@@ -194,37 +209,39 @@ var LiFiBridgeService = class {
|
|
|
194
209
|
// EVM chains (Ethereum, Arbitrum, Base, Polygon, etc.)
|
|
195
210
|
EVM({
|
|
196
211
|
getWalletClient: async () => {
|
|
197
|
-
|
|
198
|
-
|
|
212
|
+
const provider = getWalletProvider();
|
|
213
|
+
if (!provider) {
|
|
214
|
+
throw new Error("No wallet provider found. Please connect a wallet first.");
|
|
199
215
|
}
|
|
200
|
-
const accounts = await
|
|
216
|
+
const accounts = await provider.request({
|
|
201
217
|
method: "eth_requestAccounts"
|
|
202
218
|
});
|
|
203
|
-
const chainIdHex = await
|
|
219
|
+
const chainIdHex = await provider.request({
|
|
204
220
|
method: "eth_chainId"
|
|
205
221
|
});
|
|
206
222
|
const currentChainId = parseInt(chainIdHex, 16);
|
|
207
223
|
return createWalletClient({
|
|
208
224
|
account: accounts[0],
|
|
209
225
|
chain: { id: currentChainId },
|
|
210
|
-
transport: custom(
|
|
226
|
+
transport: custom(provider)
|
|
211
227
|
});
|
|
212
228
|
},
|
|
213
229
|
switchChain: async (chainId) => {
|
|
214
|
-
|
|
215
|
-
|
|
230
|
+
const provider = getWalletProvider();
|
|
231
|
+
if (!provider) {
|
|
232
|
+
throw new Error("No wallet provider found. Please connect a wallet first.");
|
|
216
233
|
}
|
|
217
|
-
await
|
|
234
|
+
await provider.request({
|
|
218
235
|
method: "wallet_switchEthereumChain",
|
|
219
236
|
params: [{ chainId: `0x${chainId.toString(16)}` }]
|
|
220
237
|
});
|
|
221
|
-
const accounts = await
|
|
238
|
+
const accounts = await provider.request({
|
|
222
239
|
method: "eth_requestAccounts"
|
|
223
240
|
});
|
|
224
241
|
return createWalletClient({
|
|
225
242
|
account: accounts[0],
|
|
226
243
|
chain: { id: chainId },
|
|
227
|
-
transport: custom(
|
|
244
|
+
transport: custom(provider)
|
|
228
245
|
});
|
|
229
246
|
}
|
|
230
247
|
}),
|
|
@@ -2491,8 +2508,7 @@ var DepositModal = ({
|
|
|
2491
2508
|
style: {
|
|
2492
2509
|
position: "absolute",
|
|
2493
2510
|
inset: 0,
|
|
2494
|
-
background:
|
|
2495
|
-
backdropFilter: "blur(8px)",
|
|
2511
|
+
background: COLORS.ebony,
|
|
2496
2512
|
cursor: step === "executing" || step === "depositing" ? "not-allowed" : "pointer"
|
|
2497
2513
|
}
|
|
2498
2514
|
}
|
|
@@ -2594,11 +2610,17 @@ var HyperliquidDeposit = ({
|
|
|
2594
2610
|
buttonStyle,
|
|
2595
2611
|
buttonClassName,
|
|
2596
2612
|
disabled = false,
|
|
2597
|
-
modalStyles
|
|
2613
|
+
modalStyles,
|
|
2614
|
+
walletProvider
|
|
2598
2615
|
}) => {
|
|
2599
2616
|
const [isOpen, setIsOpen] = useState(false);
|
|
2600
2617
|
const [chains, setChains] = useState(customChains || []);
|
|
2601
2618
|
const [isLoading, setIsLoading] = useState(!customChains);
|
|
2619
|
+
useEffect(() => {
|
|
2620
|
+
if (walletProvider) {
|
|
2621
|
+
setWalletProvider(walletProvider);
|
|
2622
|
+
}
|
|
2623
|
+
}, [walletProvider]);
|
|
2602
2624
|
useEffect(() => {
|
|
2603
2625
|
if (customChains) {
|
|
2604
2626
|
setChains(customChains);
|
|
@@ -2621,9 +2643,12 @@ var HyperliquidDeposit = ({
|
|
|
2621
2643
|
}, [customChains]);
|
|
2622
2644
|
const handleOpen = useCallback(() => {
|
|
2623
2645
|
if (!disabled && !isLoading && walletAddress) {
|
|
2646
|
+
if (walletProvider) {
|
|
2647
|
+
setWalletProvider(walletProvider);
|
|
2648
|
+
}
|
|
2624
2649
|
setIsOpen(true);
|
|
2625
2650
|
}
|
|
2626
|
-
}, [disabled, isLoading, walletAddress]);
|
|
2651
|
+
}, [disabled, isLoading, walletAddress, walletProvider]);
|
|
2627
2652
|
const handleClose = useCallback(() => {
|
|
2628
2653
|
setIsOpen(false);
|
|
2629
2654
|
}, []);
|
|
@@ -5146,6 +5171,6 @@ var HyprBridgeWidget = ({ styles }) => {
|
|
|
5146
5171
|
] });
|
|
5147
5172
|
};
|
|
5148
5173
|
|
|
5149
|
-
export { ChainTokenSelector, DepositModal, HYPERLIQUID_BRIDGE_ADDRESS, HyperliquidDeposit, HyprBridgeWidget, LiFiBridgeService, MIN_HYPERLIQUID_DEPOSIT_USD, TOP_TOKENS_BY_MARKETCAP, TokenSearchService, getTokenRank, isTopToken, sortByMarketCap, useHyperliquidDeposit };
|
|
5174
|
+
export { ChainTokenSelector, DepositModal, HYPERLIQUID_BRIDGE_ADDRESS, HyperliquidDeposit, HyprBridgeWidget, LiFiBridgeService, MIN_HYPERLIQUID_DEPOSIT_USD, TOP_TOKENS_BY_MARKETCAP, TokenSearchService, getTokenRank, isTopToken, setWalletProvider, sortByMarketCap, useHyperliquidDeposit };
|
|
5150
5175
|
//# sourceMappingURL=index.js.map
|
|
5151
5176
|
//# sourceMappingURL=index.js.map
|