Skip to content

Commit

Permalink
update transaction toast
Browse files Browse the repository at this point in the history
  • Loading branch information
alissacrane-cb committed Aug 9, 2024
1 parent c7ebdc3 commit 4e83f2f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/transaction/hooks/useGetTransactionToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { successSvg } from '../../internal/svg/successSvg';
import { getChainExplorer } from '../../network/getChainExplorer';
import { cn, color, text } from '../../styles/theme';
import { useTransactionContext } from '../components/TransactionProvider';
import { useShowCallsStatus } from 'wagmi/experimental';

export function useGetTransactionToast() {
const {
Expand All @@ -22,6 +23,8 @@ export function useGetTransactionToast() {

const isInProgress = isLoading || !!transactionId || !!transactionHash;

const { showCallsStatus } = useShowCallsStatus();

Check failure on line 26 in src/transaction/hooks/useGetTransactionToast.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

src/transaction/hooks/useGetTransactionToast.test.tsx > useGetTransactionToast > should return correct toast and actionElement when transaction is loading

WagmiProviderNotFoundError: `useConfig` must be used within `WagmiProvider`. Docs: https://wagmi.sh/react/api/WagmiProvider.html Version: [email protected] ❯ useConfig node_modules/wagmi/src/hooks/useConfig.ts:20:22 ❯ Module.useShowCallsStatus node_modules/wagmi/src/experimental/hooks/useShowCallsStatus.ts:59:18 ❯ Module.useGetTransactionToast src/transaction/hooks/useGetTransactionToast.tsx:26:31 ❯ src/transaction/hooks/useGetTransactionToast.test.tsx:24:41 ❯ TestComponent node_modules/@testing-library/react/dist/pure.js:309:27 ❯ renderWithHooks node_modules/react-dom/cjs/react-dom.development.js:15486:18 ❯ mountIndeterminateComponent node_modules/react-dom/cjs/react-dom.development.js:20103:13 ❯ beginWork node_modules/react-dom/cjs/react-dom.development.js:21626:16 ❯ beginWork$1 node_modules/react-dom/cjs/react-dom.development.js:27465:14 ❯ performUnitOfWork node_modules/react-dom/cjs/react-dom.development.js:26599:12 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { details: undefined, docsPath: '/api/WagmiProvider', metaMessages: undefined, shortMessage: '`useConfig` must be used within `WagmiProvider`.', docsBaseUrl: 'https://wagmi.sh/react', version: '[email protected]', walk: 'Function<walk>' }

Check failure on line 26 in src/transaction/hooks/useGetTransactionToast.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

src/transaction/hooks/useGetTransactionToast.test.tsx > useGetTransactionToast > should return correct toast and actionElement when receipt exists

WagmiProviderNotFoundError: `useConfig` must be used within `WagmiProvider`. Docs: https://wagmi.sh/react/api/WagmiProvider.html Version: [email protected] ❯ useConfig node_modules/wagmi/src/hooks/useConfig.ts:20:22 ❯ Module.useShowCallsStatus node_modules/wagmi/src/experimental/hooks/useShowCallsStatus.ts:59:18 ❯ Module.useGetTransactionToast src/transaction/hooks/useGetTransactionToast.tsx:26:31 ❯ src/transaction/hooks/useGetTransactionToast.test.tsx:35:41 ❯ TestComponent node_modules/@testing-library/react/dist/pure.js:309:27 ❯ renderWithHooks node_modules/react-dom/cjs/react-dom.development.js:15486:18 ❯ mountIndeterminateComponent node_modules/react-dom/cjs/react-dom.development.js:20103:13 ❯ beginWork node_modules/react-dom/cjs/react-dom.development.js:21626:16 ❯ beginWork$1 node_modules/react-dom/cjs/react-dom.development.js:27465:14 ❯ performUnitOfWork node_modules/react-dom/cjs/react-dom.development.js:26599:12 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { details: undefined, docsPath: '/api/WagmiProvider', metaMessages: undefined, shortMessage: '`useConfig` must be used within `WagmiProvider`.', docsBaseUrl: 'https://wagmi.sh/react', version: '[email protected]', walk: 'Function<walk>' }

return useMemo(() => {
const chainExplorer = getChainExplorer(accountChainId);

Expand All @@ -33,6 +36,7 @@ export function useGetTransactionToast() {
icon = <Spinner className="px-1.5 py-1.5" />;
label = 'Transaction in progress';
}
// EOA will have txn hash
if (transactionHash) {
actionElement = (
<a
Expand All @@ -46,6 +50,16 @@ export function useGetTransactionToast() {
</a>
);
}
// SW will have txn id
if (transactionId) {
actionElement = (
<button onClick={() => showCallsStatus({ id: transactionId })}>
<span className={cn(text.label1, color.primary)}>
View transaction
</span>
</button>
);
}
if (receipt) {
icon = successSvg;
label = 'Successful';
Expand Down

0 comments on commit 4e83f2f

Please sign in to comment.