Skip to content

Commit

Permalink
Add origination operation page
Browse files Browse the repository at this point in the history
  • Loading branch information
OKendigelyan committed May 24, 2024
1 parent 3a08c4b commit c3ea845
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/components/SendFlow/Beacon/BeaconSignPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BeaconSignPageProps } from "./BeaconSignPageProps";
import { ContractCallSignPage } from "./ContractCallSignPage";
import { DelegationSignPage } from "./DelegationSignPage";
import { OriginationOperationSignPage } from "./OriginationOperationSignPage";
import { TezSignPage as BeaconTezSignPage } from "./TezSignPage";
import { UndelegationSignPage } from "./UndelegationSignPage";

Expand All @@ -20,6 +21,8 @@ export const BeaconSignPage: React.FC<BeaconSignPageProps> = ({ operation, fee,
case "undelegation": {
return <UndelegationSignPage fee={fee} message={message} operation={operation} />;
}
case "contract_origination":
return <OriginationOperationSignPage fee={fee} message={message} operation={operation} />;
/**
* FA1/2 are impossible to get here because we don't parse them
* instead we get a generic contract call
Expand All @@ -28,7 +31,6 @@ export const BeaconSignPage: React.FC<BeaconSignPageProps> = ({ operation, fee,
*/
case "fa1.2":
case "fa2":
case "contract_origination":
throw new Error("Unsupported operation type");
}
};
3 changes: 2 additions & 1 deletion src/utils/beacon/useHandleBeaconMessage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ describe("partialOperationToOperation", () => {
without(
Object.values(TezosOperationType),
TezosOperationType.TRANSACTION,
TezosOperationType.DELEGATION
TezosOperationType.DELEGATION,
TezosOperationType.ORIGINATION
)
)("for %s", kind => {
it("throws an error", () => {
Expand Down
16 changes: 15 additions & 1 deletion src/utils/beacon/useHandleBeaconMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { ImplicitAccount } from "../../types/Account";
import { ImplicitOperations } from "../../types/AccountOperations";
import { parseImplicitPkh, parsePkh } from "../../types/Address";
import { Network } from "../../types/Network";
import { Operation } from "../../types/Operation";
import { ContractOrigination, Operation } from "../../types/Operation";
import { useGetOwnedAccountSafe } from "../hooks/getAccountDataHooks";
import { useFindNetwork } from "../hooks/networkHooks";
import { useAsyncActionHandler } from "../hooks/useAsyncActionHandler";
Expand Down Expand Up @@ -194,6 +194,20 @@ export const partialOperationToOperation = (
return { type: "undelegation", sender: signer.address };
}
}
case TezosOperationType.ORIGINATION: {
const { script } = partialOperation;
const { code, storage } = script as unknown as {
code: ContractOrigination["code"];
storage: ContractOrigination["storage"];
};

return {
type: "contract_origination",
sender: signer.address,
code,
storage,
};
}
default:
throw new Error(`Unsupported operation kind: ${partialOperation.kind}`);
}
Expand Down

0 comments on commit c3ea845

Please sign in to comment.