@pollar/core 0.5.0 → 0.5.3

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.mts CHANGED
@@ -107,15 +107,18 @@ type TransactionState = {
107
107
  buildData: TxBuildContent;
108
108
  } | {
109
109
  step: 'signing';
110
- buildData: TxBuildContent;
110
+ buildData?: TxBuildContent;
111
+ external?: true;
111
112
  } | {
112
113
  step: 'success';
113
- buildData: TxBuildContent;
114
+ buildData?: TxBuildContent;
114
115
  hash: string;
116
+ external?: true;
115
117
  } | {
116
118
  step: 'error';
117
119
  details?: string;
118
120
  buildData?: TxBuildContent;
121
+ external?: true;
119
122
  };
120
123
  declare const AUTH_ERROR_CODES: {
121
124
  readonly SESSION_CREATE_FAILED: "SESSION_CREATE_FAILED";
@@ -183,6 +186,17 @@ declare class PollarFlowError extends Error {
183
186
  }
184
187
  type WalletBalanceContent = paths['/wallet/balance']['get']['responses'][200]['content']['application/json']['content'];
185
188
  type WalletBalanceRecord = WalletBalanceContent['balances'][number];
189
+ type WalletBalanceState = {
190
+ step: 'idle';
191
+ } | {
192
+ step: 'loading';
193
+ } | {
194
+ step: 'loaded';
195
+ data: WalletBalanceContent;
196
+ } | {
197
+ step: 'error';
198
+ message: string;
199
+ };
186
200
  type TxHistoryRecord = paths['/tx/history']['get']['responses'][200]['content']['application/json']['content']['records'][number];
187
201
  type TxHistoryParams = NonNullable<paths['/tx/history']['get']['parameters']['query']>;
188
202
  type TxHistoryContent = paths['/tx/history']['get']['responses'][200]['content']['application/json']['content'];
@@ -217,6 +231,13 @@ type RampsTransactionResponse = paths['/ramps/transaction/{txId}']['get']['respo
217
231
  type RampTxStatus = RampsTransactionResponse['status'];
218
232
  type RampDirection = RampsTransactionResponse['direction'];
219
233
  type PaymentInstructions = RampsOnrampResponse['paymentInstructions'];
234
+ type EscrowFn<TParams = unknown> = (params: TParams) => Promise<{
235
+ unsignedTransaction: string;
236
+ }>;
237
+ type EscrowAdapter = Record<string, EscrowFn<any>>;
238
+ interface PollarAdapters {
239
+ [key: string]: EscrowAdapter;
240
+ }
220
241
 
221
242
  declare class PollarClient {
222
243
  readonly apiKey: string;
@@ -228,6 +249,8 @@ declare class PollarClient {
228
249
  private _transactionStateListeners;
229
250
  private _txHistoryState;
230
251
  private _txHistoryStateListeners;
252
+ private _walletBalanceState;
253
+ private _walletBalanceStateListeners;
231
254
  private _authState;
232
255
  private _authStateListeners;
233
256
  private _networkState;
@@ -250,12 +273,14 @@ declare class PollarClient {
250
273
  onNetworkStateChange(cb: (state: NetworkState) => void): () => void;
251
274
  getTransactionState(): TransactionState | null;
252
275
  onTransactionStateChange(cb: (state: TransactionState) => void): () => void;
253
- private _setTxHistoryState;
254
276
  getTxHistoryState(): TxHistoryState;
255
277
  onTxHistoryStateChange(cb: (state: TxHistoryState) => void): () => void;
256
278
  fetchTxHistory(params?: TxHistoryParams): Promise<void>;
257
- getWalletBalance(publicKey?: string): Promise<WalletBalanceContent | null>;
279
+ getWalletBalanceState(): WalletBalanceState;
280
+ onWalletBalanceStateChange(cb: (state: WalletBalanceState) => void): () => void;
281
+ refreshBalance(publicKey?: string): Promise<void>;
258
282
  buildTx(operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']): Promise<void>;
283
+ getWalletType(): WalletType | null;
259
284
  signAndSubmitTx(unsignedXdr: string): Promise<void>;
260
285
  getAppConfig(): Promise<unknown>;
261
286
  getKycStatus(providerId?: string): Promise<{
@@ -291,6 +316,8 @@ declare class PollarClient {
291
316
  intervalMs?: number;
292
317
  timeoutMs?: number;
293
318
  }): Promise<RampTxStatus>;
319
+ private _setTxHistoryState;
320
+ private _setWalletBalanceState;
294
321
  /** Creates a new AbortController, cancelling any existing flow first. */
295
322
  private _newController;
296
323
  /** Builds the deps object passed to flow functions via bind pattern. */
@@ -2076,6 +2103,8 @@ interface operations {
2076
2103
  balance: string;
2077
2104
  available: string;
2078
2105
  limit?: string;
2106
+ enabledInApp: boolean;
2107
+ trustlineRemoved: boolean;
2079
2108
  }[];
2080
2109
  };
2081
2110
  };
@@ -2732,4 +2761,4 @@ declare function pollRampTransaction(api: PollarApiClient, txId: string, { inter
2732
2761
  timeoutMs?: number;
2733
2762
  }): Promise<RampTxStatus>;
2734
2763
 
2735
- export { AUTH_ERROR_CODES, AlbedoAdapter, type AuthErrorCode, type AuthState, type ConnectWalletResponse, FreighterAdapter, type KycFlow, type KycLevel, type KycProvider, type KycStartBody, type KycStartResponse, type KycStatus, type NetworkState, type PaymentInstructions, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLoginOptions, type RampDirection, type RampQuote, type RampTxStatus, type RampsOfframpBody, type RampsOfframpResponse, type RampsOnrampBody, type RampsOnrampResponse, type RampsQuoteQuery, type RampsQuoteResponse, type RampsTransactionResponse, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, type TransactionState, type TxBuildBody, type TxBuildContent, type TxBuildResponse, type TxHistoryContent, type TxHistoryParams, type TxHistoryRecord, type TxHistoryState, type TxSignAndSendBody, type TxSignSendResponse, type WalletAdapter, type WalletBalanceContent, type WalletBalanceRecord, WalletType, createOffRamp, createOnRamp, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, pollKycStatus, pollRampTransaction, type paths as pollarPaths, resolveKyc, startKyc };
2764
+ export { AUTH_ERROR_CODES, AlbedoAdapter, type AuthErrorCode, type AuthState, type ConnectWalletResponse, type EscrowAdapter, type EscrowFn, FreighterAdapter, type KycFlow, type KycLevel, type KycProvider, type KycStartBody, type KycStartResponse, type KycStatus, type NetworkState, type PaymentInstructions, type PollarAdapters, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLoginOptions, type RampDirection, type RampQuote, type RampTxStatus, type RampsOfframpBody, type RampsOfframpResponse, type RampsOnrampBody, type RampsOnrampResponse, type RampsQuoteQuery, type RampsQuoteResponse, type RampsTransactionResponse, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, type TransactionState, type TxBuildBody, type TxBuildContent, type TxBuildResponse, type TxHistoryContent, type TxHistoryParams, type TxHistoryRecord, type TxHistoryState, type TxSignAndSendBody, type TxSignSendResponse, type WalletAdapter, type WalletBalanceContent, type WalletBalanceRecord, type WalletBalanceState, WalletType, createOffRamp, createOnRamp, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, pollKycStatus, pollRampTransaction, type paths as pollarPaths, resolveKyc, startKyc };
package/dist/index.d.ts CHANGED
@@ -107,15 +107,18 @@ type TransactionState = {
107
107
  buildData: TxBuildContent;
108
108
  } | {
109
109
  step: 'signing';
110
- buildData: TxBuildContent;
110
+ buildData?: TxBuildContent;
111
+ external?: true;
111
112
  } | {
112
113
  step: 'success';
113
- buildData: TxBuildContent;
114
+ buildData?: TxBuildContent;
114
115
  hash: string;
116
+ external?: true;
115
117
  } | {
116
118
  step: 'error';
117
119
  details?: string;
118
120
  buildData?: TxBuildContent;
121
+ external?: true;
119
122
  };
120
123
  declare const AUTH_ERROR_CODES: {
121
124
  readonly SESSION_CREATE_FAILED: "SESSION_CREATE_FAILED";
@@ -183,6 +186,17 @@ declare class PollarFlowError extends Error {
183
186
  }
184
187
  type WalletBalanceContent = paths['/wallet/balance']['get']['responses'][200]['content']['application/json']['content'];
185
188
  type WalletBalanceRecord = WalletBalanceContent['balances'][number];
189
+ type WalletBalanceState = {
190
+ step: 'idle';
191
+ } | {
192
+ step: 'loading';
193
+ } | {
194
+ step: 'loaded';
195
+ data: WalletBalanceContent;
196
+ } | {
197
+ step: 'error';
198
+ message: string;
199
+ };
186
200
  type TxHistoryRecord = paths['/tx/history']['get']['responses'][200]['content']['application/json']['content']['records'][number];
187
201
  type TxHistoryParams = NonNullable<paths['/tx/history']['get']['parameters']['query']>;
188
202
  type TxHistoryContent = paths['/tx/history']['get']['responses'][200]['content']['application/json']['content'];
@@ -217,6 +231,13 @@ type RampsTransactionResponse = paths['/ramps/transaction/{txId}']['get']['respo
217
231
  type RampTxStatus = RampsTransactionResponse['status'];
218
232
  type RampDirection = RampsTransactionResponse['direction'];
219
233
  type PaymentInstructions = RampsOnrampResponse['paymentInstructions'];
234
+ type EscrowFn<TParams = unknown> = (params: TParams) => Promise<{
235
+ unsignedTransaction: string;
236
+ }>;
237
+ type EscrowAdapter = Record<string, EscrowFn<any>>;
238
+ interface PollarAdapters {
239
+ [key: string]: EscrowAdapter;
240
+ }
220
241
 
221
242
  declare class PollarClient {
222
243
  readonly apiKey: string;
@@ -228,6 +249,8 @@ declare class PollarClient {
228
249
  private _transactionStateListeners;
229
250
  private _txHistoryState;
230
251
  private _txHistoryStateListeners;
252
+ private _walletBalanceState;
253
+ private _walletBalanceStateListeners;
231
254
  private _authState;
232
255
  private _authStateListeners;
233
256
  private _networkState;
@@ -250,12 +273,14 @@ declare class PollarClient {
250
273
  onNetworkStateChange(cb: (state: NetworkState) => void): () => void;
251
274
  getTransactionState(): TransactionState | null;
252
275
  onTransactionStateChange(cb: (state: TransactionState) => void): () => void;
253
- private _setTxHistoryState;
254
276
  getTxHistoryState(): TxHistoryState;
255
277
  onTxHistoryStateChange(cb: (state: TxHistoryState) => void): () => void;
256
278
  fetchTxHistory(params?: TxHistoryParams): Promise<void>;
257
- getWalletBalance(publicKey?: string): Promise<WalletBalanceContent | null>;
279
+ getWalletBalanceState(): WalletBalanceState;
280
+ onWalletBalanceStateChange(cb: (state: WalletBalanceState) => void): () => void;
281
+ refreshBalance(publicKey?: string): Promise<void>;
258
282
  buildTx(operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']): Promise<void>;
283
+ getWalletType(): WalletType | null;
259
284
  signAndSubmitTx(unsignedXdr: string): Promise<void>;
260
285
  getAppConfig(): Promise<unknown>;
261
286
  getKycStatus(providerId?: string): Promise<{
@@ -291,6 +316,8 @@ declare class PollarClient {
291
316
  intervalMs?: number;
292
317
  timeoutMs?: number;
293
318
  }): Promise<RampTxStatus>;
319
+ private _setTxHistoryState;
320
+ private _setWalletBalanceState;
294
321
  /** Creates a new AbortController, cancelling any existing flow first. */
295
322
  private _newController;
296
323
  /** Builds the deps object passed to flow functions via bind pattern. */
@@ -2076,6 +2103,8 @@ interface operations {
2076
2103
  balance: string;
2077
2104
  available: string;
2078
2105
  limit?: string;
2106
+ enabledInApp: boolean;
2107
+ trustlineRemoved: boolean;
2079
2108
  }[];
2080
2109
  };
2081
2110
  };
@@ -2732,4 +2761,4 @@ declare function pollRampTransaction(api: PollarApiClient, txId: string, { inter
2732
2761
  timeoutMs?: number;
2733
2762
  }): Promise<RampTxStatus>;
2734
2763
 
2735
- export { AUTH_ERROR_CODES, AlbedoAdapter, type AuthErrorCode, type AuthState, type ConnectWalletResponse, FreighterAdapter, type KycFlow, type KycLevel, type KycProvider, type KycStartBody, type KycStartResponse, type KycStatus, type NetworkState, type PaymentInstructions, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLoginOptions, type RampDirection, type RampQuote, type RampTxStatus, type RampsOfframpBody, type RampsOfframpResponse, type RampsOnrampBody, type RampsOnrampResponse, type RampsQuoteQuery, type RampsQuoteResponse, type RampsTransactionResponse, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, type TransactionState, type TxBuildBody, type TxBuildContent, type TxBuildResponse, type TxHistoryContent, type TxHistoryParams, type TxHistoryRecord, type TxHistoryState, type TxSignAndSendBody, type TxSignSendResponse, type WalletAdapter, type WalletBalanceContent, type WalletBalanceRecord, WalletType, createOffRamp, createOnRamp, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, pollKycStatus, pollRampTransaction, type paths as pollarPaths, resolveKyc, startKyc };
2764
+ export { AUTH_ERROR_CODES, AlbedoAdapter, type AuthErrorCode, type AuthState, type ConnectWalletResponse, type EscrowAdapter, type EscrowFn, FreighterAdapter, type KycFlow, type KycLevel, type KycProvider, type KycStartBody, type KycStartResponse, type KycStatus, type NetworkState, type PaymentInstructions, type PollarAdapters, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, PollarFlowError, type PollarLoginOptions, type RampDirection, type RampQuote, type RampTxStatus, type RampsOfframpBody, type RampsOfframpResponse, type RampsOnrampBody, type RampsOnrampResponse, type RampsQuoteQuery, type RampsQuoteResponse, type RampsTransactionResponse, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, type TransactionState, type TxBuildBody, type TxBuildContent, type TxBuildResponse, type TxHistoryContent, type TxHistoryParams, type TxHistoryRecord, type TxHistoryState, type TxSignAndSendBody, type TxSignSendResponse, type WalletAdapter, type WalletBalanceContent, type WalletBalanceRecord, type WalletBalanceState, WalletType, createOffRamp, createOnRamp, getKycProviders, getKycStatus, getRampTransaction, getRampsQuote, isValidSession, pollKycStatus, pollRampTransaction, type paths as pollarPaths, resolveKyc, startKyc };