Skip to content

Commit

Permalink
Add null checks for new fields in config (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur2136 authored Apr 24, 2024
1 parent c424801 commit 1f1647a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
10 changes: 5 additions & 5 deletions packages/cli/src/CliSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ publishCommand
}) => {
await tryWithErrorMessage(async () => {
await checkForSelfUpdate();
await checkSubmissionNetwork(url);
checkSubmissionNetwork(url);

const config = await loadPublishDetails(Constants.getConfigFilePath());

Expand All @@ -320,7 +320,7 @@ publishCommand

const signer = parseKeypair(keypair);
if (signer) {
if (hasAddressInConfig(config.lastUpdatedVersionOnStore)) {
if (config.lastUpdatedVersionOnStore != null && config.lastSubmittedVersionOnChain.address != null) {
await publishUpdateCommand({
appMintAddress: appMintAddress,
releaseMintAddress: releaseMintAddress,
Expand Down Expand Up @@ -397,7 +397,7 @@ publishCommand
}) => {
await tryWithErrorMessage(async () => {
await checkForSelfUpdate();
await checkSubmissionNetwork(url);
checkSubmissionNetwork(url);

const config = await loadPublishDetails(Constants.getConfigFilePath())

Expand Down Expand Up @@ -467,7 +467,7 @@ publishCommand
}) => {
await tryWithErrorMessage(async () => {
await checkForSelfUpdate();
await checkSubmissionNetwork(url);
checkSubmissionNetwork(url);

const config = await loadPublishDetails(Constants.getConfigFilePath())

Expand Down Expand Up @@ -530,7 +530,7 @@ publishCommand
) => {
await tryWithErrorMessage(async () => {
await checkForSelfUpdate();
await checkSubmissionNetwork(url);
checkSubmissionNetwork(url);

const config = await loadPublishDetails(Constants.getConfigFilePath())

Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/commands/ValidateCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { debug, showMessage } from "../CliUtils.js";

import type { Keypair } from "@solana/web3.js";
import type { MetaplexFile } from "@metaplex-foundation/js";
import { isMetaplexFile } from "@metaplex-foundation/js";
import { loadPublishDetailsWithChecks } from "../config/PublishDetails.js";

export const validateCommand = async ({
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/commands/create/CreateCliPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,6 @@ export const createPublisherCommand = async ({

return { publisherAddress, transactionSignature };
}

return { publisherAddress: "", transactionSignature: "" };
};
4 changes: 2 additions & 2 deletions packages/cli/src/commands/create/CreateCliRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ export const createReleaseCommand = async ({
const mediaBuffer = await fs.promises.readFile(apkEntry.uri);
const hash = createHash("sha256").update(mediaBuffer).digest("base64");

if (hash === config.lastSubmittedVersionOnChain.apk_hash) {
if (config.lastSubmittedVersionOnChain != null && hash === config.lastSubmittedVersionOnChain.apk_hash) {
throw new Error(`The last created release used the same apk file.`);
}

if (config.release.android_details.version_code <= config.lastSubmittedVersionOnChain.version_code) {
if (config.lastSubmittedVersionOnChain != null && config.release.android_details.version_code <= config.lastSubmittedVersionOnChain.version_code) {
throw new Error(`Each release NFT should have higher version code than previous minted release NFT.\nLast released version code is ${config.lastSubmittedVersionOnChain.version_code}.\nCurrent version code from apk file is ${config.release.android_details.version_code}`);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/publish/PublishCliSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const publishSubmitCommand = async ({
const appAddr = appMintAddress ?? appDetails.address;
const releaseAddr = releaseMintAddress ?? releaseDetails.address;

if (releaseAddr === lastUpdatedVersionOnStore.address) {
if (lastUpdatedVersionOnStore != null && releaseAddr === lastUpdatedVersionOnStore.address) {
throw new Error(`You've already submitted this version for review.`);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/publish/PublishCliUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const publishUpdateCommand = async ({
const appAddr = appMintAddress ?? appDetails.address;
const releaseAddr = releaseMintAddress ?? releaseDetails.address;

if (releaseAddr === lastUpdatedVersionOnStore.address) {
if (lastUpdatedVersionOnStore != null && releaseAddr === lastUpdatedVersionOnStore.address) {
throw new Error(`You've already submitted this version for review.`);
}

Expand Down

0 comments on commit 1f1647a

Please sign in to comment.