Skip to content

Commit 5bcee99

Browse files
committed
feat(add-last-sale-type): Linting + Update lint rules - removed extra param
1 parent 7343a89 commit 5bcee99

File tree

5 files changed

+92
-91
lines changed

5 files changed

+92
-91
lines changed

lib/types.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ export interface AssetEvent {
271271
eventTimestamp: Date;
272272
auctionType: AuctionType;
273273
totalPrice: string;
274-
transaction?: Transaction | null;
275-
paymentToken?: OpenSeaFungibleToken | null;
274+
transaction: Transaction | null;
275+
paymentToken: OpenSeaFungibleToken | null;
276276
}
277277
/**
278278
* Defines set of possible auctions types

src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {WyvernProtocol} from 'wyvern-js'
1+
import { WyvernProtocol } from 'wyvern-js'
22

33
export const DEFAULT_GAS_INCREASE_FACTOR = 1.1
44
export const NULL_ADDRESS = WyvernProtocol.NULL_ADDRESS

src/debugging.ts

Lines changed: 81 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Order } from "./types"
2-
import { WyvernProtocol } from "wyvern-js"
3-
import {NULL_ADDRESS} from './constants'
1+
import { Order } from './types'
2+
import { WyvernProtocol } from 'wyvern-js'
3+
import { NULL_ADDRESS } from './constants'
44

55
export const MAX_ERROR_LENGTH = 120
66

@@ -13,17 +13,17 @@ enum Side { Buy, Sell }
1313
enum SaleKind { FixedPrice, DutchAuction }
1414

1515
const SaleKindInterface = {
16-
Side,
17-
SaleKind,
16+
Side,
17+
SaleKind,
1818

19-
validateParameters(saleKind: SaleKind, expirationTime: number): boolean {
20-
return (saleKind === SaleKind.FixedPrice || expirationTime > 0)
21-
},
19+
validateParameters(saleKind: SaleKind, expirationTime: number): boolean {
20+
return (saleKind === SaleKind.FixedPrice || expirationTime > 0)
21+
},
2222

23-
canSettleOrder(listingTime: number, expirationTime: number): boolean {
24-
const now = Math.round(Date.now() / 1000)
25-
return (listingTime < now) && (expirationTime === 0 || now < expirationTime)
26-
}
23+
canSettleOrder(listingTime: number, expirationTime: number): boolean {
24+
const now = Math.round(Date.now() / 1000)
25+
return (listingTime < now) && (expirationTime === 0 || now < expirationTime)
26+
}
2727
}
2828

2929
/**
@@ -34,67 +34,67 @@ const SaleKindInterface = {
3434
export async function requireOrdersCanMatch(
3535
client: WyvernProtocol,
3636
{buy, sell, accountAddress}:
37-
{ buy: Order, sell: Order, accountAddress: string }
38-
) {
39-
const result = await client.wyvernExchange.ordersCanMatch_.callAsync(
40-
[buy.exchange, buy.maker, buy.taker, buy.feeRecipient, buy.target, buy.staticTarget, buy.paymentToken, sell.exchange, sell.maker, sell.taker, sell.feeRecipient, sell.target, sell.staticTarget, sell.paymentToken],
41-
[buy.makerRelayerFee, buy.takerRelayerFee, buy.makerProtocolFee, buy.takerProtocolFee, buy.basePrice, buy.extra, buy.listingTime, buy.expirationTime, buy.salt, sell.makerRelayerFee, sell.takerRelayerFee, sell.makerProtocolFee, sell.takerProtocolFee, sell.basePrice, sell.extra, sell.listingTime, sell.expirationTime, sell.salt],
42-
[buy.feeMethod, buy.side, buy.saleKind, buy.howToCall, sell.feeMethod, sell.side, sell.saleKind, sell.howToCall],
43-
buy.calldata,
44-
sell.calldata,
45-
buy.replacementPattern,
46-
sell.replacementPattern,
47-
buy.staticExtradata,
48-
sell.staticExtradata,
49-
{ from: accountAddress },
50-
)
51-
52-
if (result) {
53-
return
54-
}
55-
56-
if (!(+buy.side == +SaleKindInterface.Side.Buy && +sell.side == +SaleKindInterface.Side.Sell)) {
57-
throw new Error('Must be opposite-side')
58-
}
59-
60-
if (!(buy.feeMethod == sell.feeMethod)) {
61-
throw new Error('Must use same fee method')
62-
}
63-
64-
if (!(buy.paymentToken == sell.paymentToken)) {
65-
throw new Error('Must use same payment token')
66-
}
67-
68-
if (!(sell.taker == NULL_ADDRESS || sell.taker == buy.maker)) {
69-
throw new Error('Sell taker must be null or matching buy maker')
70-
}
71-
72-
if (!(buy.taker == NULL_ADDRESS || buy.taker == sell.maker)) {
73-
throw new Error('Buy taker must be null or matching sell maker')
74-
}
75-
76-
if (!((sell.feeRecipient == NULL_ADDRESS && buy.feeRecipient != NULL_ADDRESS) || (sell.feeRecipient != NULL_ADDRESS && buy.feeRecipient == NULL_ADDRESS))) {
77-
throw new Error('One order must be maker and the other must be taker')
78-
}
79-
80-
if (!(buy.target == sell.target)) {
81-
throw new Error('Must match target')
82-
}
83-
84-
if (!(buy.howToCall == sell.howToCall)) {
85-
throw new Error('Must match howToCall')
86-
}
87-
88-
if (!SaleKindInterface.canSettleOrder(+buy.listingTime, +buy.expirationTime)) {
89-
throw new Error(`Buy-side order is set in the future or expired`)
90-
}
91-
92-
if (!SaleKindInterface.canSettleOrder(+sell.listingTime, +sell.expirationTime)) {
93-
throw new Error(`Sell-side order is set in the future or expired`)
94-
}
95-
96-
// Handle default
97-
throw new Error('Unable to match offer with auction')
37+
{ buy: Order, sell: Order, accountAddress: string }
38+
) {
39+
const result = await client.wyvernExchange.ordersCanMatch_.callAsync(
40+
[buy.exchange, buy.maker, buy.taker, buy.feeRecipient, buy.target, buy.staticTarget, buy.paymentToken, sell.exchange, sell.maker, sell.taker, sell.feeRecipient, sell.target, sell.staticTarget, sell.paymentToken],
41+
[buy.makerRelayerFee, buy.takerRelayerFee, buy.makerProtocolFee, buy.takerProtocolFee, buy.basePrice, buy.extra, buy.listingTime, buy.expirationTime, buy.salt, sell.makerRelayerFee, sell.takerRelayerFee, sell.makerProtocolFee, sell.takerProtocolFee, sell.basePrice, sell.extra, sell.listingTime, sell.expirationTime, sell.salt],
42+
[buy.feeMethod, buy.side, buy.saleKind, buy.howToCall, sell.feeMethod, sell.side, sell.saleKind, sell.howToCall],
43+
buy.calldata,
44+
sell.calldata,
45+
buy.replacementPattern,
46+
sell.replacementPattern,
47+
buy.staticExtradata,
48+
sell.staticExtradata,
49+
{from: accountAddress},
50+
)
51+
52+
if (result) {
53+
return
54+
}
55+
56+
if (!(+buy.side == +SaleKindInterface.Side.Buy && +sell.side == +SaleKindInterface.Side.Sell)) {
57+
throw new Error('Must be opposite-side')
58+
}
59+
60+
if (!(buy.feeMethod == sell.feeMethod)) {
61+
throw new Error('Must use same fee method')
62+
}
63+
64+
if (!(buy.paymentToken == sell.paymentToken)) {
65+
throw new Error('Must use same payment token')
66+
}
67+
68+
if (!(sell.taker == NULL_ADDRESS || sell.taker == buy.maker)) {
69+
throw new Error('Sell taker must be null or matching buy maker')
70+
}
71+
72+
if (!(buy.taker == NULL_ADDRESS || buy.taker == sell.maker)) {
73+
throw new Error('Buy taker must be null or matching sell maker')
74+
}
75+
76+
if (!((sell.feeRecipient == NULL_ADDRESS && buy.feeRecipient != NULL_ADDRESS) || (sell.feeRecipient != NULL_ADDRESS && buy.feeRecipient == NULL_ADDRESS))) {
77+
throw new Error('One order must be maker and the other must be taker')
78+
}
79+
80+
if (!(buy.target == sell.target)) {
81+
throw new Error('Must match target')
82+
}
83+
84+
if (!(buy.howToCall == sell.howToCall)) {
85+
throw new Error('Must match howToCall')
86+
}
87+
88+
if (!SaleKindInterface.canSettleOrder(+buy.listingTime, +buy.expirationTime)) {
89+
throw new Error(`Buy-side order is set in the future or expired`)
90+
}
91+
92+
if (!SaleKindInterface.canSettleOrder(+sell.listingTime, +sell.expirationTime)) {
93+
throw new Error(`Sell-side order is set in the future or expired`)
94+
}
95+
96+
// Handle default
97+
throw new Error('Unable to match offer with auction')
9898
}
9999

100100
/**
@@ -104,12 +104,12 @@ export async function requireOrdersCanMatch(
104104
*/
105105
export async function requireOrderCalldataCanMatch(
106106
client: WyvernProtocol,
107-
{ buy, sell }:
108-
{ buy: Order, sell: Order }
109-
) {
110-
const result = client.wyvernExchange.orderCalldataCanMatch.callAsync(buy.calldata, buy.replacementPattern, sell.calldata, sell.replacementPattern)
111-
if (result) {
112-
return
113-
}
114-
throw new Error('Unable to match offer data with auction data.')
107+
{buy, sell}:
108+
{ buy: Order, sell: Order }
109+
) {
110+
const result = client.wyvernExchange.orderCalldataCanMatch.callAsync(buy.calldata, buy.replacementPattern, sell.calldata, sell.replacementPattern)
111+
if (result) {
112+
return
113+
}
114+
throw new Error('Unable to match offer data with auction data.')
115115
}

