Skip to content

Commit

Permalink
Merge branch 'main' into unimind
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhwu authored Jan 14, 2025
2 parents cfa0bf4 + cc60b86 commit c020234
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
1 change: 1 addition & 0 deletions bin/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ Object.values(SUPPORTED_CHAINS).forEach((chainId) => {
envVars['RPC_TENDERLY'] = process.env[`RPC_TENDERLY`] || ''
envVars['RPC_1'] = process.env[`RPC_1`] || ''
envVars['RPC_8453'] = process.env[`RPC_8453`] || ''
envVars['RPC_130'] = process.env[`RPC_130`] || ''
envVars['DL_REACTOR_TENDERLY'] = process.env[`DL_REACTOR_TENDERLY`] || ''
envVars['QUOTER_TENDERLY'] = process.env[`QUOTER_TENDERLY`] || ''
envVars['PERMIT2_TENDERLY'] = process.env[`PERMIT2_TENDERLY`] || ''
Expand Down
2 changes: 2 additions & 0 deletions lib/handlers/check-order-status/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ export const AVERAGE_BLOCK_TIME = (chainId: ChainId): number => {
return 12
case ChainId.ARBITRUM_ONE:
return 1
case ChainId.UNICHAIN:
return 1
case ChainId.BASE:
return 2
case ChainId.POLYGON:
Expand Down
2 changes: 2 additions & 0 deletions lib/util/chain.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export enum ChainId {
MAINNET = 1,
UNICHAIN = 130,
BASE = 8453,
OPTIMISM = 10,
ARBITRUM_ONE = 42161,
Expand All @@ -17,4 +18,5 @@ export const SUPPORTED_CHAINS = [
ChainId.GÖRLI,
ChainId.ARBITRUM_ONE,
ChainId.BASE,
ChainId.UNICHAIN,
]
43 changes: 27 additions & 16 deletions test/integ/repositories/dynamo-repository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ const PRIORITY_ORDER_1 = {
cosigner: '0xsigner',
}

const PRIORITY_ORDER_2 = {
...PRIORITY_ORDER_1,
chainId: 130,
orderHash: '0x12',
}

const DUTCHV3_1 = {
orderHash: '0x42161',
offerer: '0xmaker',
Expand Down Expand Up @@ -195,6 +201,7 @@ describe('OrdersRepository put item test', () => {
expect(() => {
mockTime(1)
ordersRepository.putOrderAndUpdateNonceTransaction(PRIORITY_ORDER_1 as unknown as UniswapXOrderEntity)
ordersRepository.putOrderAndUpdateNonceTransaction(PRIORITY_ORDER_2 as unknown as UniswapXOrderEntity)
}).not.toThrow()
})

Expand Down Expand Up @@ -248,10 +255,11 @@ describe('OrdersRepository getOrders test', () => {

it('should successfully get orders given an orderStatus', async () => {
const queryResult = await ordersRepository.getOrders(10, { orderStatus: ORDER_STATUS.OPEN })
expect(queryResult.orders).toHaveLength(4)
expect(queryResult.orders).toHaveLength(5)
expect(queryResult.orders).toContainEqual(expect.objectContaining(MOCK_ORDER_1))
expect(queryResult.orders).toContainEqual(expect.objectContaining(MOCK_ORDER_2))
expect(queryResult.orders).toContainEqual(expect.objectContaining(PRIORITY_ORDER_1))
expect(queryResult.orders).toContainEqual(expect.objectContaining(PRIORITY_ORDER_2))
expect(queryResult.orders).toContainEqual(expect.objectContaining(DUTCHV3_1))
})

Expand Down Expand Up @@ -435,10 +443,10 @@ describe('OrdersRepository getOrders test with pagination', () => {
let orders = await ordersRepository.getOrders(1, { orderStatus: ORDER_STATUS.OPEN })
expect(orders.orders).toHaveLength(1)
allOrders = allOrders.concat(orders.orders)
orders = await ordersRepository.getOrders(4, { orderStatus: ORDER_STATUS.OPEN }, orders.cursor)
expect(orders.orders).toHaveLength(3)
orders = await ordersRepository.getOrders(5, { orderStatus: ORDER_STATUS.OPEN }, orders.cursor)
expect(orders.orders).toHaveLength(4)
allOrders = allOrders.concat(orders.orders)
expect(allOrders).toHaveLength(4)
expect(allOrders).toHaveLength(5)
expect(allOrders).toContainEqual(expect.objectContaining(MOCK_ORDER_1))
expect(allOrders).toContainEqual(expect.objectContaining(MOCK_ORDER_2))
expect(allOrders).toContainEqual(expect.objectContaining(DUTCHV3_1))
Expand Down Expand Up @@ -468,22 +476,24 @@ describe('OrdersRepository getOrders test with pagination', () => {
})

it('should throw an Error for cursor with the wrong index', async () => {
const orders = await ordersRepository.getOrders(3, { orderStatus: ORDER_STATUS.OPEN })
expect(orders.orders).toHaveLength(3)
const orders = await ordersRepository.getOrders(4, { orderStatus: ORDER_STATUS.OPEN })
expect(orders.orders).toHaveLength(4)
expect(orders.orders).toContainEqual(expect.objectContaining(MOCK_ORDER_5))
expect(orders.orders).toContainEqual(expect.objectContaining(DUTCHV3_1))
expect(orders.orders).toContainEqual(expect.objectContaining(PRIORITY_ORDER_1))
expect(orders.orders).toContainEqual(expect.objectContaining(PRIORITY_ORDER_2))
await expect(() => ordersRepository.getOrders(0, { offerer: 'riley.eth' }, orders.cursor)).rejects.toThrow(
Error('Invalid cursor.')
)
})

it('should throw an Error for cursor with the wrong cursor', async () => {
const orders = await ordersRepository.getOrders(3, { orderStatus: ORDER_STATUS.OPEN })
expect(orders.orders).toHaveLength(3)
const orders = await ordersRepository.getOrders(4, { orderStatus: ORDER_STATUS.OPEN })
expect(orders.orders).toHaveLength(4)
expect(orders.orders).toContainEqual(expect.objectContaining(MOCK_ORDER_5))
expect(orders.orders).toContainEqual(expect.objectContaining(DUTCHV3_1))
expect(orders.orders).toContainEqual(expect.objectContaining(PRIORITY_ORDER_1))
expect(orders.orders).toContainEqual(expect.objectContaining(PRIORITY_ORDER_2))
await expect(() => ordersRepository.getOrders(0, { offerer: 'riley.eth' }, 'wrong_cursor')).rejects.toThrow(
Error('Invalid cursor.')
)
Expand Down Expand Up @@ -536,11 +546,12 @@ describe('OrdersRepository getOrders test with sorting', () => {
sort: 'between(1,3)',
desc: true,
})
expect(queryResult.orders).toHaveLength(5)
expect(queryResult.orders).toHaveLength(6)
expect(queryResult.orders).toContainEqual(expect.objectContaining(MOCK_ORDER_2))
expect(queryResult.orders).toContainEqual(expect.objectContaining(MOCK_ORDER_1))
expect(queryResult.orders).toContainEqual(expect.objectContaining(MOCK_ORDER_5))
expect(queryResult.orders).toContainEqual(expect.objectContaining(PRIORITY_ORDER_1))
expect(queryResult.orders).toContainEqual(expect.objectContaining(PRIORITY_ORDER_2))
expect(queryResult.orders).toContainEqual(expect.objectContaining(DUTCHV3_1))
})

Expand All @@ -551,13 +562,13 @@ describe('OrdersRepository getOrders test with sorting', () => {
sort: 'between(1,3)',
desc: false,
})
expect(queryResult.orders).toHaveLength(5)
expect(queryResult.orders[0]).toEqual(expect.objectContaining(MOCK_ORDER_5))
expect(queryResult.orders[1]).toEqual(expect.objectContaining(PRIORITY_ORDER_1))
expect(queryResult.orders[2]).toEqual(expect.objectContaining(DUTCHV3_1))
expect(queryResult.orders[3]).toEqual(expect.objectContaining(MOCK_ORDER_1))
expect(queryResult.orders[4]).toEqual(expect.objectContaining(MOCK_ORDER_2))

expect(queryResult.orders).toHaveLength(6)
expect(queryResult.orders[0]).toEqual(expect.objectContaining(PRIORITY_ORDER_2))
expect(queryResult.orders[1]).toEqual(expect.objectContaining(MOCK_ORDER_5))
expect(queryResult.orders[2]).toEqual(expect.objectContaining(PRIORITY_ORDER_1))
expect(queryResult.orders[3]).toEqual(expect.objectContaining(DUTCHV3_1))
expect(queryResult.orders[4]).toEqual(expect.objectContaining(MOCK_ORDER_1))
expect(queryResult.orders[5]).toEqual(expect.objectContaining(MOCK_ORDER_2))
})
})

Expand Down
6 changes: 6 additions & 0 deletions test/unit/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ export const MOCK_PROVIDER_MAP = new Map([
getBlockNumber: providerGetLatestBlockMock,
},
],
[
ChainId.UNICHAIN,
{
getBlockNumber: providerGetLatestBlockMock,
},
],
[
ChainId.BASE,
{
Expand Down

0 comments on commit c020234

Please sign in to comment.