@hfunlabs/hypurr-connect 0.1.14 → 0.1.15
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 +12 -0
- package/dist/index.d.ts +86 -3
- package/dist/index.js +1834 -337
- package/dist/index.js.map +1 -1
- package/package.json +17 -6
- package/src/AddWalletModal.tsx +744 -0
- package/src/AgentExpiryWarning.tsx +129 -0
- package/src/DeleteWalletModal.tsx +5 -1
- package/src/HypurrConnectProvider.tsx +190 -0
- package/src/LoginModal.tsx +11 -11
- package/src/RenameWalletModal.tsx +5 -1
- package/src/RenewAgentModal.tsx +380 -0
- package/src/UserProfileModal.tsx +157 -25
- package/src/WalletSelectorDropdown.tsx +146 -6
- package/src/agent.ts +38 -12
- package/src/agentWallet.ts +86 -0
- package/src/css.d.ts +1 -0
- package/src/icons/lucide.tsx +61 -0
- package/src/index.ts +17 -1
- package/src/profileStyles.ts +58 -0
- package/src/styles.css +1 -0
- package/src/tailwind.css +77 -0
- package/src/types.ts +13 -0
package/README.md
CHANGED
|
@@ -286,6 +286,7 @@ const {
|
|
|
286
286
|
selectWallet,
|
|
287
287
|
createWallet,
|
|
288
288
|
deleteWallet,
|
|
289
|
+
renewAgentWallet,
|
|
289
290
|
refreshWallets,
|
|
290
291
|
} = useHypurrConnect();
|
|
291
292
|
|
|
@@ -305,6 +306,15 @@ const newWallet = await createWallet("Trading");
|
|
|
305
306
|
|
|
306
307
|
// Delete a wallet (auto-selects another if the deleted one was active)
|
|
307
308
|
await deleteWallet(walletId);
|
|
309
|
+
|
|
310
|
+
// Renew an expiring agent wallet after connecting the owner EOA wallet
|
|
311
|
+
await renewAgentWallet({
|
|
312
|
+
walletId,
|
|
313
|
+
ownerAddress: address,
|
|
314
|
+
signTypedDataAsync,
|
|
315
|
+
chainId,
|
|
316
|
+
approvalDurationMs: 7 * 24 * 60 * 60 * 1000,
|
|
317
|
+
});
|
|
308
318
|
```
|
|
309
319
|
|
|
310
320
|
#### Wallet Packs & Labels
|
|
@@ -389,6 +399,7 @@ Returns the full auth and exchange state. Throws if used outside `HypurrConnectP
|
|
|
389
399
|
| `selectWallet` | `(walletId: number) => void` | Switch the active wallet |
|
|
390
400
|
| `createWallet` | `(name: string) => Promise<HyperliquidWallet>` | Create a new wallet (Telegram only) |
|
|
391
401
|
| `deleteWallet` | `(walletId: number) => Promise<void>` | Delete a wallet (Telegram only) |
|
|
402
|
+
| `renewAgentWallet` | `(params: RenewAgentWalletParams) => Promise<void>` | Renew a Telegram agent wallet by approving the existing agent address with an owner EOA |
|
|
392
403
|
| `refreshWallets` | `() => void` | Re-fetch wallets and packs from the server |
|
|
393
404
|
| `packs` | `TelegramChatWalletPack[]` | Wallet packs for the Telegram user |
|
|
394
405
|
| `createWalletPack` | `(name: string) => Promise<number>` | Create a wallet pack; returns the new pack ID |
|
|
@@ -467,6 +478,7 @@ interface HyperliquidWallet {
|
|
|
467
478
|
name: string;
|
|
468
479
|
ethereumAddress: string;
|
|
469
480
|
isAgent: boolean;
|
|
481
|
+
agentExpiresAt?: Timestamp;
|
|
470
482
|
isReadOnly: boolean;
|
|
471
483
|
// ... plus balances, movements, sessions
|
|
472
484
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -105,6 +105,17 @@ interface EoaSignerOptions {
|
|
|
105
105
|
signTransaction?: EoaSignTransactionFn;
|
|
106
106
|
request?: EvmRequestFn;
|
|
107
107
|
}
|
|
108
|
+
interface RenewAgentWalletParams {
|
|
109
|
+
walletId: number;
|
|
110
|
+
/** Connected owner wallet address that will sign the approveAgent transaction. */
|
|
111
|
+
ownerAddress: Hex;
|
|
112
|
+
signTypedDataAsync: SignTypedDataFn;
|
|
113
|
+
chainId: number;
|
|
114
|
+
/** Approval length used when `agentName` is omitted. Defaults to 1 day. */
|
|
115
|
+
approvalDurationMs?: number;
|
|
116
|
+
/** Hyperliquid agent name to approve. Defaults to the Telegram agent-wallet valid_until name. */
|
|
117
|
+
agentName?: string;
|
|
118
|
+
}
|
|
108
119
|
/**
|
|
109
120
|
* Create an {@link EoaSigner} from any EIP-712 signing function.
|
|
110
121
|
*
|
|
@@ -147,6 +158,7 @@ interface HypurrConnectState {
|
|
|
147
158
|
createWallet: (name: string) => Promise<HyperliquidWallet>;
|
|
148
159
|
deleteWallet: (walletId: number) => Promise<void>;
|
|
149
160
|
renameWallet: (walletId: number, name: string) => Promise<void>;
|
|
161
|
+
renewAgentWallet: (params: RenewAgentWalletParams) => Promise<void>;
|
|
150
162
|
refreshWallets: () => void;
|
|
151
163
|
packs: TelegramChatWalletPack[];
|
|
152
164
|
createWalletPack: (name: string) => Promise<number>;
|
|
@@ -201,6 +213,59 @@ interface LoginModalProps {
|
|
|
201
213
|
}
|
|
202
214
|
declare function LoginModal({ onConnectWallet, walletIcon, backgroundColor, }: LoginModalProps): react_jsx_runtime.JSX.Element;
|
|
203
215
|
|
|
216
|
+
interface AgentApprovalDurationOption {
|
|
217
|
+
label: string;
|
|
218
|
+
durationMs: number;
|
|
219
|
+
}
|
|
220
|
+
declare const DEFAULT_AGENT_APPROVAL_DURATION_MS: number;
|
|
221
|
+
declare const AGENT_APPROVAL_DURATION_OPTIONS: AgentApprovalDurationOption[];
|
|
222
|
+
declare function createTelegramAgentApprovalName(durationMs?: number): string;
|
|
223
|
+
|
|
224
|
+
interface AddWalletModalProps {
|
|
225
|
+
isOpen: boolean;
|
|
226
|
+
onClose: () => void;
|
|
227
|
+
ownerAddress?: string | null;
|
|
228
|
+
isWalletConnected?: boolean;
|
|
229
|
+
chainId?: number;
|
|
230
|
+
signTypedDataAsync?: SignTypedDataFn;
|
|
231
|
+
onConnectWallet?: () => void;
|
|
232
|
+
onDisconnectWallet?: () => void;
|
|
233
|
+
onWalletAdded?: (wallet?: HyperliquidWallet) => void | Promise<void>;
|
|
234
|
+
onAddReadOnlyWallet?: (address: string) => void | Promise<void>;
|
|
235
|
+
onNotify?: (n: {
|
|
236
|
+
type: "success" | "error";
|
|
237
|
+
message: string;
|
|
238
|
+
}) => void;
|
|
239
|
+
hyperliquidChain?: "Mainnet" | "Testnet" | string;
|
|
240
|
+
/** Expiration choices for owner-approved agent wallets. Defaults to 1/7/30/90 days. */
|
|
241
|
+
agentApprovalDurationOptions?: AgentApprovalDurationOption[];
|
|
242
|
+
/** Initial owner approval duration. Defaults to 1 day. */
|
|
243
|
+
defaultAgentApprovalDurationMs?: number;
|
|
244
|
+
}
|
|
245
|
+
declare function AddWalletModal({ isOpen, onClose, ownerAddress, isWalletConnected, chainId, signTypedDataAsync, onConnectWallet, onDisconnectWallet, onWalletAdded, onAddReadOnlyWallet, onNotify, hyperliquidChain, agentApprovalDurationOptions, defaultAgentApprovalDurationMs, }: AddWalletModalProps): ReactNode;
|
|
246
|
+
|
|
247
|
+
interface RenewAgentModalProps {
|
|
248
|
+
isOpen: boolean;
|
|
249
|
+
onClose: () => void;
|
|
250
|
+
wallet: HyperliquidWallet | null;
|
|
251
|
+
ownerAddress?: string | null;
|
|
252
|
+
isWalletConnected?: boolean;
|
|
253
|
+
chainId?: number;
|
|
254
|
+
signTypedDataAsync?: SignTypedDataFn;
|
|
255
|
+
onConnectWallet?: () => void;
|
|
256
|
+
onDisconnectWallet?: () => void;
|
|
257
|
+
onRenewed?: (wallet: HyperliquidWallet) => void | Promise<void>;
|
|
258
|
+
onNotify?: (n: {
|
|
259
|
+
type: "success" | "error";
|
|
260
|
+
message: string;
|
|
261
|
+
}) => void;
|
|
262
|
+
/** Expiration choices for the renewed owner approval. Defaults to 1/7/30/90 days. */
|
|
263
|
+
approvalDurationOptions?: AgentApprovalDurationOption[];
|
|
264
|
+
/** Initial renewal approval duration. Defaults to 1 day. */
|
|
265
|
+
defaultApprovalDurationMs?: number;
|
|
266
|
+
}
|
|
267
|
+
declare function RenewAgentModal({ isOpen, onClose, wallet, ownerAddress, isWalletConnected, chainId, signTypedDataAsync, onConnectWallet, onDisconnectWallet, onRenewed, onNotify, approvalDurationOptions, defaultApprovalDurationMs, }: RenewAgentModalProps): ReactNode;
|
|
268
|
+
|
|
204
269
|
interface PrincipalColors {
|
|
205
270
|
accent: string;
|
|
206
271
|
accentText: string;
|
|
@@ -243,6 +308,8 @@ interface UserProfileModalProps {
|
|
|
243
308
|
* portfolio UI in response.
|
|
244
309
|
*/
|
|
245
310
|
onShowPortfolio?: (wallet: HyperliquidWallet) => void;
|
|
311
|
+
/** Called when the user clicks an agent wallet renew action. Host should connect the owner wallet and call `renewAgentWallet`. */
|
|
312
|
+
onRenewAgentWallet?: (wallet: HyperliquidWallet) => void;
|
|
246
313
|
/** Optional toast callback. SDK fires success on rename/delete; errors stay inline in sub-modals. */
|
|
247
314
|
onNotify?: (n: {
|
|
248
315
|
type: "success" | "error";
|
|
@@ -253,7 +320,7 @@ interface UserProfileModalProps {
|
|
|
253
320
|
/** Principal accent colors used for switches, action text, and wallet icon surfaces. */
|
|
254
321
|
principalColors?: PrincipalColorOverrides;
|
|
255
322
|
}
|
|
256
|
-
declare function UserProfileModal({ isOpen, onClose, animationsEnabled, onToggleAnimations, defaultSlippage, onSlippageChange, slippageOptions, onWalletDeleted, onWalletRenamed, onShowPortfolio, onNotify, accentColor, principalColors, }: UserProfileModalProps): ReactNode;
|
|
323
|
+
declare function UserProfileModal({ isOpen, onClose, animationsEnabled, onToggleAnimations, defaultSlippage, onSlippageChange, slippageOptions, onWalletDeleted, onWalletRenamed, onShowPortfolio, onRenewAgentWallet, onNotify, accentColor, principalColors, }: UserProfileModalProps): ReactNode;
|
|
257
324
|
|
|
258
325
|
interface WalletSelectorDropdownProps {
|
|
259
326
|
isOpen: boolean;
|
|
@@ -262,6 +329,8 @@ interface WalletSelectorDropdownProps {
|
|
|
262
329
|
onAddWallet?: () => void;
|
|
263
330
|
/** Called when the user clicks the portfolio icon on a wallet row. */
|
|
264
331
|
onShowPortfolio?: (wallet: HyperliquidWallet) => void;
|
|
332
|
+
/** Called when the user clicks an agent wallet renew action. Host should connect the owner wallet and call `renewAgentWallet`. */
|
|
333
|
+
onRenewAgentWallet?: (wallet: HyperliquidWallet) => void;
|
|
265
334
|
/**
|
|
266
335
|
* Called before the SDK's `logout()` runs. Host can do extra cleanup
|
|
267
336
|
* (e.g. wagmi `disconnect()`).
|
|
@@ -294,8 +363,22 @@ interface WalletSelectorDropdownProps {
|
|
|
294
363
|
principalColors?: PrincipalColorOverrides;
|
|
295
364
|
/** CSS color used as the dropdown panel background. Defaults to `rgba(20,20,20,0.95)`. */
|
|
296
365
|
backgroundColor?: string;
|
|
366
|
+
/** Extra footer rows rendered between "Profile & Settings" and "Logout". */
|
|
367
|
+
extraFooterItems?: ExtraFooterItem[];
|
|
368
|
+
}
|
|
369
|
+
interface ExtraFooterItem {
|
|
370
|
+
/** Stable key for React reconciliation. */
|
|
371
|
+
key: string;
|
|
372
|
+
/** Leading icon (e.g. an icon from `./icons/lucide`). */
|
|
373
|
+
icon: ReactNode;
|
|
374
|
+
/** Row label. */
|
|
375
|
+
label: string;
|
|
376
|
+
/** Click handler. The dropdown is NOT auto-closed — call `onClose` yourself if desired. */
|
|
377
|
+
onClick: () => void;
|
|
378
|
+
/** Optional hover text color (matches the "Logout" red-on-hover pattern). */
|
|
379
|
+
hoverColor?: string;
|
|
297
380
|
}
|
|
298
|
-
declare function WalletSelectorDropdown({ isOpen, onClose, onAddWallet, onShowPortfolio, onLogout, onNotify, vipThreshold, animationsEnabled, onToggleAnimations, defaultSlippage, onSlippageChange, slippageOptions, onWalletDeleted, onWalletRenamed, accentColor, principalColors, backgroundColor, }: WalletSelectorDropdownProps): ReactNode;
|
|
381
|
+
declare function WalletSelectorDropdown({ isOpen, onClose, onAddWallet, onShowPortfolio, onRenewAgentWallet, onLogout, onNotify, vipThreshold, animationsEnabled, onToggleAnimations, defaultSlippage, onSlippageChange, slippageOptions, onWalletDeleted, onWalletRenamed, accentColor, principalColors, backgroundColor, extraFooterItems, }: WalletSelectorDropdownProps): ReactNode;
|
|
299
382
|
|
|
300
383
|
interface DeleteWalletModalProps {
|
|
301
384
|
isOpen: boolean;
|
|
@@ -367,4 +450,4 @@ declare class PrivateKeySigner implements AbstractViemLocalAccount {
|
|
|
367
450
|
signTypedData(params: SignTypedDataParams): Promise<Hex>;
|
|
368
451
|
}
|
|
369
452
|
|
|
370
|
-
export { type AuthMethod, DeleteWalletModal, type DeleteWalletModalProps, type EoaSignTransactionFn, type EoaSigner, type EoaSignerOptions, type EvmRequestFn, type EvmTransactionRequest, GrpcExchangeTransport, type GrpcExchangeTransportConfig, type Hex, type HypurrConnectConfig, HypurrConnectProvider, type HypurrConnectState, type HypurrUser, LoginModal, type LoginModalProps, type PrincipalColorOverrides, type PrincipalColors, PrivateKeySigner, RenameWalletModal, type RenameWalletModalProps, type ScaleCreateParams, type SignEvmTransactionFn, type SignTypedDataFn, type SlippageOption, type StoredAgent, type TelegramLoginData, type TwapCreateParams, type TwapModifyParams, UserProfileModal, type UserProfileModalProps, WalletSelectorDropdown, type WalletSelectorDropdownProps, createEoaSigner, createStaticClient, createTelegramClient, useHypurrConnect };
|
|
453
|
+
export { AGENT_APPROVAL_DURATION_OPTIONS, AddWalletModal, type AddWalletModalProps, type AgentApprovalDurationOption, type AuthMethod, DEFAULT_AGENT_APPROVAL_DURATION_MS, DeleteWalletModal, type DeleteWalletModalProps, type EoaSignTransactionFn, type EoaSigner, type EoaSignerOptions, type EvmRequestFn, type EvmTransactionRequest, type ExtraFooterItem, GrpcExchangeTransport, type GrpcExchangeTransportConfig, type Hex, type HypurrConnectConfig, HypurrConnectProvider, type HypurrConnectState, type HypurrUser, LoginModal, type LoginModalProps, type PrincipalColorOverrides, type PrincipalColors, PrivateKeySigner, RenameWalletModal, type RenameWalletModalProps, RenewAgentModal, type RenewAgentModalProps, type RenewAgentWalletParams, type ScaleCreateParams, type SignEvmTransactionFn, type SignTypedDataFn, type SlippageOption, type StoredAgent, type TelegramLoginData, type TwapCreateParams, type TwapModifyParams, UserProfileModal, type UserProfileModalProps, WalletSelectorDropdown, type WalletSelectorDropdownProps, createEoaSigner, createStaticClient, createTelegramAgentApprovalName, createTelegramClient, useHypurrConnect };
|