superstack-wallet-sdk 0.5.7 → 0.5.8

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 CHANGED
@@ -7,7 +7,7 @@ import react__default, { ReactNode } from 'react';
7
7
  type SupportedTransactionVersions = ReadonlySet<TransactionVersion> | null | undefined;
8
8
  type TransactionOrVersionedTransaction<S extends SupportedTransactionVersions> = S extends null | undefined ? Transaction : Transaction | VersionedTransaction;
9
9
  declare function isVersionedTransaction(transaction: Transaction | VersionedTransaction): transaction is VersionedTransaction;
10
- type LoginType = "TwitterOAuth" | "GoogleOAuth" | "Phantom" | "Okx" | "Email" | "Phone" | "Telegram" | "TelegramOAuth" | "MetaMask" | "Rabby" | "Coinbase" | "WalletConnect";
10
+ type LoginType = "Email" | "Phone" | "TwitterOAuth" | "GoogleOAuth" | "Telegram" | "TelegramOAuth" | "Apple" | "Phantom" | "Okx" | "MetaMask" | "Rabby" | "Coinbase" | "WalletConnect";
11
11
  declare enum Network {
12
12
  Solana = "Solana",
13
13
  Ethereum = "Ethereum"
@@ -17,12 +17,10 @@ declare enum WalletType {
17
17
  Embedded = "Embedded"
18
18
  }
19
19
  declare enum SocialType {
20
- Email = "Email",
21
20
  Google = "Google",
22
21
  Twitter = "Twitter",
23
- Phantom = "Phantom",
24
- Phone = "Phone",
25
- Okx = "Okx"
22
+ Telegram = "Telegram",
23
+ Apple = "Apple"
26
24
  }
27
25
  type Social = {
28
26
  [key in SocialType]: string;
@@ -43,36 +41,72 @@ interface Wallet {
43
41
  address: string;
44
42
  network: Network;
45
43
  wallet_type: WalletType;
46
- wallet_set: "Main" | "Forward-0" | string;
44
+ wallet_set: "Main" | `Forward-${number}` | `Secondary-${number}` | `SecondaryForward-${number}-${number}`;
45
+ account_index: number;
46
+ is_enabled: boolean;
47
47
  }
48
48
  interface WalletInfo {
49
- account_info: AccountInfo;
50
49
  id: string;
51
- is_exported: boolean;
52
50
  wallets: Wallet[];
53
51
  social_links: Social[];
54
52
  social_infos: SocialInfo[];
53
+ account_info: AccountInfo;
54
+ created_at: number;
55
+ is_exported: boolean;
55
56
  access_token?: string;
56
57
  }
58
+ interface SubAccountInfo {
59
+ account_index: number;
60
+ secondary_index: number;
61
+ name?: string;
62
+ created_at: number;
63
+ is_exported: boolean;
64
+ is_enabled: boolean;
65
+ }
57
66
  interface AccountInfo {
58
67
  name: string | null;
68
+ sub_accounts: SubAccountInfo[];
59
69
  }
70
+ type MultiAccountRequest = {
71
+ type: "Create";
72
+ data: {
73
+ name?: string | null;
74
+ };
75
+ } | {
76
+ type: "Enable";
77
+ data: {
78
+ index: number;
79
+ };
80
+ } | {
81
+ type: "Disable";
82
+ data: {
83
+ index: number;
84
+ };
85
+ };
60
86
  interface SignRequestV1 {
87
+ user_id: string;
88
+ network: string;
61
89
  address: string;
62
- userId: string;
63
90
  message: string;
64
- network: string;
65
- requestId: string;
66
91
  }
67
- interface UnsignedTx {
92
+ interface UnsignedTxV2 {
68
93
  Solana?: string;
69
94
  EthereumEip712?: Record<string, unknown>;
70
95
  }
71
96
  interface SignRequestV2 {
97
+ user_id: string;
98
+ network: string;
72
99
  address: string;
100
+ tx: UnsignedTxV2;
101
+ }
102
+ interface UnsignedTxV3 {
103
+ Solana?: string;
104
+ }
105
+ interface SignRequestV3 {
73
106
  user_id: string;
74
107
  network: string;
75
- tx: UnsignedTx;
108
+ address: string;
109
+ tx: UnsignedTxV3;
76
110
  }
77
111
  interface UserSession {
78
112
  id: string;
@@ -138,13 +172,13 @@ interface OrderState {
138
172
  }
139
173
  interface TransferRequest {
140
174
  user_id: string;
175
+ network: Network;
176
+ chain_id: number;
141
177
  from: string;
142
178
  to: string;
143
179
  amount: string;
144
180
  decimals: number;
145
181
  token?: string;
146
- network: Network;
147
- chain_id: number;
148
182
  }
149
183
  declare enum VaultId {
150
184
  HyperbeatUltraHype = "HyperbeatUltraHype",
@@ -238,138 +272,6 @@ interface BuildTransactionResponse {
238
272
  raw_transaction: string;
239
273
  metadata?: any;
240
274
  }
241
- type BigDecimalString = string;
242
- declare enum BorrowedAsset {
243
- HypercorePerpsUSDC = "HypercorePerpsUSDC"
244
- }
245
- declare enum CollateralAsset {
246
- HypercoreSpotBTC = "HypercoreSpotBTC"
247
- }
248
- declare enum CrossMarginPositionStatus {
249
- Open = "Open",
250
- Closed = "Closed",
251
- PartiallyLiquidated = "PartiallyLiquidated",
252
- AllLiquidated = "AllLiquidated"
253
- }
254
- declare enum CrossMarginOperationType {
255
- Borrow = "Borrow",
256
- Repay = "Repay",
257
- AddMargin = "AddMargin",
258
- RemoveMargin = "RemoveMargin",
259
- Liquidation = "Liquidation"
260
- }
261
- interface CollateralAssetInfo {
262
- amount: BigDecimalString;
263
- contribution?: number;
264
- liquidation_price?: number;
265
- }
266
- interface CrossMarginBorrowQuoteRequest {
267
- collateral_assets: Partial<Record<CollateralAsset, BigDecimalString>>;
268
- }
269
- interface CrossMarginBorrowQuoteResponse {
270
- quote_id: string;
271
- collateral_asset_infos: Record<CollateralAsset, CollateralAssetInfo>;
272
- total_collateral_value: number;
273
- borrowed_asset: BorrowedAsset;
274
- max_borrowed_amount: BigDecimalString;
275
- max_borrowed_value: number;
276
- created_at: number;
277
- expires_at: number;
278
- }
279
- interface CrossMarginBorrowRequest {
280
- network: Network;
281
- address: string;
282
- quote_id: string;
283
- collateral_assets: Partial<Record<CollateralAsset, BigDecimalString>>;
284
- borrowed_asset: BorrowedAsset;
285
- borrowed_amount: BigDecimalString;
286
- }
287
- interface CrossMarginBorrowResponse {
288
- position_id: string;
289
- }
290
- interface CrossMarginRepayQuoteRequest {
291
- position_id: string;
292
- }
293
- interface CrossMarginRepayQuoteResponse {
294
- quote_id: string;
295
- repay_asset: BorrowedAsset;
296
- borrowed_amount: BigDecimalString;
297
- interest_cost: BigDecimalString;
298
- repay_amount: BigDecimalString;
299
- created_at: number;
300
- expires_at: number;
301
- }
302
- interface CrossMarginRepayRequest {
303
- position_id: string;
304
- quote_id: string;
305
- repay_asset: BorrowedAsset;
306
- repay_amount: BigDecimalString;
307
- }
308
- interface CrossMarginRepayResponse {
309
- position_id: string;
310
- }
311
- interface CrossMarginAdjustMarginRequest {
312
- position_id: string;
313
- is_add_margin: boolean;
314
- collateral_assets: Partial<Record<CollateralAsset, BigDecimalString>>;
315
- }
316
- interface CrossMarginAdjustMarginResponse {
317
- position_id: string;
318
- }
319
- interface BorrowedAssetGeneralInfo {
320
- interest_rate_hourly: number;
321
- interest_rate_annual: number;
322
- available_amount: number;
323
- max_borrowable_amount: number;
324
- }
325
- interface CollateralAssetGeneralInfo {
326
- liquidation_threshold: number;
327
- h_vol: number;
328
- price: number;
329
- }
330
- interface CrossMarginGeneralInfoResponse {
331
- collateral_info: Record<CollateralAsset, CollateralAssetGeneralInfo>;
332
- borrowed_info: Record<BorrowedAsset, BorrowedAssetGeneralInfo>;
333
- }
334
- interface UserOpenPositionInfo {
335
- position_id: string;
336
- collateral_assets: Record<CollateralAsset, CollateralAssetInfo>;
337
- borrowed_asset: BorrowedAsset;
338
- borrowed_amount: BigDecimalString;
339
- created_at: number;
340
- updated_at: number;
341
- current_ltv: number;
342
- margin_call_ltv: number;
343
- liquidation_ltv: number;
344
- interest_cost: number;
345
- }
346
- interface UserOpenPositionsResponse {
347
- positions: UserOpenPositionInfo[];
348
- }
349
- interface UserClosedPositionInfo {
350
- position_id: string;
351
- collateral_assets: Record<CollateralAsset, CollateralAssetInfo>;
352
- borrowed_asset: BorrowedAsset;
353
- borrowed_amount: BigDecimalString;
354
- created_at: number;
355
- closed_at: number;
356
- interest_cost: number;
357
- status: CrossMarginPositionStatus;
358
- repaid_amount?: number;
359
- }
360
- interface UserOperationInfo {
361
- position_id: string;
362
- operation_id: string;
363
- created_at: number;
364
- finished_at: number;
365
- operation_type: CrossMarginOperationType;
366
- amount: BigDecimalString;
367
- symbol: string;
368
- }
369
- interface UserHistoryResponse {
370
- positions: UserClosedPositionInfo[];
371
- operations: UserOperationInfo[];
372
- }
373
275
 
374
276
  interface PhantomWalletAdapterConfig {
375
277
  }
@@ -455,8 +357,44 @@ declare class WalletClient {
455
357
  get social_links(): Social[] | null;
456
358
  reconnect(isBackup?: boolean): Promise<WalletInfo | null>;
457
359
  connectPhantom(): Promise<WalletInfo | null>;
458
- updateAccountName(name: string): Promise<any>;
360
+ updateAccountName(name: string, accountIndex?: number): Promise<WalletInfo>;
361
+ /**
362
+ * Create, enable, or disable a sub-account
363
+ * @param request Multi-account request with type and data
364
+ * @returns Updated wallet info
365
+ */
366
+ manageMultiAccount(request: MultiAccountRequest): Promise<WalletInfo>;
367
+ /**
368
+ * Create a new sub-account
369
+ * @param name Optional name for the sub-account
370
+ * @returns Updated wallet info
371
+ */
372
+ createSubAccount(name?: string | null): Promise<WalletInfo>;
373
+ /**
374
+ * Enable a sub-account by index
375
+ * @param index Account index to enable
376
+ * @returns Updated wallet info
377
+ */
378
+ enableSubAccount(index: number): Promise<WalletInfo>;
379
+ /**
380
+ * Disable a sub-account by index
381
+ * @param index Account index to disable
382
+ * @returns Updated wallet info
383
+ */
384
+ disableSubAccount(index: number): Promise<WalletInfo>;
385
+ /**
386
+ * This method is used to sign a solana transaction with v3 sign api,
387
+ * which is enabled in default.
388
+ * @param transaction Solana transaction to sign
389
+ * @returns signed transaction
390
+ */
459
391
  signSolanaTransaction(transaction: Transaction | VersionedTransaction): Promise<Transaction | VersionedTransaction>;
392
+ /**
393
+ * This method is used to sign a ethereum eip712 transaction with v2 sign api,
394
+ * which is disabled in default.
395
+ * @param params Ethereum eip712 transaction parameters
396
+ * @returns signature
397
+ */
460
398
  signEthereumEip712(params: {
461
399
  domain: {
462
400
  name: string;
@@ -531,6 +469,11 @@ declare class WalletClient {
531
469
  getSolanaBalance(): Promise<string>;
532
470
  getEthereumBalance(): Promise<string>;
533
471
  fetchCoinbaseToken(address: string, blockchain?: "solana" | "ethereum"): Promise<string>;
472
+ /**
473
+ * This method is used to sign a ethereum eip712 transaction with v2 sign api,
474
+ * which is disabled in default.
475
+ * @returns viem signer adapter
476
+ */
534
477
  viemSignerAdapter(): {
535
478
  signTypedData: (params: {
536
479
  domain: {
@@ -584,15 +527,7 @@ declare class WalletClient {
584
527
  * @param request Build transaction request
585
528
  * @returns Build transaction response with raw transaction
586
529
  */
587
- buildTransaction(request: BuildTransactionRequest): Promise<BuildTransactionResponse>;
588
- getCrossMarginGeneralInfo(): Promise<CrossMarginGeneralInfoResponse>;
589
- getCrossMarginBorrowQuote(payload: CrossMarginBorrowQuoteRequest): Promise<CrossMarginBorrowQuoteResponse>;
590
- borrowCrossMargin(payload: CrossMarginBorrowRequest): Promise<CrossMarginBorrowResponse>;
591
- getCrossMarginRepayQuote(payload: CrossMarginRepayQuoteRequest): Promise<CrossMarginRepayQuoteResponse>;
592
- repayCrossMargin(payload: CrossMarginRepayRequest): Promise<CrossMarginRepayResponse>;
593
- adjustCrossMarginMargin(payload: CrossMarginAdjustMarginRequest): Promise<CrossMarginAdjustMarginResponse>;
594
- getCrossMarginOpenPositions(): Promise<UserOpenPositionsResponse>;
595
- getCrossMarginHistory(): Promise<UserHistoryResponse>;
530
+ buildTransaction(request: BuildTransactionRequest, walletAddress?: string): Promise<BuildTransactionResponse>;
596
531
  }
597
532
  type SignTransactionReturnType<serializer extends viem.SerializeTransactionFn<viem.TransactionSerializable> = viem.SerializeTransactionFn<viem.TransactionSerializable>, transaction extends Parameters<serializer>[0] = Parameters<serializer>[0]> = viem.TransactionSerialized<viem.GetTransactionType<transaction>>;
598
533
 
@@ -849,5 +784,5 @@ declare function useCoinbaseOnramp(): {
849
784
  getCoinbaseOnrampUrl: (amount: number, blockchain?: "solana" | "ethereum", redirectUrl?: string) => Promise<string>;
850
785
  };
851
786
 
852
- export { ACCESS_TOKEN_KEY, BACKUP_WALLET_INFO, BACKUP_WALLET_TYPE_KEY, BorrowedAsset, CollateralAsset, CrossMarginOperationType, CrossMarginPositionStatus, Network, STORAGE_STATE_KEY, SWITCHED_ACCOUNT_ADDRESS, SocialType, Storage, VaultId, WALLET_TYPE_KEY, WalletClient, WalletProvider, WalletProviderBackup, WalletType, injectStyles, isVersionedTransaction, theme, useActiveWallet, useCoinbaseOnramp, useConnect, useLoginModal, useWallet, useWalletBackup, useWalletBackupStatus, useWalletStatus };
853
- export type { AccountInfo, ApiResponse, BigDecimalString, BorrowedAssetGeneralInfo, BuildTransactionRequest, BuildTransactionResponse, CoinbaseOnrampRequest, CollateralAssetGeneralInfo, CollateralAssetInfo, CrossMarginAdjustMarginRequest, CrossMarginAdjustMarginResponse, CrossMarginBorrowQuoteRequest, CrossMarginBorrowQuoteResponse, CrossMarginBorrowRequest, CrossMarginBorrowResponse, CrossMarginGeneralInfoResponse, CrossMarginRepayQuoteRequest, CrossMarginRepayQuoteResponse, CrossMarginRepayRequest, CrossMarginRepayResponse, DeBridgeDlnCreateTxRequest, IModalManager, LoginModalProps, LoginType, MiddleAccount, MiddleAccountRequest, OrderState, SignMessageResponse, SignRequestV1, SignRequestV2, SignTransactionResponse, SignTransactionReturnType, Social, SocialInfo, SupportedTransactionVersions, TransactionOrVersionedTransaction, TransferRequest, UnsignedTx, UserClosedPositionInfo, UserHistoryResponse, UserOpenPositionInfo, UserOpenPositionsResponse, UserOperationInfo, UserSession, Wallet, WalletInfo, WalletProviderConfig };
787
+ export { ACCESS_TOKEN_KEY, BACKUP_WALLET_INFO, BACKUP_WALLET_TYPE_KEY, Network, STORAGE_STATE_KEY, SWITCHED_ACCOUNT_ADDRESS, SocialType, Storage, VaultId, WALLET_TYPE_KEY, WalletClient, WalletProvider, WalletProviderBackup, WalletType, injectStyles, isVersionedTransaction, theme, useActiveWallet, useCoinbaseOnramp, useConnect, useLoginModal, useWallet, useWalletBackup, useWalletBackupStatus, useWalletStatus };
788
+ export type { AccountInfo, ApiResponse, BuildTransactionRequest, BuildTransactionResponse, CoinbaseOnrampRequest, DeBridgeDlnCreateTxRequest, IModalManager, LoginModalProps, LoginType, MiddleAccount, MiddleAccountRequest, MultiAccountRequest, OrderState, SignMessageResponse, SignRequestV1, SignRequestV2, SignRequestV3, SignTransactionResponse, SignTransactionReturnType, Social, SocialInfo, SubAccountInfo, SupportedTransactionVersions, TransactionOrVersionedTransaction, TransferRequest, UnsignedTxV2, UnsignedTxV3, UserSession, Wallet, WalletInfo, WalletProviderConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superstack-wallet-sdk",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "description": "A wallet SDK for superstack",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",