Skip to content

Commit

Permalink
fix(audit): Remove tenderly from supported chain ids (#244)
Browse files Browse the repository at this point in the history
Remove tenderly from supported chain ids
  • Loading branch information
zhongeric authored Jul 10, 2023
1 parent a3fd141 commit d5da57a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
3 changes: 1 addition & 2 deletions lib/util/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export enum ChainId {
OPTIMISM = 10,
ARBITRUM_ONE = 42161,
POLYGON = 137,
TENDERLY = 12341234,
}

export const SUPPORTED_CHAINS = [ChainId.MAINNET, ChainId.GÖRLI, ChainId.POLYGON, ChainId.TENDERLY]
export const SUPPORTED_CHAINS = [ChainId.MAINNET, ChainId.GÖRLI, ChainId.POLYGON]
2 changes: 1 addition & 1 deletion test/handlers/check-order-status.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe('Testing check order status handler', () => {
orderStatus: ORDER_STATUS.OPEN as string,
chainId: 2022,
} as any)
).rejects.toThrowError(`"chainId" must be one of [1, 5, 137, 12341234]`)
).rejects.toThrowError(`"chainId" must be one of [1, 5, 137]`)
})
})

Expand Down
2 changes: 1 addition & 1 deletion test/handlers/get-nonce.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Testing get nonce handler.', () => {
[{ address: '' }, '"address\\" is not allowed to be empty"'],
[{ address: '0xF53bDa7e0337BD456cDcDab0Ab24Db43E738065' }, 'VALIDATION ERROR: Invalid address'],
[{}, '"address\\" is required'],
[{ address: MOCK_ADDRESS, chainId: 'foo' }, '\\"chainId\\" must be one of [1, 5, 137, 12341234]'],
[{ address: MOCK_ADDRESS, chainId: 'foo' }, '\\"chainId\\" must be one of [1, 5, 137]'],
])('Throws 400 with invalid query param %p', async (invalidQueryParam, bodyMsg) => {
const invalidEvent = {
...event,
Expand Down
2 changes: 1 addition & 1 deletion test/handlers/get-orders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe('Testing get orders handler.', () => {
[{ sort: 'foo(bar)' }, '"foo(bar)\\" fails to match the required pattern'],
[{ cursor: 1 }, 'must be a string'],
[{ sort: 'gt(4)' }, '{"detail":"\\"sortKey\\" is required","errorCode":"VALIDATION_ERROR"}'],
[{ chainId: 420 }, '{"detail":"\\"chainId\\" must be one of [1, 5, 137, 12341234]","errorCode":"VALIDATION_ERROR"}'],
[{ chainId: 420 }, '{"detail":"\\"chainId\\" must be one of [1, 5, 137]","errorCode":"VALIDATION_ERROR"}'],
[{ desc: true }, '{"detail":"\\"sortKey\\" is required","errorCode":"VALIDATION_ERROR"}'],
[
{ desc: 'yes', sortKey: 'createdAt', orderStatus: 'expired' },
Expand Down
18 changes: 9 additions & 9 deletions test/handlers/post-order.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ErrorCode } from '../../lib/handlers/base'
import { PostOrderHandler } from '../../lib/handlers/post-order/handler'

const MOCK_ARN_1 = 'MOCK_ARN_1'
const MOCK_ARN_12341234 = 'MOCK_ARN_12341234'
const MOCK_ARN_5 = 'MOCK_ARN_5'
const MOCK_HASH = '0xhash'
const MOCK_START_EXECUTION_INPUT = JSON.stringify({
orderHash: MOCK_HASH,
Expand All @@ -28,7 +28,7 @@ mockSfnClient

mockSfnClient
.on(StartExecutionCommand, {
stateMachineArn: MOCK_ARN_12341234,
stateMachineArn: MOCK_ARN_5,
name: MOCK_HASH,
input: MOCK_START_EXECUTION_INPUT,
})
Expand Down Expand Up @@ -148,7 +148,7 @@ describe('Testing post order handler.', () => {
1: {
validate: onchainValidationSucceededMock,
},
12341234: {
5: {
validate: onchainValidationSucceededMock,
},
137: {
Expand All @@ -164,7 +164,7 @@ describe('Testing post order handler.', () => {

beforeAll(() => {
process.env['STATE_MACHINE_ARN_1'] = MOCK_ARN_1
process.env['STATE_MACHINE_ARN_12341234'] = MOCK_ARN_12341234
process.env['STATE_MACHINE_ARN_5'] = MOCK_ARN_5
process.env['REGION'] = 'region'
parserMock.mockImplementation((_order: any, chainId: number) => ({ ...DECODED_ORDER, chainId }))
})
Expand Down Expand Up @@ -204,17 +204,17 @@ describe('Testing post order handler.', () => {
const postOrderResponse = await postOrderHandler.handler(
{
queryStringParameters: {},
body: JSON.stringify({ ...postRequestBody, chainId: 12341234 }),
body: JSON.stringify({ ...postRequestBody, chainId: 5 }),
} as any,
{} as any
)

expect(putOrderAndUpdateNonceTransactionMock).toBeCalledWith({ ...ORDER, chainId: 12341234 })
expect(putOrderAndUpdateNonceTransactionMock).toBeCalledWith({ ...ORDER, chainId: 5 })
expect(onchainValidationSucceededMock).toBeCalled()
expect(validatorMock).toBeCalledWith({ ...DECODED_ORDER, chainId: 12341234 })
expect(validatorMock).toBeCalledWith({ ...DECODED_ORDER, chainId: 5 })
expect(mockSfnClient.calls()).toHaveLength(1)
expect(mockSfnClient.call(0).args[0].input).toMatchObject({
stateMachineArn: MOCK_ARN_12341234,
stateMachineArn: MOCK_ARN_5,
})
expect(postOrderResponse).toEqual({
body: JSON.stringify({ hash: '0x0000000000000000000000000000000000000000000000000000000000000006' }),
Expand Down Expand Up @@ -305,7 +305,7 @@ describe('Testing post order handler.', () => {
{ signature: '0xbad_signature' },
'{"detail":"\\"signature\\" with value \\"0xbad_signature\\" fails to match the required pattern: /^0x[0-9,a-z,A-Z]{130}$/","errorCode":"VALIDATION_ERROR"}',
],
[{ chainId: 0 }, `{"detail":"\\"chainId\\" must be one of [1, 5, 137, 12341234]","errorCode":"VALIDATION_ERROR"}`],
[{ chainId: 0 }, `{"detail":"\\"chainId\\" must be one of [1, 5, 137]","errorCode":"VALIDATION_ERROR"}`],
[{ quoteId: 'not_UUIDV4' }, '{"detail":"\\"quoteId\\" must be a valid GUID","errorCode":"VALIDATION_ERROR"}'],
])('Throws 400 with invalid field %p', async (invalidBodyField, bodyMsg) => {
const invalidEvent = {
Expand Down
4 changes: 2 additions & 2 deletions test/util/field-validator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ describe('Testing each field on the FieldValidator class.', () => {
const chainId = 'MAINNET'
const validatedField = FieldValidator.isValidChainId().validate(chainId)
expect(validatedField.error).toBeTruthy()
expect(validatedField.error?.details[0].message).toEqual(`"value" must be one of [1, 5, 137, 12341234]`)
expect(validatedField.error?.details[0].message).toEqual(`"value" must be one of [1, 5, 137]`)
})
it('should invalidate unsupported chain.', async () => {
const chainId = ChainId.ARBITRUM_ONE
const validatedField = FieldValidator.isValidChainId().validate(chainId)
expect(validatedField.error).toBeTruthy()
expect(validatedField.error?.details[0].message).toEqual(`"value" must be one of [1, 5, 137, 12341234]`)
expect(validatedField.error?.details[0].message).toEqual(`"value" must be one of [1, 5, 137]`)
})
})
describe('Testing nonce field.', () => {
Expand Down

0 comments on commit d5da57a

Please sign in to comment.