diff --git a/packages/web3-providers/src/batch-request/BatchRequest.js b/packages/web3-providers/src/batch-request/BatchRequest.js index 8b5c4423346..029ed38be35 100644 --- a/packages/web3-providers/src/batch-request/BatchRequest.js +++ b/packages/web3-providers/src/batch-request/BatchRequest.js @@ -86,7 +86,7 @@ export default class BatchRequest { let mappedResult; // TODO: Find a better handling for custom behaviours in a batch request (afterBatchRequest?) - if (method.Type === 'eth-send-transaction-method') { + if (method.Type === 'eth-send-transaction-method' || method.Type === 'observed-transaction-method') { mappedResult = responseItem.result; } else { mappedResult = method.afterExecution(responseItem.result); diff --git a/packages/web3-providers/tests/src/batch-request/BatchRequestTest.js b/packages/web3-providers/tests/src/batch-request/BatchRequestTest.js index 8c81d97f89d..0472cbcaaa1 100644 --- a/packages/web3-providers/tests/src/batch-request/BatchRequestTest.js +++ b/packages/web3-providers/tests/src/batch-request/BatchRequestTest.js @@ -309,6 +309,30 @@ describe('BatchRequestTest', () => { expect(JsonRpcMapper.toPayload).toHaveBeenCalledWith('rpc_method', [true]); }); + it('calls execute with the SendRawTransactionMethod and returns a resolved promise', async () => { + JsonRpcResponseValidator.validate.mockReturnValueOnce(true); + + JsonRpcMapper.toPayload.mockReturnValueOnce({}); + + providerMock.sendPayload = jest.fn((payload) => { + expect(payload).toEqual([{}]); + + return Promise.resolve([{result: true}]); + }); + + abstractMethodMock.Type = 'observed-transaction-method'; + batchRequest.add(abstractMethodMock); + + await expect(batchRequest.execute()).resolves.toEqual({ + methods: [abstractMethodMock], + response: [true] + }); + + expect(JsonRpcResponseValidator.validate).toHaveBeenCalled(); + + expect(JsonRpcMapper.toPayload).toHaveBeenCalledWith('rpc_method', [true]); + }); + it('calls execute with accounts defined and returns a resolved promise', async () => { JsonRpcResponseValidator.validate.mockReturnValueOnce(false);