Skip to content

Commit

Permalink
serde input alias support for data field in call/send (polkadot-e…
Browse files Browse the repository at this point in the history
…vm#1045)

* Bump web3 1.9.0

* serde `input` alias support for `data` field in call/send
  • Loading branch information
tgmichel authored and ashutoshvarma committed Jun 8, 2023
1 parent 9bce3c8 commit a1d26a4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions client/rpc-core/src/types/call_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub struct CallRequest {
/// Value
pub value: Option<U256>,
/// Data
#[serde(alias = "input")]
pub data: Option<Bytes>,
/// Nonce
pub nonce: Option<U256>,
Expand Down
1 change: 1 addition & 0 deletions client/rpc-core/src/types/transaction_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub struct TransactionRequest {
/// Value of transaction in wei
pub value: Option<U256>,
/// Additional data sent with transaction
#[serde(alias = "input")]
pub data: Option<Bytes>,
/// Transaction's nonce
pub nonce: Option<U256>,
Expand Down
2 changes: 1 addition & 1 deletion ts-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"truffle": "^5.7.0",
"ts-node": "^8.10.2",
"typescript": "^3.9.6",
"web3": "^1.8.0"
"web3": "^1.9.0"
},
"devDependencies": {
"@types/chai-as-promised": "^7.1.5",
Expand Down
12 changes: 12 additions & 0 deletions ts-tests/tests/test-execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,16 @@ describeWithFrontier("Frontier RPC (RPC execution)", (context) => {
id: 1,
});
});

step("`input` field alias is properly deserialized", async function () {
const result = await customRequest(context.web3, "eth_call", [
{
from: GENESIS_ACCOUNT,
gas: `0x${(ETH_BLOCK_GAS_LIMIT - 1).toString(16)}`,
input: TEST_CONTRACT_BYTECODE,
},
]);

expect(result.result).to.be.equal(TEST_CONTRACT_DEPLOYED_BYTECODE);
});
});

0 comments on commit a1d26a4

Please sign in to comment.