-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transaction input
and data
refactors
#6294
Changes from 5 commits
5c65103
7a5b5ca
7412abe
9d56a31
ee074e6
2f03bb7
f32feb6
a5b195d
24ae148
19023ea
1b0b30d
df836d5
e75e379
a4ca37c
d82de1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ import { Web3Eth } from '../../../src'; | |
import { | ||
closeOpenConnection, | ||
createTempAccount, | ||
getSystemTestBackend, | ||
getSystemTestProvider, | ||
} from '../../fixtures/system_test_utils'; | ||
|
||
|
@@ -47,17 +48,21 @@ describe('Web3Eth.signTransaction', () => { | |
gasPrice: '0x3b9aca01', | ||
}; | ||
const response = await web3Eth.signTransaction(transaction); | ||
expect(response).toMatchObject({ | ||
const expectedResponse: { tx: Transaction } = { | ||
tx: { | ||
type: BigInt(0), | ||
nonce: BigInt(nonce), | ||
gasPrice: BigInt(1000000001), | ||
gas: BigInt(21000), | ||
value: BigInt(1), | ||
to: transaction.to, | ||
input: '0x', | ||
}, | ||
}); | ||
}; | ||
if (getSystemTestBackend() === 'geth') expectedResponse.tx.input = '0x'; | ||
else if (getSystemTestBackend() === 'ganache') expectedResponse.tx.data = '0x'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This indicates a breaking change. We cannot be sure that no user used to fill |
||
|
||
expect(response).toMatchObject(expectedResponse); | ||
|
||
// Pulling out of toMatchObject to be compatiable with Cypress | ||
expect(response.raw).toMatch(/0[xX][0-9a-fA-F]+/); | ||
expect(typeof (response.tx as TransactionLegacySignedAPI).v).toBe('bigint'); | ||
|
@@ -77,16 +82,21 @@ describe('Web3Eth.signTransaction', () => { | |
gasPrice: '0x3b9aca01', | ||
}; | ||
const response = await web3Eth.signTransaction(transaction); | ||
// eslint-disable-next-line jest/no-standalone-expect | ||
expect(response).toMatchObject({ | ||
const expectedResponse: { tx: Transaction } = { | ||
tx: { | ||
type: BigInt(0), | ||
nonce: BigInt(nonce), | ||
gasPrice: BigInt(1000000001), | ||
gas: BigInt(475320), | ||
input: greeterContractDeploymentData, | ||
}, | ||
}); | ||
}; | ||
if (getSystemTestBackend() === 'geth') | ||
expectedResponse.tx.input = greeterContractDeploymentData; | ||
else if (getSystemTestBackend() === 'ganache') | ||
expectedResponse.tx.data = greeterContractDeploymentData; | ||
|
||
// eslint-disable-next-line jest/no-standalone-expect | ||
expect(response).toMatchObject(expectedResponse); | ||
// Pulling out of toMatchObject to be compatiable with Cypress | ||
expect(response.raw).toMatch(/0[xX][0-9a-fA-F]+/); | ||
expect(typeof (response.tx as TransactionLegacySignedAPI).v).toBe('bigint'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -409,7 +409,8 @@ export interface PopulatedUnsignedBaseTransaction { | |
gas?: Numbers; | ||
gasPrice: Numbers; | ||
type: Numbers; | ||
input: Bytes; | ||
input?: Bytes; | ||
data?: Bytes; | ||
Comment on lines
+412
to
+413
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a breaking change for |
||
nonce: Numbers; | ||
networkId: Numbers; | ||
chain: ValidChains; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The property name is still
data
because that's what TransactionFactory.fromTxData is expecting