Skip to content

Commit

Permalink
Fix contract address checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tifrel committed Feb 27, 2024
1 parent 075c989 commit 95f5b20
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 22 deletions.
8 changes: 4 additions & 4 deletions packages/sdk/src/batchChangeCreators/batchChangeCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ export const batchChangeCreators = (
args: BatchChangeCreatorsArgs,
): NearContractCall<BatchChangeMintersArgsResponse> => {
const { addCreators = [], removeCreators = [], contractAddress = mbjs.keys.contractAddress } = args;

if (!contractAddress) {
throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
}

if (!isStoreV2(contractAddress)) {
throw new Error(ERROR_MESSAGES.ONLY_V2);
}

if (contractAddress == null) {
throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
}

if (addCreators.length === 0 && removeCreators.length === 0) {
throw new Error(ERROR_MESSAGES.BATCH_CHANGE_CREATORS_NO_CHANGE);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/src/batchChangeMinters/batchChangeMinters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ export const batchChangeMinters = (
args: BatchChangeMintersArgs,
): NearContractCall<BatchChangeMintersArgsResponse> => {
const { addMinters = [], removeMinters = [], contractAddress = mbjs.keys.contractAddress } = args;

if (!contractAddress) {
throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
}

if (!isStoreV1(contractAddress)) {
throw new Error(ERROR_MESSAGES.ONLY_V1);
}

if (contractAddress == null) {
throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
}

if (addMinters.length === 0 && removeMinters.length === 0) {
throw new Error(ERROR_MESSAGES.BATCH_CHANGE_MINTERS_NO_CHANGE);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/burn/burn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ERROR_MESSAGES } from '../errorMessages';
*/
export const burn = ({ tokenIds, contractAddress = mbjs.keys.contractAddress }: BurnArgs): NearContractCall<BurnArgsResponse> => {

if (contractAddress == null) {
if (!contractAddress) {
throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/buy/buy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { BuyArgs, BuyArgsFtResponse, BuyArgsResponse, FT_METHOD_NAMES, MARKET_ME
export const buy = (args: BuyArgs): NearContractCall<BuyArgsResponse | BuyArgsFtResponse> => {
const { contractAddress = mbjs.keys.contractAddress, tokenId, referrerId = null, marketId = mbjs.keys.marketAddress, price, affiliateAccount } = args;

if (contractAddress == null) {
if (!contractAddress) {
throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/createMetadata/createMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const createMetadata = (
noReference = false,
} = args;

if (contractAddress == null) {
if (!contractAddress) {
throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
}

Expand Down
3 changes: 1 addition & 2 deletions packages/sdk/src/delist/delist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ export const delist = (
args: DelistArgs,
): NearContractCall<DelistArgsResponse> => {
const { contractAddress = mbjs.keys.contractAddress, tokenIds, marketAddress = mbjs.keys.marketAddress, oldMarket = false } = args;


if (contractAddress == null) {
if (!contractAddress) {
throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/list/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ListArgs, ListArgsResponse, MARKET_METHOD_NAMES, NearContractCall } fro
export const list = (args: ListArgs): NearContractCall<ListArgsResponse> => {
const { contractAddress = mbjs.keys.contractAddress, tokenId, marketAddress = mbjs.keys.marketAddress, price } = args;

if (contractAddress == null) {
if (!contractAddress) {
throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/lockMetadata/lockMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const lockMetadata = (
metadataId,
} = args;

if (contractAddress == null) {
if (!contractAddress) {
throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
}

Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/src/mint/mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ export const mint = (
noMedia = false,
noReference = false,
} = args;

if (!contractAddress) {
throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
}

if (!isStoreV1(contractAddress)) {
throw new Error(ERROR_MESSAGES.ONLY_V1);
}

if (contractAddress == null) {
throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
}

// Reference and media need to be present or explicitly opted out of
if (!noReference && !metadata.reference) {
throw new Error(ERROR_MESSAGES.NO_REFERENCE);
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/mintOnMetadata/mintOnMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const mintOnMetadata = (
price,
} = args;

if (contractAddress == null) {
if (!contractAddress) {
throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/setSplits/setSplits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const setSplits = (args: SetSplitsArgs): NearContractCall<SetSplitsArgsRe
splitOwners,
} = args;

if (contractAddress == null) {
if (!contractAddress) {
throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/updateMetadata/updateMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const updateMetadata = (
noMedia = false,
} = args;

if (contractAddress == null) {
if (!contractAddress) {
throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
}

Expand Down

0 comments on commit 95f5b20

Please sign in to comment.