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

Fix close, transfer, publish, import #536

Merged
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
5 changes: 3 additions & 2 deletions src/ExtrinsicSubmissionStateView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import ExtrinsicSubmissionResult from './ExtrinsicSubmissionResult';
export interface Props {
successMessage?: string;
slim?: boolean;
submissionId?: string;
}

export default function ExtrinsicSubmissionStateView(props: Props) {
const { extrinsicSubmissionState } = useLogionChain();

if(extrinsicSubmissionState.submitted) {
return (<ExtrinsicSubmissionResult
error={ extrinsicSubmissionState.error }
result={ extrinsicSubmissionState.result }
error={ extrinsicSubmissionState.getError(props.submissionId) }
result={ extrinsicSubmissionState.getResult(props.submissionId) }
successMessage={ props.successMessage }
slim={ props.slim }
/>);
Expand Down
8 changes: 5 additions & 3 deletions src/common/WalletGauge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ export default function WalletGauge(props: Props) {
};
}, [ amount, destination, unit, mutateBalanceState, signer, expectNewTransaction ]);

const transferCallback = useCallback(() => {
submitCall(transfer);
const transferCallback = useCallback(async () => {
try {
await submitCall(transfer);
} catch(e) {}
}, [ transfer, submitCall ]);

const clearFormCallback = useCallback(() => {
Expand Down Expand Up @@ -131,7 +133,7 @@ export default function WalletGauge(props: Props) {
buttonText: "Cancel",
buttonVariant: 'secondary-polkadot',
callback: cancelCallback,
disabled: extrinsicSubmissionState.submitted && !extrinsicSubmissionState.callEnded,
disabled: extrinsicSubmissionState.inProgress,
},
{
id: 'transfer',
Expand Down
9 changes: 5 additions & 4 deletions src/loc/CloseLocButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ enum CloseStatus {
NONE,
ACCEPT,
CLOSE_PENDING,
CLOSING,
DONE
CLOSING
}

interface CloseState {
Expand Down Expand Up @@ -60,9 +59,11 @@ export default function CloseLocButton(props: Props) {
});
}, [ mutateLocState, autoAck, signer ]);

const close = useCallback(() => {
const close = useCallback(async () => {
setCloseState({ status: CloseStatus.CLOSING });
submitCall(closeCall);
try {
await submitCall(closeCall);
} catch(e) {}
}, [ closeCall, submitCall ]);

const clear = useCallback(() => {
Expand Down
7 changes: 1 addition & 6 deletions src/loc/ImportItems.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ import { setLocState, refresh } from "./__mocks__/UserLocContextMock";
import { CollectionItem, Fees, UUID } from "@logion/node-api";
import { H256 } from "@logion/node-api/dist/types/interfaces";
import { LogionClient, AddCollectionItemParams, EstimateFeesAddCollectionItemParams } from "@logion/client";
import { mockSubmittableResult } from "../logion-chain/__mocks__/SignatureMock";
import { SUCCESSFUL_SUBMISSION, setClientMock, setExtrinsicSubmissionState } from 'src/logion-chain/__mocks__/LogionChainMock';
import { It, Mock } from 'moq.ts';
import { SubmittableExtrinsic } from '@polkadot/api/promise/types';
import { Compact, u128 } from "@polkadot/types-codec";
import { TEST_WALLET_USER } from 'src/wallet-user/TestData';

jest.mock("../common/CommonContext");
jest.mock("../logion-chain/Signature");
jest.mock("../logion-chain");
jest.mock("./UserLocContext");

Expand All @@ -29,9 +27,7 @@ describe("ImportItems", () => {
await userEvent.click(importAllButton);
await waitFor(() => expect(screen.getByRole("button", { name: "Proceed" })).toBeVisible());
await clickByName("Proceed");
await waitFor(() => expect(screen.getByRole("button", { name: "Proceed" })).toBeVisible());
await clickByName("Proceed");
await waitFor(() => expect(collection.addCollectionItem).toBeCalled());
await waitFor(() => expect(collection.addCollectionItem).toBeCalledTimes(2));

await waitFor(() => expect(screen.getAllByRole("img", {name: "ok"}).length).toBe(2));

Expand Down Expand Up @@ -69,7 +65,6 @@ async function uploadCsv(): Promise<any> {

const collection = {
addCollectionItem: jest.fn((params: AddCollectionItemParams) => {
params.callback!(mockSubmittableResult(true, "finalized"));
return Promise.resolve();
}),
estimateFeesAddCollectionItem: jest.fn((params: EstimateFeesAddCollectionItemParams) => {
Expand Down
Loading
Loading