@hfunlabs/hypurr-connect 0.1.13 → 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 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>;
@@ -196,8 +208,63 @@ declare function HypurrConnectProvider({ config, children, }: {
196
208
  interface LoginModalProps {
197
209
  onConnectWallet: () => void;
198
210
  walletIcon?: ReactNode;
211
+ /** CSS color used as the modal/drawer background. Defaults to `rgba(20,20,20,0.95)`. */
212
+ backgroundColor?: string;
213
+ }
214
+ declare function LoginModal({ onConnectWallet, walletIcon, backgroundColor, }: LoginModalProps): react_jsx_runtime.JSX.Element;
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;
199
244
  }
200
- declare function LoginModal({ onConnectWallet, walletIcon }: LoginModalProps): react_jsx_runtime.JSX.Element;
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;
201
268
 
202
269
  interface PrincipalColors {
203
270
  accent: string;
@@ -241,6 +308,8 @@ interface UserProfileModalProps {
241
308
  * portfolio UI in response.
242
309
  */
243
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;
244
313
  /** Optional toast callback. SDK fires success on rename/delete; errors stay inline in sub-modals. */
245
314
  onNotify?: (n: {
246
315
  type: "success" | "error";
@@ -251,7 +320,7 @@ interface UserProfileModalProps {
251
320
  /** Principal accent colors used for switches, action text, and wallet icon surfaces. */
252
321
  principalColors?: PrincipalColorOverrides;
253
322
  }
254
- 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;
255
324
 
256
325
  interface WalletSelectorDropdownProps {
257
326
  isOpen: boolean;
@@ -260,6 +329,8 @@ interface WalletSelectorDropdownProps {
260
329
  onAddWallet?: () => void;
261
330
  /** Called when the user clicks the portfolio icon on a wallet row. */
262
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;
263
334
  /**
264
335
  * Called before the SDK's `logout()` runs. Host can do extra cleanup
265
336
  * (e.g. wagmi `disconnect()`).
@@ -292,8 +363,22 @@ interface WalletSelectorDropdownProps {
292
363
  principalColors?: PrincipalColorOverrides;
293
364
  /** CSS color used as the dropdown panel background. Defaults to `rgba(20,20,20,0.95)`. */
294
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;
295
380
  }
296
- 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;
297
382
 
298
383
  interface DeleteWalletModalProps {
299
384
  isOpen: boolean;
@@ -365,4 +450,4 @@ declare class PrivateKeySigner implements AbstractViemLocalAccount {
365
450
  signTypedData(params: SignTypedDataParams): Promise<Hex>;
366
451
  }
367
452
 
368
- 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 };