Skip to content

Commit

Permalink
Merge branch '4.x' into 6187-typeerror-cannot-convert-a-bigint-value-…
Browse files Browse the repository at this point in the history
…to-a-number
  • Loading branch information
Muhammad-Altabba authored Oct 12, 2023
2 parents d3a1a18 + 6e43d1b commit 85a5b37
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ await web3.eth.getFeeHistory('0x1', 'latest', []);

#### sending

- In 1.x, the event listener would receive a `payload` object as an argument. In 4.x, just the sent transaction object is recieved
- In 1.x, the event listener would receive a `payload` object as an argument. In 4.x, just the sent transaction object is received

```typescript
// in 1.x
Expand Down Expand Up @@ -211,7 +211,7 @@ web3.eth.sendTransaction({ ... }).on('sending', (sendTransactionObject) => { ...

#### sent

- In 1.x, the event listener would receive a `payload` object as an argument. In 4.x just the sent transaction object is recieved
- In 1.x, the event listener would receive a `payload` object as an argument. In 4.x just the sent transaction object is received

```typescript
// in 1.x
Expand Down
2 changes: 1 addition & 1 deletion docs/src/theme/SearchBar/algolia.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
.algolia-docsearch-suggestion--highlight {
color: #3a33d1;
}
/* Highligted search terms in the main category headers */
/* Highlighted search terms in the main category headers */
.algolia-docsearch-suggestion--category-header
.algolia-docsearch-suggestion--highlight {
background-color: #4d47d5;
Expand Down
1 change: 1 addition & 0 deletions packages/web3-eth/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ Documentation:
### Fixed

- Ensure provider.supportsSubscriptions exists before watching by subscription (#6440)
- Fixed param sent to `checkRevertBeforeSending` in `sendSignedTransaction`

### Added

Expand Down
5 changes: 4 additions & 1 deletion packages/web3-eth/src/rpc_method_wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,11 @@ export function sendSignedTransaction<
};

try {
const { v , r , s,
...txWithoutSigParams} = unSerializedTransactionWithFrom;

await sendTxHelper.checkRevertBeforeSending(
unSerializedTransactionWithFrom as TransactionCall,
txWithoutSigParams as TransactionCall,
);

sendTxHelper.emitSending(signedTransactionFormattedHex);
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth/test/e2e/e2e_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { getSystemTestBackend } from '../fixtures/system_test_utils';
import secrets from '../../../../.secrets.json';

export const getSystemE2ETestProvider = (): string => {
if (process.env.WEB3_SYTEM_TEST_MODE === 'http') {
if (process.env.WEB3_SYSTEM_TEST_MODE === 'http') {
return getSystemTestBackend() === 'sepolia'
? process.env.INFURA_SEPOLIA_HTTP ?? secrets.SEPOLIA.HTTP
: process.env.INFURA_MAINNET_HTTP ?? secrets.MAINNET.HTTP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
testData,
} from './fixtures/send_signed_transaction';
import { transactionReceiptSchema } from '../../../src/schemas';
import { SendTxHelper } from '../../../src/utils/send_tx_helper';

jest.mock('web3-rpc-methods');
jest.mock('../../../src/utils/wait_for_transaction_receipt');
Expand All @@ -45,6 +46,42 @@ describe('sendTransaction', () => {

afterEach(() => jest.resetAllMocks());

it.each(testData)(
`should remove signature part in transaction before checkRevertBeforeSending`,
async (_, inputSignedTransaction) => {
(
WaitForTransactionReceipt.waitForTransactionReceipt as jest.Mock
).mockResolvedValueOnce(expectedTransactionReceipt);

const checkRevertBeforeSendingSpy = jest.fn().mockImplementation((transaction) => {
expect(transaction).toBeDefined();

// verify signature part is removed before sending to revert check function
expect(transaction).not.toHaveProperty('v');
expect(transaction).not.toHaveProperty('r');
expect(transaction).not.toHaveProperty('s');
});

SendTxHelper.prototype.checkRevertBeforeSending = checkRevertBeforeSendingSpy;

const inputSignedTransactionFormatted = format(
{ format: 'bytes' },
inputSignedTransaction,
DEFAULT_RETURN_FORMAT,
);
await sendSignedTransaction(web3Context, inputSignedTransaction, DEFAULT_RETURN_FORMAT);

// verify original tx params are intact
expect(ethRpcMethods.sendRawTransaction).toHaveBeenCalledWith(
web3Context.requestManager,
inputSignedTransactionFormatted,
);

expect(checkRevertBeforeSendingSpy).toHaveBeenCalledTimes(1);

},
);

it.each(testData)(
`sending event should emit with inputSignedTransaction\n ${testMessage}`,
async (_, inputSignedTransaction) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/web3/test/e2e/e2e_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { getSystemTestBackend } from '../shared_fixtures/system_tests_utils';
import secrets from '../../../../.secrets.json';

export const getSystemE2ETestProvider = (): string => {
if (process.env.WEB3_SYTEM_TEST_MODE === 'http') {
if (process.env.WEB3_SYSTEM_TEST_MODE === 'http') {
return getSystemTestBackend() === 'sepolia'
? process.env.INFURA_SEPOLIA_HTTP ?? secrets.SEPOLIA.HTTP
: process.env.INFURA_MAINNET_HTTP ?? secrets.MAINNET.HTTP;
Expand Down
2 changes: 1 addition & 1 deletion scripts/test-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fi
echo "Node software used for tests: " $BACKEND
echo "Node running on: " "$MODE://127.0.0.1:$WEB3_SYSTEM_TEST_PORT"

export WEB3_SYTEM_TEST_MODE=$MODE
export WEB3_SYSTEM_TEST_MODE=$MODE
export WEB3_SYSTEM_TEST_PROVIDER="$MODE://127.0.0.1:$WEB3_SYSTEM_TEST_PORT"
export WEB3_SYSTEM_TEST_BACKEND=$BACKEND
export WEB3_SYSTEM_TEST_ENGINE=$ENGINE
Expand Down

0 comments on commit 85a5b37

Please sign in to comment.