@oasisprotocol/privana-sdk 0.5.4 → 0.5.5
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 +28 -19
- package/dist/{chunk-FGWMLLEC.cjs → chunk-7VNAGKRC.cjs} +916 -364
- package/dist/chunk-7VNAGKRC.cjs.map +1 -0
- package/dist/{chunk-QQG4RPYZ.js → chunk-PMBU2F2R.js} +917 -365
- package/dist/chunk-PMBU2F2R.js.map +1 -0
- package/dist/index.cjs +278 -252
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +37 -11
- package/dist/index.js.map +1 -1
- package/dist/on-ramp.cjs +3 -3
- package/dist/on-ramp.d.cts +81 -52
- package/dist/on-ramp.d.ts +81 -52
- package/dist/on-ramp.js +1 -1
- package/dist/{pending-lock-DSEqUHOw.d.cts → pending-lock-IgzZyg9C.d.cts} +22 -18
- package/dist/{pending-lock-DSEqUHOw.d.ts → pending-lock-IgzZyg9C.d.ts} +22 -18
- package/package.json +1 -1
- package/dist/chunk-FGWMLLEC.cjs.map +0 -1
- package/dist/chunk-QQG4RPYZ.js.map +0 -1
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-
|
|
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-
|
|
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';
|
|
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';
|
|
@@ -4058,7 +4058,8 @@ function WithdrawView({
|
|
|
4058
4058
|
amount,
|
|
4059
4059
|
onAmountChange,
|
|
4060
4060
|
onSelectToken,
|
|
4061
|
-
onPendingChange
|
|
4061
|
+
onPendingChange,
|
|
4062
|
+
onWithdrawSuccess
|
|
4062
4063
|
}) {
|
|
4063
4064
|
const { chains, getChainById: getChainById2 } = usePrivanaContext();
|
|
4064
4065
|
const { isConnected, address } = useAccount();
|
|
@@ -4078,7 +4079,12 @@ function WithdrawView({
|
|
|
4078
4079
|
const { withdraw, isPending, currentStep, error, reset } = useWithdraw({
|
|
4079
4080
|
onProcessingSuccess: () => {
|
|
4080
4081
|
onAmountChange("");
|
|
4081
|
-
|
|
4082
|
+
if (onWithdrawSuccess) {
|
|
4083
|
+
reset();
|
|
4084
|
+
onWithdrawSuccess();
|
|
4085
|
+
} else {
|
|
4086
|
+
setShowSuccess(true);
|
|
4087
|
+
}
|
|
4082
4088
|
},
|
|
4083
4089
|
onProcessingTimeout: () => {
|
|
4084
4090
|
onAmountChange("");
|
|
@@ -4251,7 +4257,8 @@ function WithdrawView({
|
|
|
4251
4257
|
function WithdrawModalContent({
|
|
4252
4258
|
onClose,
|
|
4253
4259
|
onPendingChange,
|
|
4254
|
-
onBack
|
|
4260
|
+
onBack,
|
|
4261
|
+
onWithdrawSuccess
|
|
4255
4262
|
}) {
|
|
4256
4263
|
const { serviceName, enabledTokens, defaultToken, hostedAuthConfig } = usePrivanaContext();
|
|
4257
4264
|
const { address } = useAccount();
|
|
@@ -4317,7 +4324,8 @@ function WithdrawModalContent({
|
|
|
4317
4324
|
amount,
|
|
4318
4325
|
onAmountChange: setAmount,
|
|
4319
4326
|
onSelectToken: () => setView("select-token"),
|
|
4320
|
-
onPendingChange: handlePendingChange
|
|
4327
|
+
onPendingChange: handlePendingChange,
|
|
4328
|
+
onWithdrawSuccess
|
|
4321
4329
|
}
|
|
4322
4330
|
),
|
|
4323
4331
|
view === "select-token" && /* @__PURE__ */ jsx(
|
|
@@ -4332,7 +4340,7 @@ function WithdrawModalContent({
|
|
|
4332
4340
|
)
|
|
4333
4341
|
] });
|
|
4334
4342
|
}
|
|
4335
|
-
function WithdrawModal({ open, onClose }) {
|
|
4343
|
+
function WithdrawModal({ open, onClose, onWithdrawSuccess }) {
|
|
4336
4344
|
const titleId = useId();
|
|
4337
4345
|
const descId = useId();
|
|
4338
4346
|
const [isCloseBlocked, setIsCloseBlocked] = useState(false);
|
|
@@ -4359,14 +4367,21 @@ function WithdrawModal({ open, onClose }) {
|
|
|
4359
4367
|
children: [
|
|
4360
4368
|
/* @__PURE__ */ jsx(DialogTitle, { id: titleId, className: "sr-only", children: "Withdraw" }),
|
|
4361
4369
|
/* @__PURE__ */ jsx(DialogDescription, { id: descId, className: "sr-only", children: "Withdraw funds from your account." }),
|
|
4362
|
-
/* @__PURE__ */ jsx(
|
|
4370
|
+
/* @__PURE__ */ jsx(
|
|
4371
|
+
WithdrawModalContent,
|
|
4372
|
+
{
|
|
4373
|
+
onClose: handleClose,
|
|
4374
|
+
onPendingChange: setIsCloseBlocked,
|
|
4375
|
+
onWithdrawSuccess
|
|
4376
|
+
}
|
|
4377
|
+
)
|
|
4363
4378
|
]
|
|
4364
4379
|
}
|
|
4365
4380
|
)
|
|
4366
4381
|
}
|
|
4367
4382
|
);
|
|
4368
4383
|
}
|
|
4369
|
-
function WithdrawInlineModal({ className }) {
|
|
4384
|
+
function WithdrawInlineModal({ className, onWithdrawSuccess }) {
|
|
4370
4385
|
return /* @__PURE__ */ jsx(
|
|
4371
4386
|
"div",
|
|
4372
4387
|
{
|
|
@@ -4375,7 +4390,7 @@ function WithdrawInlineModal({ className }) {
|
|
|
4375
4390
|
"bg-card relative flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
|
|
4376
4391
|
className
|
|
4377
4392
|
),
|
|
4378
|
-
children: /* @__PURE__ */ jsx(WithdrawModalContent, {})
|
|
4393
|
+
children: /* @__PURE__ */ jsx(WithdrawModalContent, { onWithdrawSuccess })
|
|
4379
4394
|
}
|
|
4380
4395
|
);
|
|
4381
4396
|
}
|
|
@@ -4627,6 +4642,7 @@ function WalletModalContent({
|
|
|
4627
4642
|
onFundSession,
|
|
4628
4643
|
onEndSession,
|
|
4629
4644
|
onDepositSuccess,
|
|
4645
|
+
onWithdrawSuccess,
|
|
4630
4646
|
onClose,
|
|
4631
4647
|
onCloseBlockedChange,
|
|
4632
4648
|
...depositHandlers
|
|
@@ -4791,7 +4807,17 @@ function WalletModalContent({
|
|
|
4791
4807
|
retryLabel: "Try again"
|
|
4792
4808
|
}
|
|
4793
4809
|
) }),
|
|
4794
|
-
view === "withdraw" && /* @__PURE__ */ jsx(
|
|
4810
|
+
view === "withdraw" && /* @__PURE__ */ jsx(
|
|
4811
|
+
WithdrawModalContent,
|
|
4812
|
+
{
|
|
4813
|
+
onBack: exitWithdraw,
|
|
4814
|
+
onPendingChange: setWithdrawPending,
|
|
4815
|
+
onWithdrawSuccess: () => {
|
|
4816
|
+
exitWithdraw();
|
|
4817
|
+
onWithdrawSuccess?.();
|
|
4818
|
+
}
|
|
4819
|
+
}
|
|
4820
|
+
),
|
|
4795
4821
|
view === "deposit" && /* @__PURE__ */ jsx(
|
|
4796
4822
|
DepositModalContent,
|
|
4797
4823
|
{
|