superstack-wallet-sdk 0.5.10 → 0.6.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.
@@ -1,7 +1,6 @@
1
- import { Wallet, Social, WalletInfo, Network, IModalManager, MiddleAccountRequest, MiddleAccount, CoinbaseOnrampRequest, OrderState, LoginType, BuildTransactionRequest, BuildTransactionResponse, MultiAccountRequest, ExportInitResponse, ExportWalletResponse, CloseInitResponse, CloseFinishResponse, LighterBuildTransactionRequest, LighterBuildTransactionResponse, LighterAuthResponse, LighterChangeKeyResponse, ExchangeRequest, ExchangeResponse } from "./types";
1
+ import { WalletInfo, Network, IModalManager, MiddleAccountRequest, MiddleAccount, CoinbaseOnrampRequest, OrderState, LoginType, BuildTransactionRequest, BuildTransactionResponse, MultiAccountRequest, ExportInitResponse, ExportWalletResponse, CloseInitResponse, CloseFinishResponse, LighterBuildTransactionRequest, LighterBuildTransactionResponse, LighterAuthResponse, LighterChangeKeyResponse, ExchangeRequest, ExchangeResponse } from "./types";
2
2
  import { Transaction, VersionedTransaction } from "@solana/web3.js";
3
3
  import { PhantomWalletAdapter } from "./adapters/phantom";
