Skip to content

Commit

Permalink
fix: WalletConnect, moved sdkType to headerProps
Browse files Browse the repository at this point in the history
  • Loading branch information
dianasavvatina committed Dec 20, 2024
1 parent 5153a57 commit a08730f
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { type CalculatedSignProps, type SdkSignPageProps } from "../utils";
export const useSignWithBeacon = ({
operation,
headerProps,
requestId,
}: SdkSignPageProps): CalculatedSignProps => {
const { isLoading: isSigning, handleAsyncAction } = useAsyncActionHandler();
const { openWith } = useDynamicModalContext();
Expand All @@ -28,7 +27,7 @@ export const useSignWithBeacon = ({

const response: OperationResponseInput = {
type: BeaconMessageType.OperationResponse,
id: requestId.id.toString(),
id: headerProps.requestId.id.toString(),
transactionHash: opHash,
};
await WalletClient.respond(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import { type CalculatedSignProps, type SdkSignPageProps } from "../utils";
export const useSignWithWalletConnect = ({
operation,
headerProps,
requestId,
}: SdkSignPageProps): CalculatedSignProps => {
const { isLoading: isSigning, handleAsyncAction } = useAsyncActionHandler();
const { openWith } = useDynamicModalContext();

const form = useForm({ defaultValues: { executeParams: operation.estimates } });
const requestId = headerProps.requestId;

if (requestId.sdkType !== "walletconnect") {
return {
Expand Down
4 changes: 3 additions & 1 deletion apps/web/src/components/SendFlow/common/BatchSignPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export const BatchSignPage = (
const beaconCalculatedProps = useSignWithBeacon({ ...signProps });
const walletConnectCalculatedProps = useSignWithWalletConnect({ ...signProps });
const calculatedProps =
signProps.requestId.sdkType === "beacon" ? beaconCalculatedProps : walletConnectCalculatedProps;
signProps.headerProps.requestId.sdkType === "beacon"
? beaconCalculatedProps
: walletConnectCalculatedProps;

const { isSigning, onSign, network, fee } = calculatedProps;
const { signer, operations } = signProps.operation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const headerProps: SignHeaderProps = {
network: GHOSTNET,
appName: message.appMetadata.name,
appIcon: message.appMetadata.icon,
requestId: { sdkType: "beacon", id: message.id },
};
const signProps: SdkSignPageProps = {
headerProps: headerProps,
operation: operation,
requestId: { sdkType: "beacon", id: message.id },
};

jest.mock("@umami/core", () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ describe("<SingleSignPage />", () => {
network: GHOSTNET,
appName: message.appMetadata.name,
appIcon: message.appMetadata.icon,
requestId: { sdkType: "beacon", id: message.id },
};
store.dispatch(networksActions.setCurrent(GHOSTNET));

Expand All @@ -89,7 +90,6 @@ describe("<SingleSignPage />", () => {
const signProps: SdkSignPageProps = {
headerProps: headerProps,
operation: operation,
requestId: { sdkType: "beacon", id: message.id },
};

jest.mocked(useGetSecretKey).mockImplementation(() => () => Promise.resolve("secretKey"));
Expand Down
4 changes: 3 additions & 1 deletion apps/web/src/components/SendFlow/common/SingleSignPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export const SingleSignPage = (signProps: SdkSignPageProps) => {
const beaconCalculatedProps = useSignWithBeacon({ ...signProps });
const walletConnectCalculatedProps = useSignWithWalletConnect({ ...signProps });
const calculatedProps =
signProps.requestId.sdkType === "beacon" ? beaconCalculatedProps : walletConnectCalculatedProps;
signProps.headerProps.requestId.sdkType === "beacon"
? beaconCalculatedProps
: walletConnectCalculatedProps;

switch (operationType) {
case "tez": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ describe("<TezSignPage />", () => {
network: GHOSTNET,
appName: message.appMetadata.name,
appIcon: message.appMetadata.icon,
requestId: { sdkType: "beacon", id: message.id },
};
const signProps: SdkSignPageProps = {
headerProps: headerProps,
operation: operation,
requestId: { sdkType: "beacon", id: message.id },
};

store.dispatch(networksActions.setCurrent(GHOSTNET));
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/SendFlow/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ export type SignHeaderProps = {
network: Network;
appName: string;
appIcon?: string;
requestId: SignRequestId;
};

export type SdkSignPageProps = {
requestId: SignRequestId;
operation: EstimatedAccountOperations;
headerProps: SignHeaderProps;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ export const useHandleWcRequest = () => {
network,
appName: session.peer.metadata.name,
appIcon: session.peer.metadata.icons[0],
requestId: { sdkType: "walletconnect", id: id, topic },
};
const signProps: SdkSignPageProps = {
headerProps: headerProps,
operation: estimatedOperations,
requestId: { sdkType: "walletconnect", id: id, topic },
};

if (operation.operations.length === 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,11 @@ describe("<useHandleBeaconMessage />", () => {
network: MAINNET,
appName: message.appMetadata.name,
appIcon: message.appMetadata.icon,
requestId: { sdkType: "beacon", id: message.id },
};
const signProps: SdkSignPageProps = {
headerProps: headerProps,
operation: operation,
requestId: { sdkType: "beacon", id: message.id },
};

const {
Expand Down Expand Up @@ -465,11 +465,11 @@ describe("<useHandleBeaconMessage />", () => {
network: MAINNET,
appName: message.appMetadata.name,
appIcon: message.appMetadata.icon,
requestId: { sdkType: "beacon", id: message.id },
};
const signProps: SdkSignPageProps = {
headerProps: headerProps,
operation: estimatedOperations,
requestId: { sdkType: "beacon", id: message.id },
};

const {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/beacon/useHandleBeaconMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ export const useHandleBeaconMessage = () => {
network: network,
appName: message.appMetadata.name,
appIcon: message.appMetadata.icon,
requestId: { sdkType: "beacon", id: message.id },
};
const signProps: SdkSignPageProps = {
headerProps: headerProps,
operation: estimatedOperations,
requestId: { sdkType: "beacon", id: message.id },
};

if (operation.operations.length === 1) {
Expand Down

0 comments on commit a08730f

Please sign in to comment.