Skip to content

Commit 4dbcdea

Browse files
Nana-ECnatanasow
andauthored
Align transaction with ethereum execution apis (0.4) (#363)
Cherry-pick #338 to release/0.4 Update transaction response integers to be hexadecimal like ethereum execution apis schema Signed-off-by: Nikolay Atanasow <[email protected]> Signed-off-by: Nana-EC <[email protected]> Co-authored-by: Nikolay Atanasow <[email protected]>
1 parent 37d5eb6 commit 4dbcdea

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

packages/relay/src/lib/eth.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ export class EthImpl implements Eth {
780780
blockNumber: EthImpl.numberTo0x(contractResult.block_number),
781781
chainId: contractResult.chain_id,
782782
from: contractResult.from.substring(0, 42),
783-
gas: contractResult.gas_used,
783+
gas: EthImpl.numberTo0x(contractResult.gas_used),
784784
gasPrice: EthImpl.toNullIfEmptyHex(contractResult.gas_price),
785785
hash: contractResult.hash.substring(0, 66),
786786
input: contractResult.function_parameters,
@@ -790,10 +790,10 @@ export class EthImpl implements Eth {
790790
r: rSig,
791791
s: sSig,
792792
to: contractResult.to?.substring(0, 42),
793-
transactionIndex: contractResult.transaction_index,
793+
transactionIndex: EthImpl.numberTo0x(contractResult.transaction_index),
794794
type: contractResult.type,
795795
v: contractResult.v,
796-
value: contractResult.amount,
796+
value: EthImpl.numberTo0x(contractResult.amount),
797797
});
798798
}
799799

@@ -1035,7 +1035,7 @@ export class EthImpl implements Eth {
10351035
blockNumber: EthImpl.numberTo0x(contractResultDetails.block_number),
10361036
chainId: contractResultDetails.chain_id,
10371037
from: contractResultDetails.from.substring(0, 42),
1038-
gas: contractResultDetails.gas_used,
1038+
gas: EthImpl.numberTo0x(contractResultDetails.gas_used),
10391039
gasPrice: EthImpl.toNullIfEmptyHex(contractResultDetails.gas_price),
10401040
hash: contractResultDetails.hash.substring(0, 66),
10411041
input: contractResultDetails.function_parameters,
@@ -1045,10 +1045,10 @@ export class EthImpl implements Eth {
10451045
r: rSig,
10461046
s: sSig,
10471047
to: contractResultDetails.to.substring(0, 42),
1048-
transactionIndex: contractResultDetails.transaction_index,
1048+
transactionIndex: EthImpl.numberTo0x(contractResultDetails.transaction_index),
10491049
type: contractResultDetails.type,
10501050
v: contractResultDetails.v,
1051-
value: contractResultDetails.amount,
1051+
value: EthImpl.numberTo0x(contractResultDetails.amount),
10521052
});
10531053
})
10541054
.catch((e: any) => {

packages/relay/tests/lib/eth.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ describe('Eth', async function () {
13361336
"blockNumber": "0x11",
13371337
"chainId": "0x12a",
13381338
"from": "0x0000000000000000000000000000000000001f41",
1339-
"gas": 123,
1339+
"gas": "0x7b",
13401340
"gasPrice": "0x4a817c80",
13411341
"hash": defaultTxHash,
13421342
"input": "0x0707",
@@ -1346,10 +1346,10 @@ describe('Eth', async function () {
13461346
"r": "0xd693b532a80fed6392b428604171fb32fdbf953728a3a7ecc7d4062b1652c042",
13471347
"s": "0x24e9c602ac800b983b035700a14b23f78a253ab762deab5dc27e3555a750b354",
13481348
"to": "0x0000000000000000000000000000000000001389",
1349-
"transactionIndex": 1,
1349+
"transactionIndex": "0x1",
13501350
"type": 2,
13511351
"v": 1,
1352-
"value": 2000000000
1352+
"value": "0x77359400"
13531353
};
13541354

13551355
const defaultDetailedContractResultByHash = {

packages/server/tests/helpers/assertions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ export default class Assertions {
121121
expect(relayResponse.blockNumber).to.eq(ethers.utils.hexValue(mirrorNodeResponse.block_number));
122122
// expect(relayResponse.chainId).to.eq(mirrorNodeResponse.chain_id); // FIXME must not be null!
123123
expect(relayResponse.from).to.eq(mirrorNodeResponse.from);
124-
expect(relayResponse.gas).to.eq(mirrorNodeResponse.gas_used);
124+
expect(relayResponse.gas).to.eq(ethers.utils.hexValue(mirrorNodeResponse.gas_used));
125125
// expect(relayResponse.gasPrice).to.eq(mirrorNodeResponse.gas_price); // FIXME must not be null!
126126
expect(relayResponse.hash).to.eq(mirrorNodeResponse.hash.slice(0, 66));
127127
expect(relayResponse.input).to.eq(mirrorNodeResponse.function_parameters);
128128
expect(relayResponse.to).to.eq(mirrorNodeResponse.to);
129-
expect(relayResponse.transactionIndex).to.eq(mirrorNodeResponse.transaction_index);
130-
expect(relayResponse.value).to.eq(mirrorNodeResponse.amount);
129+
expect(relayResponse.transactionIndex).to.eq(ethers.utils.hexValue(mirrorNodeResponse.transaction_index));
130+
expect(relayResponse.value).to.eq(ethers.utils.hexValue(mirrorNodeResponse.amount));
131131
}
132132

133133
static transactionReceipt = (transactionReceipt, mirrorResult) => {

0 commit comments

Comments
 (0)