4
- import * as viem from "viem";
5
4
  interface SolanaCluster {
6
5
  name?: "mainnet-beta" | "devnet" | "testnet";
7
6
  rpcUrl: string;
@@ -25,42 +24,26 @@ export interface WalletProviderConfig {
25
24
  enablePhantom?: boolean;
26
25
  }
27
26
  export declare class WalletClient {
27
+ walletInfo: WalletInfo | null;
28
+ private userId;
28
29
  private api;
29
30
  private middleAccountApi;
30
- private selectedWalletId;
31
31
  private solanaConnection;
32
32
  private ethereumProvider;
33
- private walletInfo;
34
33
  private phantomAdapter;
35
34
  private walletType;
36
- private backupWalletType;
37
35
  private solanaCluster;
38
36
  private ethereumNetwork;
39
37
  private defaultNetwork;
40
- constructor(config: WalletProviderConfig);
41
- private setWallet;
38
+ constructor(config: WalletProviderConfig & {
39
+ setWalletInfo: (walletInfo: WalletInfo | null) => void;
40
+ });
41
+ private setWalletInfo;
42
42
  private setWalletType;
43
- private setBackupWalletType;
44
- getWallet(): WalletInfo | null;
45
- getPhantomAdapter(): PhantomWalletAdapter | null;
46
- getWalletType(): "phantom" | "embedded";
47
- getBackupWalletType(): "phantom_backup" | "embedded_backup";
48
- get wallet(): Wallet | null;
49
- get address(): string | null;
50
- get network(): Network | null;
51
- get ethereumWallet(): Wallet | null;
52
- get ethereumAddress(): string | null;
53
- get solanaWallet(): Wallet | null;
54
- get forwardSolanaWallet(): Wallet | null;
55
- get forwardSolanaAddress(): string | null;
56
- get forwardEthereumWallet(): Wallet | null;
57
- get forwardEthereumAddress(): string | null;
58
- get solanaAddress(): string | null;
59
- get id(): string | null;
60
- get social_links(): Social[] | null;
61
43
  reconnect(isBackup?: boolean): Promise<WalletInfo | null>;
44
+ getPhantomAdapter(): PhantomWalletAdapter | null;
62
45
  connectPhantom(): Promise<WalletInfo | null>;
63
- updateAccountName(name: string, accountIndex?: number): Promise<WalletInfo>;
46
+ updateAccountName(name: string, accountIndex: number): Promise<WalletInfo>;
64
47
  /**
65
48
  * Create, enable, or disable a sub-account
66
49
  * @param request Multi-account request with type and data
@@ -91,7 +74,7 @@ export declare class WalletClient {
91
74
  * @param transaction Solana transaction to sign
92
75
  * @returns signed transaction
93
76
  */
94
- signSolanaTransaction(transaction: Transaction | VersionedTransaction): Promise<Transaction | VersionedTransaction>;
77
+ signSolanaTransaction(transaction: Transaction | VersionedTransaction, solanaAddress: string): Promise<Transaction | VersionedTransaction>;
95
78
  /**
96
79
  * This method is used to sign a ethereum eip712 transaction with v2 sign api,
97
80
  * which is disabled in default.
@@ -111,7 +94,7 @@ export declare class WalletClient {
111
94
  }>>;
112
95
  primaryType: string;
113
96
  message: Record<string, unknown>;
114
- }): Promise<string>;
97
+ }, ethereumAddress: string): Promise<string>;
115
98
  sendSolanaTransaction(transaction: Uint8Array): Promise<string>;
116
99
  sendEthereumTransaction(signedTransaction: string): Promise<string>;
117
100
  sendEmailVerificationCode(email: string): Promise<void>;
@@ -147,6 +130,19 @@ export declare class WalletClient {
147
130
  network?: Network;
148
131
  isBackup?: boolean;
149
132
  }): Promise<WalletInfo | null>;
133
+ bind(type: LoginType, params: {
134
+ state?: string;
135
+ code?: string;
136
+ redirect_uri?: string;
137
+ code_verifier?: string;
138
+ email?: string;
139
+ phone?: string;
140
+ wallet_address?: string;
141
+ challenge?: string;
142
+ signature?: string;
143
+ network?: Network;
144
+ isBackup?: boolean;
145
+ }): Promise<WalletInfo | null>;
150
146
  oauthInit(params: {
151
147
  provider: string;
152
148
  redirect_uri: string;
@@ -164,20 +160,18 @@ export declare class WalletClient {
164
160
  nonce: string;
165
161
  expires_at: number;
166
162
  }>;
167
- getSession(): Promise<WalletInfo>;
163
+ getAndRefreshSession(): Promise<WalletInfo>;
168
164
  logout(isBackup?: boolean): Promise<void>;
169
165
  getOAuth2ClientId(provider: string): Promise<string>;
170
- setSelectedWallet(walletId: string): void;
171
- getSelectedWallet(): string | null;
172
- getSolanaBalance(): Promise<string>;
173
- getEthereumBalance(): Promise<string>;
166
+ getSolanaBalance(solanaAddress: string): Promise<string>;
167
+ getEthereumBalance(ethereumAddress: string): Promise<string>;
174
168
  fetchCoinbaseToken(address: string, blockchain?: "solana" | "ethereum"): Promise<string>;
175
169
  /**
176
170
  * This method is used to sign a ethereum eip712 transaction with v2 sign api,
177
171
  * which is disabled in default.
178
172
  * @returns viem signer adapter
179
173
  */
180
- viemSignerAdapter(): {
174
+ viemSignerAdapter(ethereumAddress: string): {
181
175
  signTypedData: (params: {
182
176
  domain: {
183
177
  name: string;
@@ -231,13 +225,13 @@ export declare class WalletClient {
231
225
  * @param walletAddress Optional wallet address (will be added to request if provided)
232
226
  * @returns Build transaction response with raw transaction
233
227
  */
234
- buildTransaction(request: BuildTransactionRequest, walletAddress?: string): Promise<BuildTransactionResponse>;
228
+ buildTransaction(request: BuildTransactionRequest): Promise<BuildTransactionResponse>;
235
229
  /**
236
230
  * Initialize the export process by generating a server nonce
237
231
  * @param accountIndex Optional account index to export (defaults to 0)
238
232
  * @returns Server nonce for verification
239
233
  */
240
- exportInit(accountIndex?: number): Promise<ExportInitResponse>;
234
+ exportInit(accountIndex: number): Promise<ExportInitResponse>;
241
235
  /**
242
236
  * Finalize the export process and retrieve wallet private keys
243
237
  * @param params Export parameters including nonces and account index
@@ -246,7 +240,7 @@ export declare class WalletClient {
246
240
  exportFinal(params: {
247
241
  userNonce: string;
248
242
  serverNonce: string;
249
- accountIndex?: number;
243
+ accountIndex: number;
250
244
  isExport?: boolean;
251
245
  }): Promise<ExportWalletResponse>;
252
246
  /**
@@ -254,7 +248,7 @@ export declare class WalletClient {
254
248
  * @param accountIndex Optional account index (defaults to 0)
255
249
  * @returns Previously exported wallet information
256
250
  */
257
- getExportedWallets(accountIndex?: number): Promise<ExportWalletResponse>;
251
+ getExportedWallets(accountIndex: number): Promise<ExportWalletResponse>;
258
252
  /**
259
253
  * Initialize the account closure process
260
254
  * @returns Server nonce for verification
@@ -338,5 +332,4 @@ export declare class WalletClient {
338
332
  */
339
333
  exchange(request: ExchangeRequest): Promise<ExchangeResponse>;
340
334
  }
341
- export 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>>;
342
335
  export {};
@@ -1,3 +1,3 @@
1
- export declare function useCoinbaseOnramp(): {
1
+ export declare function useCoinbaseOnramp(solanaAddress: string, ethereumAddress: string): {
2
2
  getCoinbaseOnrampUrl: (amount: number, blockchain?: "solana" | "ethereum", redirectUrl?: string) => Promise<string>;
3
3
  };
@@ -16,7 +16,7 @@ interface WalletState {
16
16
  enablePhantom: boolean;
17
17
  }
18
18
  interface WalletContextValue extends WalletState {
19
- connect: () => Promise<void>;
19
+ connect: (hideLoginModal?: boolean) => Promise<void>;
20
20
  disconnect: () => void;
21
21
  }
22
22
  interface WalletProviderProps {
@@ -1,6 +1,6 @@
1
1
  import { LoginModalProps, LoginType } from "./types";
2
2
  export declare function useConnect(): {
3
- connect: () => Promise<void>;
3
+ connect: (hideLoginModal?: boolean) => Promise<void>;
4
4
  disconnect: () => void;
5
5
  isConnecting: boolean;
6
6
  };
@@ -12,17 +12,6 @@ export declare function useWalletStatus(): {
12
12
  isInitialized: boolean;
13
13
  ready: boolean;
14
14
  };
15
- export declare function useWalletBackupStatus(): {
16
- isAuthenticated: boolean;
17
- authenticated: boolean;
18
- error: string | null;
19
- session: import("./types").UserSession | null;
20
- isInitialized: boolean;
21
- ready: boolean;
22
- };
23
- export declare function useActiveWallet(): {
24
- wallet: import("./client").WalletClient | null;
25
- };
26
15
  export declare function useLoginModal({ client, isOpen, onClose, onLogin, isLoading }: LoginModalProps): {
27
16
  email: string;
28
17
  setEmail: import("react").Dispatch<import("react").SetStateAction<string>>;
@@ -1,9 +1,9 @@
1
1
  import "./polyfills";
2
2
  export * from "./client";
3
3
  export * from "./context";
4
- export * from "./context_backup";
5
4
  export * from "./hooks";
6
5
  export * from "./storage";
7
6
  export * from "./types";
8
7
  export * from "./styles";
9
8
  export * from "./coinbase";
9
+ export * from "./utils/oauth";
@@ -5,9 +5,10 @@ export declare class ModalManager implements IModalManager {
5
5
  private root;
6
6
  private createContainer;
7
7
  private removeExistingContainer;
8
- showLoginModal({ client, isLoading, onClose, onLogin, enableEmail, enablePhone, enableGoogle, enableTwitter, enablePhantom, }: {
8
+ showLoginModal({ client, isLoading, hideLoginModal, onClose, onLogin, enableEmail, enablePhone, enableGoogle, enableTwitter, enablePhantom, }: {
9
9
  client: WalletClient;
10
10
  isLoading?: boolean;
11
+ hideLoginModal?: boolean;
11
12
  onClose?: () => void;
12
13
  onLogin?: (walletInfo: WalletInfo) => void;
13
14
  enableEmail?: boolean;
@@ -3,8 +3,8 @@ export declare const STORAGE_STATE_KEY = "embedded_wallet_state";
3
3
  export declare const WALLET_TYPE_KEY = "superstack_wallet_type";
4
4
  export declare const BACKUP_WALLET_TYPE_KEY = "superstack_backup_wallet_type";
5
5
  export declare const ACCESS_TOKEN_KEY = "embedded_wallet_access_token";
6
- export declare const SWITCHED_ACCOUNT_ADDRESS = "switched_account_address";
7
6
  export declare const BACKUP_WALLET_INFO = "backup_wallet_info";
7
+ export declare const IS_GOOGLE_AUTH_BIND = "is_google_auth_bind";
8
8
  interface StorageState {
9
9
  accessToken: string;
10
10
  socials: Social[];
@@ -15,14 +15,14 @@ export declare class Storage {
15
15
  static saveAccessToken(token: string): void;
16
16
  static saveWalletType(type: "phantom" | "embedded"): void;
17
17
  static saveBackupWalletType(type: "phantom_backup" | "embedded_backup"): void;
18
- static saveSwitchedAccountAddress(address: string): void;
19
18
  static saveBackupWalletInfo(wallet: WalletInfo): void;
19
+ static saveIsGoogleAuthBind(type: boolean): void;
20
20
  static getWalletType(): "phantom" | "embedded" | null;
21
21
  static getBackupWalletType(): "phantom_backup" | "embedded_backup" | null;
22
+ static getIsGoogleAuthBind(): boolean | null;
22
23
  static getState(): StorageState | null;
23
24
  static getSocials(): Social[] | null;
24
25
  static getAccessToken(): string | null;
25
- static getSwitchedAccountAddress(): string | null;
26
26
  static getBackupWalletInfo(): WalletInfo | null;
27
27
  static clear(): void;
28
28
  static clearBackup(): void;
@@ -219,7 +219,7 @@ export interface DeBridgeDlnCreateTxRequest {
219
219
  srcChainPriorityLevel?: string | null;
220
220
  }
221
221
  export type BuildTransactionRequest = {
222
- wallet_address?: string | null;
222
+ wallet_address: string;
223
223
  } & ({
224
224
  type: "HyperbeatVaultApprove";
225
225
  data: {
@@ -468,11 +468,11 @@ export interface ExchangeRequest {
468
468
  vaultAddress?: string | null;
469
469
  expiresAfter?: number | null;
470
470
  isMainnet?: boolean | null;
471
- walletAddress?: string | null;
471
+ walletAddress: string | null;
472
472
  }
473
473
  export interface ExportInitRequest {
474
474
  user_nonce: string;
475
- account_index?: number;
475
+ account_index: number;
476
476
  }
477
477
  export interface ExportInitResponse {
478
478
  server_nonce: string;
@@ -480,7 +480,7 @@ export interface ExportInitResponse {
480
480
  export interface ExportFinishRequest {
481
481
  user_nonce?: string;
482
482
  server_nonce?: string;
483
- account_index?: number;
483
+ account_index: number;
484
484
  is_export: boolean;
485
485
  }
486
486
  export interface ExportWallet {