@oasisprotocol/privana-sdk 0.5.5 → 0.5.6

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.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as Address, J as JwtRefreshResponse, H as HostedAuthTokenExchangeResponse, B as Bytes32, a as HexString, P as PrivanaClient, N as NetworkConfig, T as TokenConfig, b as TokenBalance, c as PostDepositLockConfig, D as DepositAddressResponse, d as DepositCheckResponse, e as TransactionSubmissionResponse, f as PostDepositLockError, L as LockInfo, g as PendingDeposit, h as PendingDepositsResponse, W as WithdrawalInfo, i as HistoryEntry, j as TokenInfoResponse } from './pending-lock-IgzZyg9C.cjs';
2
- export { k as BalanceResponse, l as BatchBalancesRequest, m as BatchBalancesResponse, C as CreateOnRampIntentRequest, n as CreateOnRampIntentResponse, o as CreateSignedLockRequestParams, p as DEFAULT_LOCK_DURATION_SECONDS, q as DEFAULT_ONRAMP_LOCK_BUFFER, r as DepositAddressRequest, s as DepositCheckRequest, E as ExpiredLocksResponse, t as HistoryKind, u as HistoryRequest, v as HistoryResponse, w as HostedAuthAuthorizeUrlRequest, x as HostedAuthResponseMode, y as HostedAuthTokenExchangeRequest, z as HttpClient, F as HttpClientConfig, I as IntegerLike, G as JwtLogoutRequest, K as JwtLogoutResponse, M as JwtRefreshRequest, O as LockFundsRequest, Q as LockNonceResponse, R as LockedFundsResponse, S as MinDepositAmounts, U as ModifyLockNonceResponse, V as ModifyLockRequest, X as NETWORK_CONFIG, Y as Network, Z as OnRampPostDepositLockConfig, _ as OnRampProvider, $ as OnRampRecord, a0 as OnRampStatus, a1 as PendingDepositStatus, a2 as PendingDepositsRequest, a3 as PendingOnRampsResponse, a4 as PendingWithdrawalsResponse, a5 as PostDepositLockFailureReason, a6 as PrivanaClientConfig, a7 as SignOnRampUrlRequest, a8 as SignOnRampUrlResponse, a9 as SiweDomainResponse, aa as SiweLoginRequest, ab as SiweLoginResponse, ac as SiweNonceResponse, ad as SubmitPendingLockParams, ae as TokenListResponse, af as TotalLockedBalanceResponse, ag as TransferFundsRequest, ah as TransferLockedFundsRequest, ai as TransferLockedNonceResponse, aj as TransferNonceResponse, ak as UnlockAllExpiredRequest, al as UnlockFundsRequest, am as UpdateOnRampRequest, an as UpdateOnRampResponse, ao as WithdrawFromLockRequest, ap as WithdrawalInfoResponse, aq as WithdrawalNonceResponse, ar as WithdrawalRequest, as as applyLockBuffer, at as clampLockAmount, au as clearPendingLock, av as createSignedLockRequest, aw as getAccountingContract, ax as getApiUrl, ay as getChainId, az as isSignedLockUsable, aA as loadPendingLock, aB as normalizeAddress, aC as normalizeHex, aD as requireDepositLockOwner, aE as requireServiceAddress, aF as savePendingLock, aG as submitPendingLock } from './pending-lock-IgzZyg9C.cjs';
1
+ import { A as Address, J as JwtRefreshResponse, H as HostedAuthTokenExchangeResponse, B as Bytes32, a as HexString, P as PrivanaClient, N as NetworkConfig, T as TokenConfig, b as TokenBalance, c as PostDepositLockConfig, D as DepositAddressResponse, d as DepositCheckResponse, e as TransactionSubmissionResponse, f as PostDepositLockError, L as LockInfo, g as PendingDeposit, h as PendingDepositsResponse, W as WithdrawalInfo, i as HistoryEntry, j as TokenInfoResponse } from './pending-lock-BIMYw4gd.cjs';
2
+ export { k as BalanceResponse, l as BatchBalancesRequest, m as BatchBalancesResponse, C as CreateOnRampIntentRequest, n as CreateOnRampIntentResponse, o as CreateSignedLockRequestParams, p as DEFAULT_LOCK_DURATION_SECONDS, q as DEFAULT_ONRAMP_LOCK_BUFFER, r as DepositAddressRequest, s as DepositCheckRequest, E as ExpiredLocksResponse, t as HistoryKind, u as HistoryRequest, v as HistoryResponse, w as HostedAuthAuthorizeUrlRequest, x as HostedAuthResponseMode, y as HostedAuthTokenExchangeRequest, z as HttpClient, F as HttpClientConfig, I as IntegerLike, G as JwtLogoutRequest, K as JwtLogoutResponse, M as JwtRefreshRequest, O as LockFundsRequest, Q as LockNonceResponse, R as LockedFundsResponse, S as MinDepositAmounts, U as ModifyLockNonceResponse, V as ModifyLockRequest, X as NETWORK_CONFIG, Y as Network, Z as OnRampPostDepositLockConfig, _ as OnRampProvider, $ as OnRampRecord, a0 as OnRampStatus, a1 as PendingDepositStatus, a2 as PendingDepositsRequest, a3 as PendingOnRampsResponse, a4 as PendingWithdrawalsResponse, a5 as PostDepositLockFailureReason, a6 as PrivanaClientConfig, a7 as SignOnRampUrlRequest, a8 as SignOnRampUrlResponse, a9 as SiweDomainResponse, aa as SiweLoginRequest, ab as SiweLoginResponse, ac as SiweNonceResponse, ad as SubmitPendingLockParams, ae as TokenListResponse, af as TotalLockedBalanceResponse, ag as TransferFundsRequest, ah as TransferLockedFundsRequest, ai as TransferLockedNonceResponse, aj as TransferNonceResponse, ak as UnlockAllExpiredRequest, al as UnlockFundsRequest, am as UpdateOnRampRequest, an as UpdateOnRampResponse, ao as WithdrawFromLockRequest, ap as WithdrawalInfoResponse, aq as WithdrawalNonceResponse, ar as WithdrawalRequest, as as applyLockBuffer, at as clampLockAmount, au as clearPendingLock, av as createSignedLockRequest, aw as getAccountingContract, ax as getApiUrl, ay as getChainId, az as isSignedLockUsable, aA as loadPendingLock, aB as normalizeAddress, aC as normalizeHex, aD as requireDepositLockOwner, aE as requireServiceAddress, aF as savePendingLock, aG as submitPendingLock } from './pending-lock-BIMYw4gd.cjs';
3
3
  import { WalletClient, Address as Address$1 } from 'viem';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import * as React$1 from 'react';
