Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use showCallsStatus for smart wallets #976

Closed
wants to merge 7 commits into from
1 change: 0 additions & 1 deletion src/transaction/components/TransactionProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export function TransactionProvider({
} = useWriteContract({
onError,
setErrorMessage,
setTransactionId,
});
const { transactionHash, status: callStatus } = useCallsStatus({
onError,
Expand Down
1 change: 1 addition & 0 deletions src/transaction/hooks/useCallsStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function useCallsStatus({
refetchInterval: (data) => {
return data.state.data?.status === 'CONFIRMED' ? false : 1000;
},
enabled: !!transactionId,
},
});

Expand Down
12 changes: 12 additions & 0 deletions src/transaction/hooks/useGetTransactionStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import { getChainExplorer } from '../../network/getChainExplorer';
import { cn, color, text } from '../../styles/theme';
import { useTransactionContext } from '../components/TransactionProvider';
import { useShowCallsStatus } from 'wagmi/experimental';

export function useGetTransactionStatus() {
const { showCallsStatus } = useShowCallsStatus();

Check failure on line 10 in src/transaction/hooks/useGetTransactionStatus.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

src/transaction/hooks/useGetTransactionStatus.test.tsx > useGetTransactionStatus > should return correct status and actionElement when transaction is pending

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.useGetTransactionStatus src/transaction/hooks/useGetTransactionStatus.tsx:10:31 ❯ src/transaction/hooks/useGetTransactionStatus.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 10 in src/transaction/hooks/useGetTransactionStatus.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

src/transaction/hooks/useGetTransactionStatus.test.tsx > useGetTransactionStatus > should return correct status and actionElement when transaction hash 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.useGetTransactionStatus src/transaction/hooks/useGetTransactionStatus.tsx:10:31 ❯ src/transaction/hooks/useGetTransactionStatus.test.tsx:34: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 10 in src/transaction/hooks/useGetTransactionStatus.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

src/transaction/hooks/useGetTransactionStatus.test.tsx > useGetTransactionStatus > should return correct status 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.useGetTransactionStatus src/transaction/hooks/useGetTransactionStatus.tsx:10:31 ❯ src/transaction/hooks/useGetTransactionStatus.test.tsx:46: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 10 in src/transaction/hooks/useGetTransactionStatus.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

src/transaction/hooks/useGetTransactionStatus.test.tsx > useGetTransactionStatus > should return correct status and actionElement when error occurs

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.useGetTransactionStatus src/transaction/hooks/useGetTransactionStatus.tsx:10:31 ❯ src/transaction/hooks/useGetTransactionStatus.test.tsx:57: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 10 in src/transaction/hooks/useGetTransactionStatus.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

src/transaction/hooks/useGetTransactionStatus.test.tsx > useGetTransactionStatus > should return correct status and actionElement when no status available

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.useGetTransactionStatus src/transaction/hooks/useGetTransactionStatus.tsx:10:31 ❯ src/transaction/hooks/useGetTransactionStatus.test.tsx:68: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>' }
const {
chainId,
errorMessage,
Expand Down Expand Up @@ -50,6 +52,16 @@
);
}

if (transactionId) {
actionElement = (
<button onClick={() => showCallsStatus({ id: transactionId })}>
<span className={cn(text.label1, color.primary)}>
View transaction
</span>
</button>
);
}

if (receipt) {
label = 'Successful!';
}
Expand Down
5 changes: 0 additions & 5 deletions src/transaction/hooks/useWriteContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import type { TransactionError } from '../types';
type UseWriteContractParams = {
onError?: (e: TransactionError) => void;
setErrorMessage: (error: string) => void;
setTransactionId: (id: string) => void;
};

/**
Expand All @@ -21,7 +20,6 @@ type UseWriteContractParams = {
export function useWriteContract({
onError,
setErrorMessage,
setTransactionId,
}: UseWriteContractParams) {
try {
const { status, writeContractAsync, data } = useWriteContractWagmi({
Expand All @@ -37,9 +35,6 @@ export function useWriteContract({
}
onError?.({ code: WRITE_CONTRACT_ERROR_CODE, error: e.message });
},
onSuccess: (id) => {
setTransactionId(id);
},
},
});
return { status, writeContractAsync, data };
Expand Down
Loading