src/utils.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import BigNumber from 'bignumber.js'
2-
import {WyvernProtocol} from 'wyvern-js'
2+
import { WyvernProtocol } from 'wyvern-js'
33
import * as ethUtil from 'ethereumjs-util'
44
import * as _ from 'lodash'
55
import * as Web3 from 'web3'
@@ -11,11 +11,11 @@ import {
1111
Schema,
1212
StateMutability
1313
} from 'wyvern-schemas/dist/types'
14-
import {WyvernAtomicizerContract} from 'wyvern-js/lib/abi_gen/wyvern_atomicizer'
15-
import {HowToCall} from 'wyvern-js/lib/types'
16-
import {ERC1155} from './contracts'
14+
import { WyvernAtomicizerContract } from 'wyvern-js/lib/abi_gen/wyvern_atomicizer'
15+
import { HowToCall } from 'wyvern-js/lib/types'
16+
import { ERC1155 } from './contracts'
1717

18-
import {OpenSeaPort} from '../src'
18+
import { OpenSeaPort } from '../src'
1919
import {
2020
Asset,
2121
AssetContractType,
@@ -1028,9 +1028,9 @@ export async function getNonCompliantApprovalAddress(erc721Contract: Web3.Contra
10281028

10291029
const results = await Promise.all([
10301030
// CRYPTOKITTIES check
1031-
promisifyCall<string>(c => erc721Contract.kittyIndexToApproved.call(tokenId, c), undefined),
1031+
promisifyCall<string>(c => erc721Contract.kittyIndexToApproved.call(tokenId, c)),
10321032
// Etherbots check
1033-
promisifyCall<string>(c => erc721Contract.partIndexToApproved.call(tokenId, c), undefined),
1033+
promisifyCall<string>(c => erc721Contract.partIndexToApproved.call(tokenId, c)),
10341034
])
10351035

10361036
return _.compact(results)[0]

tslint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"whitespace": [
7979
true,
8080
"check-branch",
81+
"check-module",
8182
"check-decl",
8283
"check-operator",
8384
"check-separator",

0 commit comments

Comments
 (0)