Skip to content

Commit

Permalink
WT-1793 Remove under construction log and prod error from smart check…
Browse files Browse the repository at this point in the history
…out (#993)
  • Loading branch information
imx-mikhala committed Oct 17, 2023
1 parent 3cf0c1c commit 5c3f2f2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 121 deletions.
93 changes: 0 additions & 93 deletions packages/checkout/sdk/src/Checkout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,23 +465,6 @@ describe('Connect', () => {
expect(buy).toBeCalledWith(checkout.config, provider, [{ id: '1', takerFees: [] }]);
});

it('should throw error for buy function if is production', async () => {
const provider = new Web3Provider(providerMock, ChainId.SEPOLIA);

(validateProvider as jest.Mock).mockResolvedValue(provider);

const checkout = new Checkout({
baseConfig: { environment: Environment.PRODUCTION },
});

await expect(checkout.buy({
provider,
orders: [{ id: '1' }],
})).rejects.toThrow('This endpoint is not currently available.');

expect(buy).toBeCalledTimes(0);
});

it('should call sell function', async () => {
const provider = new Web3Provider(providerMock, ChainId.SEPOLIA);
const sellResult = {};
Expand Down Expand Up @@ -523,38 +506,6 @@ describe('Connect', () => {
);
});

it('should throw error for sell function if is production', async () => {
const provider = new Web3Provider(providerMock, ChainId.SEPOLIA);
(validateProvider as jest.Mock).mockResolvedValue(provider);

const checkout = new Checkout({
baseConfig: { environment: Environment.PRODUCTION },
});

await expect(checkout.sell({
provider,
orders: [{
sellToken: {
id: '0',
collectionAddress: '0xERC721',
},
buyToken: {
type: ItemType.NATIVE,
amount: '10',
},
makerFees: [
{
amount: { percentageDecimal: 0.025 },
recipient: '0x222',
},
],
}],

})).rejects.toThrow('This endpoint is not currently available.');

expect(sell).toBeCalledTimes(0);
});

it('should call cancel function', async () => {
const provider = new Web3Provider(providerMock, ChainId.SEPOLIA);

Expand All @@ -578,22 +529,6 @@ describe('Connect', () => {
);
});

it('should throw error for cancel function if is production', async () => {
const provider = new Web3Provider(providerMock, ChainId.SEPOLIA);
(validateProvider as jest.Mock).mockResolvedValue(provider);

const checkout = new Checkout({
baseConfig: { environment: Environment.PRODUCTION },
});

await expect(checkout.cancel({
provider,
orderIds: ['1234'],
})).rejects.toThrow('This endpoint is not currently available.');

expect(cancel).toBeCalledTimes(0);
});

it('should call smartCheckout function', async () => {
const provider = new Web3Provider(providerMock, ChainId.SEPOLIA);
const smartCheckoutResult = {};
Expand Down Expand Up @@ -628,34 +563,6 @@ describe('Connect', () => {
);
});

it('should throw error for smartCheckout function if is production', async () => {
const provider = new Web3Provider(providerMock, ChainId.SEPOLIA);
const smartCheckoutResult = {};

(validateProvider as jest.Mock).mockResolvedValue(provider);
(smartCheckout as jest.Mock).mockResolvedValue(smartCheckoutResult);

const checkout = new Checkout({
baseConfig: { environment: Environment.PRODUCTION },
});

const params: SmartCheckoutParams = {
provider,
itemRequirements: [],
transactionOrGasAmount: {
type: TransactionOrGasType.GAS,
gasToken: {
type: GasTokenType.NATIVE,
limit: BigNumber.from('1'),
},
},
};

await expect(checkout.smartCheckout(params)).rejects.toThrow('This endpoint is not currently available.');

expect(smartCheckout).toBeCalledTimes(0);
});

it('should throw error for smartCheckout function if cannot get itemRequirements', async () => {
const provider = new Web3Provider(providerMock, ChainId.IMTBL_ZKEVM_TESTNET);
const smartCheckoutResult = {};
Expand Down
28 changes: 0 additions & 28 deletions packages/checkout/sdk/src/Checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,6 @@ export class Checkout {
public async buy(
params: BuyParams,
): Promise<BuyResult> {
if (this.config.isProduction) {
throw new Error('This endpoint is not currently available.');
}

// eslint-disable-next-line no-console
console.warn('This endpoint is currently under construction.');

if (params.orders.length > 1) {
// eslint-disable-next-line no-console
console.warn('This endpoint currently only processes the first order in the array.');
Expand All @@ -320,13 +313,6 @@ export class Checkout {
public async sell(
params: SellParams,
): Promise<SellResult> {
if (this.config.isProduction) {
throw new Error('This endpoint is not currently available.');
}

// eslint-disable-next-line no-console
console.warn('This endpoint is currently under construction.');

if (params.orders.length > 1) {
// eslint-disable-next-line no-console
console.warn('This endpoint currently only processes the first order in the array.');
Expand All @@ -351,13 +337,6 @@ export class Checkout {
public async cancel(
params: CancelParams,
): Promise<CancelResult> {
if (this.config.isProduction) {
throw new Error('This endpoint is not currently available.');
}

// eslint-disable-next-line no-console
console.warn('This endpoint is currently under construction.');

// eslint-disable-next-line no-console
console.warn('This endpoint currently only processes the first order in the array.');

Expand All @@ -376,13 +355,6 @@ export class Checkout {
public async smartCheckout(
params: SmartCheckoutParams,
): Promise<SmartCheckoutResult> {
if (this.config.isProduction) {
throw new Error('This endpoint is not currently available.');
}

// eslint-disable-next-line no-console
console.warn('This endpoint is currently under construction.');

const web3Provider = await provider.validateProvider(
this.config,
params.provider,
Expand Down

0 comments on commit 5c3f2f2

Please sign in to comment.