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

feat: LifeCycle to Lifecycle #1257

Merged
merged 1 commit into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/swap/components/SwapButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('SwapButton', () => {
address: '0x123',
to: { loading: false, amount: 1, token: 'ETH' },
from: { loading: false, amount: 1, token: 'BTC' },
lifeCycleStatus: { statusName: 'init' },
lifecycleStatus: { statusName: 'init' },
handleSubmit: mockHandleSubmit,
});
render(<SwapButton />);
Expand All @@ -44,7 +44,7 @@ describe('SwapButton', () => {
useSwapContextMock.mockReturnValue({
to: { loading: true, amount: 1, token: 'ETH' },
from: { loading: false, amount: 1, token: 'BTC' },
lifeCycleStatus: { statusName: 'init' },
lifecycleStatus: { statusName: 'init' },
handleSubmit: mockHandleSubmit,
});
render(<SwapButton />);
Expand All @@ -57,7 +57,7 @@ describe('SwapButton', () => {
useSwapContextMock.mockReturnValue({
to: { loading: false, amount: 1, token: 'ETH' },
from: { loading: false, amount: 1, token: 'BTC' },
lifeCycleStatus: { statusName: 'transactionPending' },
lifecycleStatus: { statusName: 'transactionPending' },
handleSubmit: mockHandleSubmit,
});
render(<SwapButton />);
Expand All @@ -70,7 +70,7 @@ describe('SwapButton', () => {
useSwapContextMock.mockReturnValue({
to: { loading: false, amount: 1, token: 'ETH' },
from: { loading: false, amount: 1, token: 'BTC' },
lifeCycleStatus: { statusName: 'transactionApproved' },
lifecycleStatus: { statusName: 'transactionApproved' },
handleSubmit: mockHandleSubmit,
});
render(<SwapButton />);
Expand All @@ -83,7 +83,7 @@ describe('SwapButton', () => {
useSwapContextMock.mockReturnValue({
to: { loading: false, amount: 1, token: 'ETH' },
from: { loading: false, amount: null, token: 'BTC' },
lifeCycleStatus: { statusName: 'init' },
lifecycleStatus: { statusName: 'init' },
handleSubmit: mockHandleSubmit,
});
render(<SwapButton />);
Expand All @@ -96,7 +96,7 @@ describe('SwapButton', () => {
address: '0x123',
to: { loading: false, amount: 1, token: 'ETH' },
from: { loading: false, amount: 1, token: 'BTC' },
lifeCycleStatus: { statusName: 'init' },
lifecycleStatus: { statusName: 'init' },
handleSubmit: mockHandleSubmit,
});
render(<SwapButton />);
Expand All @@ -110,7 +110,7 @@ describe('SwapButton', () => {
address: '0x123',
to: { loading: false, amount: 1, token: 'ETH' },
from: { loading: false, amount: 1, token: 'BTC' },
lifeCycleStatus: { statusName: 'init' },
lifecycleStatus: { statusName: 'init' },
handleSubmit: mockHandleSubmit,
});
const customClass = 'custom-class';
Expand All @@ -123,7 +123,7 @@ describe('SwapButton', () => {
useSwapContextMock.mockReturnValue({
to: { loading: false, amount: 1, token: 'ETH' },
from: { loading: false, amount: 1, token: 'BTC' },
lifeCycleStatus: { statusName: 'init' },
lifecycleStatus: { statusName: 'init' },
handleSubmit: mockHandleSubmit,
});
vi.mocked(useAccount).mockReturnValue({
Expand Down
2 changes: 1 addition & 1 deletion src/swap/components/SwapButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function SwapButton({ className, disabled = false }: SwapButtonReact) {
address,
to,
from,
lifeCycleStatus: { statusName },
lifecycleStatus: { statusName },
handleSubmit,
} = useSwapContext();

Expand Down
16 changes: 8 additions & 8 deletions src/swap/components/SwapMessage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('SwapMessage', () => {
const mockContext = {
to: {},
from: {},
lifeCycleStatus: { statusName: 'init', statusData: null },
lifecycleStatus: { statusName: 'init', statusData: null },
};
useSwapContextMock.mockReturnValue(mockContext);
mockGetSwapMessage.mockReturnValue(mockMessage);
Expand All @@ -42,7 +42,7 @@ describe('SwapMessage', () => {
const mockContext = {
to: {},
from: {},
lifeCycleStatus: {
lifecycleStatus: {
statusName: 'error',
statusData: { message: 'Error occurred' },
},
Expand All @@ -59,7 +59,7 @@ describe('SwapMessage', () => {
const mockContext = {
to: {},
from: {},
lifeCycleStatus: { statusName: 'transactionPending', statusData: null },
lifecycleStatus: { statusName: 'transactionPending', statusData: null },
};
useSwapContextMock.mockReturnValue(mockContext);
mockGetSwapMessage.mockReturnValue(mockMessage);
Expand All @@ -73,7 +73,7 @@ describe('SwapMessage', () => {
const mockContext = {
to: {},
from: {},
lifeCycleStatus: { statusName: 'transactionApproved', statusData: null },
lifecycleStatus: { statusName: 'transactionApproved', statusData: null },
};
useSwapContextMock.mockReturnValue(mockContext);
mockGetSwapMessage.mockReturnValue(mockMessage);
Expand All @@ -86,7 +86,7 @@ describe('SwapMessage', () => {
const mockContext = {
to: {},
from: {},
lifeCycleStatus: { statusName: 'init', statusData: null },
lifecycleStatus: { statusName: 'init', statusData: null },
};

useSwapContextMock.mockReturnValue(mockContext);
Expand All @@ -98,22 +98,22 @@ describe('SwapMessage', () => {
});

it('should set isMissingRequiredFields to true when reflected in statusData', () => {
const mockLifeCycleStatus = {
const mockLifecycleStatus = {
statusName: 'init',
statusData: { isMissingRequiredField: true },
};
const mockContext = {
to: { amount: 1, token: 'ETH' },
from: { amount: null, token: 'DAI' },
address: '0x123',
lifeCycleStatus: mockLifeCycleStatus,
lifecycleStatus: mockLifecycleStatus,
};
useSwapContextMock.mockReturnValue(mockContext);
render(<SwapMessage />);
expect(mockGetSwapMessage).toHaveBeenCalledWith({
address: '0x123',
from: { amount: null, token: 'DAI' },
lifeCycleStatus: mockLifeCycleStatus,
lifecycleStatus: mockLifecycleStatus,
to: { amount: 1, token: 'ETH' },
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/swap/components/SwapMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { getSwapMessage } from '../utils/getSwapMessage';
import { useSwapContext } from './SwapProvider';

export function SwapMessage({ className }: SwapMessageReact) {
const { address, to, from, lifeCycleStatus } = useSwapContext();
const { address, to, from, lifecycleStatus } = useSwapContext();

const message = getSwapMessage({
address,
from,
lifeCycleStatus,
lifecycleStatus,
to,
});

Expand Down
Loading