Skip to content

Commit

Permalink
Link "Sign in Transaction Signer" button to "Sign Transaction" page (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jeesunikim authored Jun 14, 2024
1 parent 6fe1f70 commit 80691ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { stringify } from "lossless-json";
import { StrKey, TransactionBuilder } from "@stellar/stellar-sdk";
import { set } from "lodash";
import * as StellarXdr from "@/helpers/StellarXdr";
import { useRouter } from "next/navigation";

import { SdsLink } from "@/components/SdsLink";
import { ValidationResponseCard } from "@/components/ValidationResponseCard";
Expand Down Expand Up @@ -39,11 +40,13 @@ const MAX_INT64 = "9223372036854775807";

export const TransactionXdr = () => {
const { transaction, network } = useStore();
const router = useRouter();
const {
params: txnParams,
operations: txnOperations,
isValid,
} = transaction.build;
const { updateSignActiveView, updateSignImportXdr } = transaction;

const [isReady, setIsReady] = useState(false);

Expand Down Expand Up @@ -555,7 +558,10 @@ export const TransactionXdr = () => {
size="md"
variant="secondary"
onClick={() => {
alert("TODO: handle sign transaction flow");
updateSignImportXdr(txnXdr.xdr);
updateSignActiveView("overview");

router.push("/transaction/sign");
}}
>
Sign in Transaction Signer
Expand Down
10 changes: 6 additions & 4 deletions src/store/createStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type TransactionBuildParamsObj = {
[K in keyof TransactionBuildParams]?: TransactionBuildParams[K];
};

export type SignTxActiveView = "import" | "overview";

export interface Store {
// Shared
network: Network | EmptyObj;
Expand Down Expand Up @@ -86,7 +88,7 @@ export interface Store {
};
};
sign: {
activeView: string;
activeView: SignTxActiveView;
importTx: FeeBumpTransaction | Transaction | undefined;
importXdr: string;
signedTx: string;
Expand All @@ -111,7 +113,7 @@ export interface Store {
resetBuildParams: () => void;
resetBuild: () => void;
// [Transaction] Sign Transaction actions
updateSignActiveView: (viewId: string) => void;
updateSignActiveView: (viewId: SignTxActiveView) => void;
updateSignImportTx: (tx: FeeBumpTransaction | Transaction) => void;
updateSignImportXdr: (xdr: string) => void;
updateSignedTx: (tx: string) => void;
Expand Down Expand Up @@ -166,7 +168,7 @@ const initTransactionState = {
},
},
sign: {
activeView: "import",
activeView: "import" as SignTxActiveView,
importTx: undefined,
importXdr: "",
signedTx: "",
Expand Down Expand Up @@ -324,7 +326,7 @@ export const createStore = (options: CreateStoreOptions) =>
set((state) => {
state.transaction.build = initTransactionState.build;
}),
updateSignActiveView: (viewId: string) =>
updateSignActiveView: (viewId: SignTxActiveView) =>
set((state) => {
state.transaction.sign.activeView = viewId;
}),
Expand Down

0 comments on commit 80691ee

Please sign in to comment.