@@ -486,8 +486,6 @@ interface UseDepositOptions {
486
486
  pollInterval?: number;
487
487
  /** Max time to wait for deposit to be credited in ms (default: 180000 = 3 minutes) */
488
488
  pollTimeout?: number;
489
- /** Number of block confirmations to wait before checking deposit status (default: 15) */
490
- confirmations?: number;
491
489
  }
492
490
  interface DepositParams {
493
491
  tokenId: Bytes32;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as Address, J as JwtRefreshResponse, H as HostedAuthTokenExchangeResponse, B as Bytes32, a as HexString, P as PrivanaClient, N as NetworkConfig, T as TokenConfig, b as TokenBalance, c as PostDepositLockConfig, D as DepositAddressResponse, d as DepositCheckResponse, e as TransactionSubmissionResponse, f as PostDepositLockError, L as LockInfo, g as PendingDeposit, h as PendingDepositsResponse, W as WithdrawalInfo, i as HistoryEntry, j as TokenInfoResponse } from './pending-lock-IgzZyg9C.js';
2
- export { k as BalanceResponse, l as BatchBalancesRequest, m as BatchBalancesResponse, C as CreateOnRampIntentRequest, n as CreateOnRampIntentResponse, o as CreateSignedLockRequestParams, p as DEFAULT_LOCK_DURATION_SECONDS, q as DEFAULT_ONRAMP_LOCK_BUFFER, r as DepositAddressRequest, s as DepositCheckRequest, E as ExpiredLocksResponse, t as HistoryKind, u as HistoryRequest, v as HistoryResponse, w as HostedAuthAuthorizeUrlRequest, x as HostedAuthResponseMode, y as HostedAuthTokenExchangeRequest, z as HttpClient, F as HttpClientConfig, I as IntegerLike, G as JwtLogoutRequest, K as JwtLogoutResponse, M as JwtRefreshRequest, O as LockFundsRequest, Q as LockNonceResponse, R as LockedFundsResponse, S as MinDepositAmounts, U as ModifyLockNonceResponse, V as ModifyLockRequest, X as NETWORK_CONFIG, Y as Network, Z as OnRampPostDepositLockConfig, _ as OnRampProvider, $ as OnRampRecord, a0 as OnRampStatus, a1 as PendingDepositStatus, a2 as PendingDepositsRequest, a3 as PendingOnRampsResponse, a4 as PendingWithdrawalsResponse, a5 as PostDepositLockFailureReason, a6 as PrivanaClientConfig, a7 as SignOnRampUrlRequest, a8 as SignOnRampUrlResponse, a9 as SiweDomainResponse, aa as SiweLoginRequest, ab as SiweLoginResponse, ac as SiweNonceResponse, ad as SubmitPendingLockParams, ae as TokenListResponse, af as TotalLockedBalanceResponse, ag as TransferFundsRequest, ah as TransferLockedFundsRequest, ai as TransferLockedNonceResponse, aj as TransferNonceResponse, ak as UnlockAllExpiredRequest, al as UnlockFundsRequest, am as UpdateOnRampRequest, an as UpdateOnRampResponse, ao as WithdrawFromLockRequest, ap as WithdrawalInfoResponse, aq as WithdrawalNonceResponse, ar as WithdrawalRequest, as as applyLockBuffer, at as clampLockAmount, au as clearPendingLock, av as createSignedLockRequest, aw as getAccountingContract, ax as getApiUrl, ay as getChainId, az as isSignedLockUsable, aA as loadPendingLock, aB as normalizeAddress, aC as normalizeHex, aD as requireDepositLockOwner, aE as requireServiceAddress, aF as savePendingLock, aG as submitPendingLock } from './pending-lock-IgzZyg9C.js';
1
+ import { A as Address, J as JwtRefreshResponse, H as HostedAuthTokenExchangeResponse, B as Bytes32, a as HexString, P as PrivanaClient, N as NetworkConfig, T as TokenConfig, b as TokenBalance, c as PostDepositLockConfig, D as DepositAddressResponse, d as DepositCheckResponse, e as TransactionSubmissionResponse, f as PostDepositLockError, L as LockInfo, g as PendingDeposit, h as PendingDepositsResponse, W as WithdrawalInfo, i as HistoryEntry, j as TokenInfoResponse } from './pending-lock-BIMYw4gd.js';
2
+ export { k as BalanceResponse, l as BatchBalancesRequest, m as BatchBalancesResponse, C as CreateOnRampIntentRequest, n as CreateOnRampIntentResponse, o as CreateSignedLockRequestParams, p as DEFAULT_LOCK_DURATION_SECONDS, q as DEFAULT_ONRAMP_LOCK_BUFFER, r as DepositAddressRequest, s as DepositCheckRequest, E as ExpiredLocksResponse, t as HistoryKind, u as HistoryRequest, v as HistoryResponse, w as HostedAuthAuthorizeUrlRequest, x as HostedAuthResponseMode, y as HostedAuthTokenExchangeRequest, z as HttpClient, F as HttpClientConfig, I as IntegerLike, G as JwtLogoutRequest, K as JwtLogoutResponse, M as JwtRefreshRequest, O as LockFundsRequest, Q as LockNonceResponse, R as LockedFundsResponse, S as MinDepositAmounts, U as ModifyLockNonceResponse, V as ModifyLockRequest, X as NETWORK_CONFIG, Y as Network, Z as OnRampPostDepositLockConfig, _ as OnRampProvider, $ as OnRampRecord, a0 as OnRampStatus, a1 as PendingDepositStatus, a2 as PendingDepositsRequest, a3 as PendingOnRampsResponse, a4 as PendingWithdrawalsResponse, a5 as PostDepositLockFailureReason, a6 as PrivanaClientConfig, a7 as SignOnRampUrlRequest, a8 as SignOnRampUrlResponse, a9 as SiweDomainResponse, aa as SiweLoginRequest, ab as SiweLoginResponse, ac as SiweNonceResponse, ad as SubmitPendingLockParams, ae as TokenListResponse, af as TotalLockedBalanceResponse, ag as TransferFundsRequest, ah as TransferLockedFundsRequest, ai as TransferLockedNonceResponse, aj as TransferNonceResponse, ak as UnlockAllExpiredRequest, al as UnlockFundsRequest, am as UpdateOnRampRequest, an as UpdateOnRampResponse, ao as WithdrawFromLockRequest, ap as WithdrawalInfoResponse, aq as WithdrawalNonceResponse, ar as WithdrawalRequest, as as applyLockBuffer, at as clampLockAmount, au as clearPendingLock, av as createSignedLockRequest, aw as getAccountingContract, ax as getApiUrl, ay as getChainId, az as isSignedLockUsable, aA as loadPendingLock, aB as normalizeAddress, aC as normalizeHex, aD as requireDepositLockOwner, aE as requireServiceAddress, aF as savePendingLock, aG as submitPendingLock } from './pending-lock-BIMYw4gd.js';
3
3
  import { WalletClient, Address as Address$1 } from 'viem';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import * as React$1 from 'react';
