Skip to content

Commit

Permalink
fix: lowercase getNonce address
Browse files Browse the repository at this point in the history
Orders are sanitized to have lowercased addresses before pumping into
the DB. This means all `offerers` in the nonce db also have lowercased
addresses. However, the getNonce query does not do sanitization, so if
any integrator requests eip-55 cased nonces, it will not find results in
the db. This commit sanitizes

However, we should hold out for the frontend to make a fix incrementing
the nonce. It's currently relying on nonce randomness to get new nonces
  • Loading branch information
marktoda committed Feb 1, 2024
1 parent 6faa466 commit 54f03fb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/repositories/generic-orders-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class GenericOrdersRepository<
}

public async getNonceByAddressAndChain(address: string, chainId: number): Promise<string> {
const res = await this.nonceEntity.query(`${address}-${chainId}`, {
const res = await this.nonceEntity.query(`${address.toLowerCase()}-${chainId}`, {
limit: 1,
reverse: true,
consistent: true,
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 @@ -43,7 +43,7 @@ describe('Testing get nonce handler.', () => {

it('Testing valid request and response.', async () => {
const getNonceResponse = await getNonceHandler.handler(event as any, {} as any)
expect(getNonceByAddressMock).toBeCalledWith(requestInjectedMock.address, 1)
expect(getNonceByAddressMock).toBeCalledWith(requestInjectedMock.address.toLowerCase(), 1)
expect(getNonceResponse).toMatchObject({
body: JSON.stringify({ nonce: MOCK_NONCE }),
statusCode: 200,
Expand Down

0 comments on commit 54f03fb

Please sign in to comment.