diff --git a/.changeset/lazy-buttons-fly.md b/.changeset/lazy-buttons-fly.md new file mode 100644 index 0000000..7de3e48 --- /dev/null +++ b/.changeset/lazy-buttons-fly.md @@ -0,0 +1,5 @@ +--- +"@open-frames/proxy": patch +--- + +type fixes diff --git a/packages/server/src/handlers.ts b/packages/server/src/handlers.ts index 27bdc9e..293e28e 100644 --- a/packages/server/src/handlers.ts +++ b/packages/server/src/handlers.ts @@ -150,7 +150,8 @@ export async function postTransaction(url: string, body: unknown) { throw new Error(`Request failed with status ${response.status}`); } - const validatedTransactionResponse = parseAndValidateTransactionResponse(response.json()); + const responseData: TransactionResponse = (await response.json()) as TransactionResponse; + const validatedTransactionResponse = parseAndValidateTransactionResponse(responseData); if (!validatedTransactionResponse) { throw new Error(`Invalid transaction response from ${url}`); } else { diff --git a/packages/server/src/parser.test.ts b/packages/server/src/parser.test.ts index 49a3c94..01817dd 100644 --- a/packages/server/src/parser.test.ts +++ b/packages/server/src/parser.test.ts @@ -1,6 +1,7 @@ import { readFile } from 'node:fs/promises'; import { createServer, Server } from 'node:http'; +import { TransactionResponse } from '@open-frames/proxy-types'; import { afterAll, beforeAll, describe, expect, test } from 'vitest'; import { downloadAndExtract } from './handlers.js'; @@ -262,7 +263,7 @@ describe('parseAndValidateTransactionResponse', () => { value: '1000', data: '0x00', }, - }; + } as TransactionResponse; expect(parseAndValidateTransactionResponse(validInput)).toEqual(validInput); }); @@ -276,7 +277,7 @@ describe('parseAndValidateTransactionResponse', () => { value: '1000', data: '0x00', }, - }; + } as unknown as TransactionResponse; expect(parseAndValidateTransactionResponse(validInput)).toEqual(validInput); }); @@ -287,7 +288,7 @@ describe('parseAndValidateTransactionResponse', () => { params: { abi: 'invalid abi', }, - }; + } as unknown as TransactionResponse; expect(parseAndValidateTransactionResponse(invalidChainId)).toBeNull(); }); test('should return null when input method is eth_sendTransaction with invalid chainId', () => { @@ -300,7 +301,7 @@ describe('parseAndValidateTransactionResponse', () => { value: '1000', data: '0x00', }, - }; + } as TransactionResponse; expect(parseAndValidateTransactionResponse(invalidChainId)).toBeNull(); }); });