@@ -486,8 +486,6 @@ interface UseDepositOptions {
486
486
  pollInterval?: number;
487
487
  /** Max time to wait for deposit to be credited in ms (default: 180000 = 3 minutes) */
488
488
  pollTimeout?: number;
489
- /** Number of block confirmations to wait before checking deposit status (default: 15) */
490
- confirmations?: number;
491
489
  }
492
490
  interface DepositParams {
493
491
  tokenId: Bytes32;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { usePrivanaContext, createHostedAuthPendingStorageKey, clearHostedAuthPendingTransaction, HostedAuthRequiredError, HostedAuthError, createPkceVerifier, createPkceChallenge, createHostedAuthState, persistHostedAuthPendingTransaction, parseHostedAuthCallback, readHostedAuthPendingTransaction, HostedAuthStateMismatchError, buildHostedAuthSession, useSafePrivanaContext, usePrivateReadRequest, formatTokenAmount, submitPendingLock, PostDepositLockError, useDepositVerification, useEnsureCorrectChain, getTransactionReceipt, getBlockNumber, waitForTransactionReceipt, canUseBrowserStorage, clampLockAmount, requireDepositLockOwner, getWalletClient, createSignedLockRequest, requireServiceAddress, signWithdrawMessage, signLockMessage, signTransferMessage, signTransferLockedMessage, signModifyLockMessage, cn, stripHostedAuthCallbackParams, AccountingApiError, getBrowserStorageItem, removeBrowserStorageItem, isSignedLockUsable, setBrowserStorageItem, canUseSharedBrowserStorage, DEFAULT_LOCK_DURATION_SECONDS, parseTokenAmount, Skeleton, shortenAddress, formatCountdown, FiatOnRampForm, getExplorerAddressUrl, getExplorerLabel, formatTimeRemaining, getSharedBrowserStorageItem, removeSharedBrowserStorageItem, setSharedBrowserStorageItem } from './chunk-PMBU2F2R.js';
3
- export { AccountingApiError, Button, DEFAULT_LOCK_DURATION_SECONDS, DEFAULT_ONRAMP_LOCK_BUFFER, HOSTED_AUTH_CLOCK_SKEW_MS, HostedAuthError, HostedAuthRequiredError, HostedAuthStateMismatchError, HttpClient, LOCK_TYPES, MODIFY_LOCK_TYPES, NETWORK_CONFIG, NetworkError, PostDepositLockError, PrivanaClient, PrivanaProvider, SUPPORTED_CHAINS, SiweAuthProvider, Skeleton, TRANSFER_LOCKED_TYPES, TRANSFER_TYPES, ValidationError, WITHDRAW_FROM_LOCK_TYPES, WITHDRAW_TYPES, applyLockBuffer, applyRefreshResponse, buildHostedAuthSession, buildSiweStatement, buttonVariants, clampLockAmount, clearHostedAuthPendingTransaction, clearPendingLock, createDomain, createHostedAuthPendingStorageKey, createHostedAuthState, createHostedAuthStorageKey, createLockExpiry, createPkceChallenge, createPkceVerifier, createSignedLockRequest, getAccountingContract, getApiUrl, getChainById, getChainId, getExplorerAddressUrl, getExplorerLabel, isHostedAuthRefreshActive, isHostedAuthSessionActive, isSignedLockUsable, loadPendingLock, normalizeAddress, normalizeHex, parseHostedAuthCallback, persistHostedAuthPendingTransaction, readHostedAuthPendingTransaction, readStoredHostedAuthSession, requireDepositLockOwner, requireServiceAddress, savePendingLock, signLockMessage, signModifyLockMessage, signTransferLockedMessage, signTransferMessage, signWithdrawFromLockMessage, signWithdrawMessage, stripHostedAuthCallbackParams, submitPendingLock, syncHostedAuthSessionToClient, useDepositVerification, usePrivanaContext, useSafeAccount, useSafePrivanaContext, useSiweAuth } from './chunk-PMBU2F2R.js';
2
+ import { usePrivanaContext, createHostedAuthPendingStorageKey, clearHostedAuthPendingTransaction, HostedAuthRequiredError, HostedAuthError, createPkceVerifier, createPkceChallenge, createHostedAuthState, persistHostedAuthPendingTransaction, parseHostedAuthCallback, readHostedAuthPendingTransaction, HostedAuthStateMismatchError, buildHostedAuthSession, useSafePrivanaContext, usePrivateReadRequest, formatTokenAmount, submitPendingLock, PostDepositLockError, useDepositVerification, useEnsureCorrectChain, getTransactionReceipt, getBlockNumber, waitForTransactionReceipt, canUseBrowserStorage, clampLockAmount, requireDepositLockOwner, getWalletClient, createSignedLockRequest, requireServiceAddress, signWithdrawMessage, signLockMessage, signTransferMessage, signTransferLockedMessage, signModifyLockMessage, cn, stripHostedAuthCallbackParams, AccountingApiError, getBrowserStorageItem, removeBrowserStorageItem, isSignedLockUsable, setBrowserStorageItem, canUseSharedBrowserStorage, DEFAULT_LOCK_DURATION_SECONDS, parseTokenAmount, Skeleton, shortenAddress, formatCountdown, FiatOnRampForm, getExplorerAddressUrl, getExplorerLabel, formatTimeRemaining, getSharedBrowserStorageItem, removeSharedBrowserStorageItem, setSharedBrowserStorageItem } from './chunk-DLGIPF4N.js';
3
+ export { AccountingApiError, Button, DEFAULT_LOCK_DURATION_SECONDS, DEFAULT_ONRAMP_LOCK_BUFFER, HOSTED_AUTH_CLOCK_SKEW_MS, HostedAuthError, HostedAuthRequiredError, HostedAuthStateMismatchError, HttpClient, LOCK_TYPES, MODIFY_LOCK_TYPES, NETWORK_CONFIG, NetworkError, PostDepositLockError, PrivanaClient, PrivanaProvider, SUPPORTED_CHAINS, SiweAuthProvider, Skeleton, TRANSFER_LOCKED_TYPES, TRANSFER_TYPES, ValidationError, WITHDRAW_FROM_LOCK_TYPES, WITHDRAW_TYPES, applyLockBuffer, applyRefreshResponse, buildHostedAuthSession, buildSiweStatement, buttonVariants, clampLockAmount, clearHostedAuthPendingTransaction, clearPendingLock, createDomain, createHostedAuthPendingStorageKey, createHostedAuthState, createHostedAuthStorageKey, createLockExpiry, createPkceChallenge, createPkceVerifier, createSignedLockRequest, getAccountingContract, getApiUrl, getChainById, getChainId, getExplorerAddressUrl, getExplorerLabel, isHostedAuthRefreshActive, isHostedAuthSessionActive, isSignedLockUsable, loadPendingLock, normalizeAddress, normalizeHex, parseHostedAuthCallback, persistHostedAuthPendingTransaction, readHostedAuthPendingTransaction, readStoredHostedAuthSession, requireDepositLockOwner, requireServiceAddress, savePendingLock, signLockMessage, signModifyLockMessage, signTransferLockedMessage, signTransferMessage, signWithdrawFromLockMessage, signWithdrawMessage, stripHostedAuthCallbackParams, submitPendingLock, syncHostedAuthSessionToClient, useDepositVerification, usePrivanaContext, useSafeAccount, useSafePrivanaContext, useSiweAuth } from './chunk-DLGIPF4N.js';
4
4
  import { useState, useRef, useMemo, useCallback, useContext, useEffect, useId } from 'react';
5
5
  import { QueryClientContext, useQuery, useQueryClient, useMutation, keepPreviousData } from '@tanstack/react-query';
6
6
  import { useAccount, useWalletClient, useConfig, useWriteContract, useSendTransaction, useBalance as useBalance$1, useReadContract } from 'wagmi';
@@ -275,6 +275,13 @@ function useBatchBalances(options) {
275
275
  };
276
276
  }
