Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WT-1793 Remove under construction log and prod error from smart checkout #993

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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