@@ -56,7 +56,7 @@ import {
5656} from '../helpers' ;
5757
5858import pino from 'pino' ;
59- import { Log , Transaction } from '../../src/lib/model' ;
59+ import { Log , Transaction , Transaction1559 , Transaction2930 } from '../../src/lib/model' ;
6060import constants from '../../src/lib/constants' ;
6161import { SDKClient } from '../../src/lib/clients' ;
6262import { SDKClientError } from '../../src/lib/errors/SDKClientError' ;
@@ -282,6 +282,39 @@ describe('Eth calls using MirrorNode', async function () {
282282 }
283283 } ;
284284
285+ const contractResultMock = {
286+ address : '0x67d8d32e9bf1a9968a5ff53b87d777aa8ebbee69' ,
287+ amount : 20 ,
288+ bloom : '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' ,
289+ call_result : '0x' ,
290+ contract_id : '0.0.1012' ,
291+ created_contract_ids : [ ] ,
292+ error_message : null ,
293+ from : '0x00000000000000000000000000000000000003f7' ,
294+ function_parameters : '0x' ,
295+ gas_limit : 250000 ,
296+ gas_used : 200000 ,
297+ timestamp : '1692959189.214316721' ,
298+ to : '0x00000000000000000000000000000000000003f4' ,
299+ hash : '0x7e8a09541c80ccda1f5f40a1975e031ed46de5ad7f24cd4c37be9bac65149b9e' ,
300+ block_hash : '0xa414a76539f84ae1c797fa10d00e49d5e7a1adae556dcd43084551e671623d2eba825bcb7bbfd5b7e3fe59d63d8a167f' ,
301+ block_number : 61033 ,
302+ logs : [ ] ,
303+ result : 'SUCCESS' ,
304+ transaction_index : 2 ,
305+ state_changes : [ ] ,
306+ status : '0x1' ,
307+ failed_initcode : null ,
308+ block_gas_used : 200000 ,
309+ chain_id : '0x12a' ,
310+ gas_price : '0x' ,
311+ r : '0x85b423416d0164d0b2464d880bccb0679587c00673af8e016c8f0ce573be69b2' ,
312+ s : '0x3897a5ce2ace1f242d9c989cd9c163d79760af4266f3bf2e69ee288bcffb211a' ,
313+ type : 2 ,
314+ v : 1 ,
315+ nonce : 9
316+ } ;
317+
285318 const defaultLogTopics = [
286319 "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" ,
287320 "0x0000000000000000000000000000000000000000000000000000000000000000" ,
@@ -1293,6 +1326,46 @@ describe('Eth calls using MirrorNode', async function () {
12931326 expect ( result ) . to . equal ( null ) ;
12941327 } ) ;
12951328
1329+ it ( 'eth_getTransactionByBlockHashAndIndex returns 155 transaction for type 0' , async function ( ) {
1330+ restMock . onGet ( `contracts/results?block.hash=${ defaultBlock . hash } &transaction.index=${ defaultBlock . count } &limit=100&order=asc` ) . reply ( 200 , {
1331+ 'results' : [ {
1332+ ...contractResultMock ,
1333+ type : 0
1334+ } ]
1335+ } ) ;
1336+
1337+ const result = await ethImpl . getTransactionByBlockHashAndIndex ( defaultBlock . hash . toString ( ) , numberTo0x ( defaultBlock . count ) ) ;
1338+ expect ( result ) . to . be . an . instanceOf ( Transaction ) ;
1339+ } ) ;
1340+
1341+ it ( 'eth_getTransactionByBlockHashAndIndex returns 2930 transaction for type 1' , async function ( ) {
1342+ restMock . onGet ( `contracts/results?block.hash=${ defaultBlock . hash } &transaction.index=${ defaultBlock . count } &limit=100&order=asc` ) . reply ( 200 , {
1343+ 'results' : [ {
1344+ ...contractResultMock ,
1345+ type : 1 ,
1346+ access_list : [ ]
1347+ } ]
1348+ } ) ;
1349+
1350+ const result = await ethImpl . getTransactionByBlockHashAndIndex ( defaultBlock . hash . toString ( ) , numberTo0x ( defaultBlock . count ) ) ;
1351+ expect ( result ) . to . be . an . instanceOf ( Transaction2930 ) ;
1352+ } ) ;
1353+
1354+ it ( 'eth_getTransactionByBlockHashAndIndex returns 1559 transaction for type 2' , async function ( ) {
1355+ restMock . onGet ( `contracts/results?block.hash=${ defaultBlock . hash } &transaction.index=${ defaultBlock . count } &limit=100&order=asc` ) . reply ( 200 , {
1356+ 'results' : [ {
1357+ ...contractResultMock ,
1358+ type : 2 ,
1359+ access_list : [ ] ,
1360+ max_fee_per_gas : '0x47' ,
1361+ max_priority_fee_per_gas : '0x47'
1362+ } ]
1363+ } ) ;
1364+
1365+ const result = await ethImpl . getTransactionByBlockHashAndIndex ( defaultBlock . hash . toString ( ) , numberTo0x ( defaultBlock . count ) ) ;
1366+ expect ( result ) . to . be . an . instanceOf ( Transaction1559 ) ;
1367+ } ) ;
1368+
12961369 describe ( 'Block transaction count' , async function ( ) {
12971370 let currentMaxBlockRange : number ;
12981371
@@ -4936,15 +5009,89 @@ describe('Eth', async function () {
49365009 } ) ;
49375010
49385011 describe ( 'eth_getTransactionByHash' , async function ( ) {
4939- const uniqueTxHash = '0x27cad7b827375d12d73af57b6a3e84353645fd31305ea58ff52dda53ec640533' ;
5012+ const from = '0x00000000000000000000000000000000000003f7' ;
5013+ const evm_address = '0xc37f417fa09933335240fca72dd257bfbde9c275' ;
5014+ const contractResultMock = {
5015+ address : '0x67d8d32e9bf1a9968a5ff53b87d777aa8ebbee69' ,
5016+ amount : 20 ,
5017+ bloom : '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' ,
5018+ call_result : '0x' ,
5019+ contract_id : '0.0.1012' ,
5020+ created_contract_ids : [ ] ,
5021+ error_message : null ,
5022+ from : '0x00000000000000000000000000000000000003f7' ,
5023+ function_parameters : '0x' ,
5024+ gas_limit : 250000 ,
5025+ gas_used : 200000 ,
5026+ timestamp : '1692959189.214316721' ,
5027+ to : '0x00000000000000000000000000000000000003f4' ,
5028+ hash : '0x7e8a09541c80ccda1f5f40a1975e031ed46de5ad7f24cd4c37be9bac65149b9e' ,
5029+ block_hash : '0xa414a76539f84ae1c797fa10d00e49d5e7a1adae556dcd43084551e671623d2eba825bcb7bbfd5b7e3fe59d63d8a167f' ,
5030+ block_number : 61033 ,
5031+ logs : [ ] ,
5032+ result : 'SUCCESS' ,
5033+ transaction_index : 2 ,
5034+ state_changes : [ ] ,
5035+ status : '0x1' ,
5036+ failed_initcode : null ,
5037+ block_gas_used : 200000 ,
5038+ chain_id : '0x12a' ,
5039+ gas_price : '0x' ,
5040+ r : '0x85b423416d0164d0b2464d880bccb0679587c00673af8e016c8f0ce573be69b2' ,
5041+ s : '0x3897a5ce2ace1f242d9c989cd9c163d79760af4266f3bf2e69ee288bcffb211a' ,
5042+ v : 1 ,
5043+ nonce : 9
5044+ } ;
49405045
4941- beforeEach ( function ( ) {
5046+ this . beforeEach ( function ( ) {
5047+ restMock . reset ( ) ;
49425048 restMock . onGet ( `accounts/${ defaultFromLongZeroAddress } ${ noTransactions } ` ) . reply ( 200 , {
49435049 evm_address : `${ defaultTransaction . from } `
49445050 } ) ;
5051+ restMock . onGet ( `accounts/${ from } ?transactions=false` ) . reply ( 200 , {
5052+ evm_address : evm_address
5053+ } ) ;
5054+ } ) ;
5055+
5056+ it ( 'returns 155 transaction for type 0' , async function ( ) {
5057+ const uniqueTxHash = '0x27cad7b827375d12d73af57b6a3e84353645fd31305ea58ff52dda53ec640533' ;
5058+ restMock . onGet ( `contracts/results/${ uniqueTxHash } ` ) . reply ( 200 , {
5059+ ...contractResultMock ,
5060+ type : 0
5061+ } ) ;
5062+
5063+ const result = await ethImpl . getTransactionByHash ( uniqueTxHash ) ;
5064+ expect ( result ) . to . be . an . instanceOf ( Transaction ) ;
5065+ } ) ;
5066+
5067+ it ( 'returns 2930 transaction for type 1' , async function ( ) {
5068+ const uniqueTxHash = '0x28cad7b827375d12d73af57b6a3e84353645fd31305ea58ff52dda53ec640533' ;
5069+ restMock . onGet ( `contracts/results/${ uniqueTxHash } ` ) . reply ( 200 , {
5070+ ...contractResultMock ,
5071+ type : 1 ,
5072+ access_list : [ ]
5073+ } ) ;
5074+
5075+ const result = await ethImpl . getTransactionByHash ( uniqueTxHash ) ;
5076+ expect ( result ) . to . be . an . instanceOf ( Transaction2930 ) ;
5077+ } ) ;
5078+
5079+ it ( 'returns 1559 transaction for type 2' , async function ( ) {
5080+ const uniqueTxHash = '0x27cad7b827375d12d73af57b7a3e84353645fd31305ea58ff52dda53ec640533' ;
5081+ restMock . onGet ( `contracts/results/${ uniqueTxHash } ` ) . reply ( 200 , {
5082+ ...contractResultMock ,
5083+ type : 2 ,
5084+ access_list : [ ] ,
5085+ max_fee_per_gas : '0x47' ,
5086+ max_priority_fee_per_gas : '0x47'
5087+ } ) ;
5088+
5089+ const result = await ethImpl . getTransactionByHash ( uniqueTxHash ) ;
5090+ expect ( result ) . to . be . an . instanceOf ( Transaction1559 ) ;
49455091 } ) ;
49465092
49475093 it ( 'returns `null` for non-existing hash' , async function ( ) {
5094+ const uniqueTxHash = '0x27cAd7b838375d12d73af57b6a3e84353645fd31305ea58ff52dda53ec640533' ;
49485095 restMock . onGet ( `contracts/results/${ uniqueTxHash } ` ) . reply ( 404 , {
49495096 '_status' : {
49505097 'messages' : [
0 commit comments