277
277
  var STALE_MS = 30 * 60 * 1e3;
278
+ function resolveConfirmations(depositAddress, chainId) {
279
+ const confirmations = depositAddress.finality_depth?.[String(chainId)];
280
+ if (confirmations === void 0) {
281
+ throw new Error(`Deposits are not supported on chain ${chainId}`);
282
+ }
283
+ return confirmations;
284
+ }
278
285
  function storageKey(address) {
279
286
  return `privana:pending-deposit:${address.toLowerCase()}`;
280
287
  }
@@ -318,7 +325,6 @@ function useDeposit(options = {}) {
318
325
  const { executePrivateRead, privateReadAddress } = usePrivateReadRequest();
319
326
  const privateReadAddressRef = useRef(privateReadAddress);
320
327
  privateReadAddressRef.current = privateReadAddress;
321
- const confirmations = options.confirmations ?? 15;
322
328
  const [depositAddress, setDepositAddress] = useState(null);
323
329
  const [txHash, setTxHash] = useState();
324
330
  const [isSwitchingChain, setIsSwitchingChain] = useState(false);
@@ -481,6 +487,7 @@ function useDeposit(options = {}) {
481
487
  const isStale = () => generation !== generationRef.current;
482
488
  (async () => {
483
489
  try {
490
+ const confirmations = resolveConfirmations(persisted.depositAddress, persisted.chainId);
484
491
  let confirmed = false;
485
492
  try {
486
493
  const receipt = await getTransactionReceipt(config, {
@@ -512,7 +519,7 @@ function useDeposit(options = {}) {
512
519
  onErrorRef.current?.(error2);
513
520
  }
514
521
  })();
515
- }, [address, config, confirmations, queryClient, verify]);
522
+ }, [address, config, queryClient, verify]);
516
523
  const deposit = useCallback(
517
524
  async (params) => {
518
525
  if (verificationContextRef.current) {
@@ -543,6 +550,7 @@ function useDeposit(options = {}) {
543
550
  `Amount is below the minimum deposit (${minAmountStr}) for ${isNative ? "native" : "ERC-20"} on chain ${sourceChain.id}`
544
551
  );
545
552
  }
553
+ const confirmations = resolveConfirmations(addrResponse, sourceChain.id);
546
554
  if (params.postDepositLock && !canUseBrowserStorage()) {
547
555
  throw new Error("Browser storage is required for locked deposit recovery");
548
556
  }
@@ -653,7 +661,6 @@ function useDeposit(options = {}) {
653
661
  client,
654
662
  getChainById2,
655
663
  config,
656
- confirmations,
657
664
  enabledTokens,
658
665
  ensureCorrectChain,
659
666
  networkConfig,