From a1d26a4072df3d6c3bb8de084f3c1c23a9a4c6e6 Mon Sep 17 00:00:00 2001 From: tgmichel Date: Fri, 5 May 2023 15:44:18 +0200 Subject: [PATCH] serde `input` alias support for `data` field in call/send (#1045) * Bump web3 1.9.0 * serde `input` alias support for `data` field in call/send --- client/rpc-core/src/types/call_request.rs | 1 + client/rpc-core/src/types/transaction_request.rs | 1 + ts-tests/package.json | 2 +- ts-tests/tests/test-execute.ts | 12 ++++++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/client/rpc-core/src/types/call_request.rs b/client/rpc-core/src/types/call_request.rs index 0214ab6446..163b18af9b 100644 --- a/client/rpc-core/src/types/call_request.rs +++ b/client/rpc-core/src/types/call_request.rs @@ -42,6 +42,7 @@ pub struct CallRequest { /// Value pub value: Option, /// Data + #[serde(alias = "input")] pub data: Option, /// Nonce pub nonce: Option, diff --git a/client/rpc-core/src/types/transaction_request.rs b/client/rpc-core/src/types/transaction_request.rs index af4cd73e29..43097f6a93 100644 --- a/client/rpc-core/src/types/transaction_request.rs +++ b/client/rpc-core/src/types/transaction_request.rs @@ -54,6 +54,7 @@ pub struct TransactionRequest { /// Value of transaction in wei pub value: Option, /// Additional data sent with transaction + #[serde(alias = "input")] pub data: Option, /// Transaction's nonce pub nonce: Option, diff --git a/ts-tests/package.json b/ts-tests/package.json index 6993af97dd..07e8d2ba73 100644 --- a/ts-tests/package.json +++ b/ts-tests/package.json @@ -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", diff --git a/ts-tests/tests/test-execute.ts b/ts-tests/tests/test-execute.ts index f26bc839d4..18f9d981ef 100644 --- a/ts-tests/tests/test-execute.ts +++ b/ts-tests/tests/test-execute.ts @@ -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); + }); });