@@ -69,7 +69,7 @@ describe('address tests', () => {
69
69
const testAddr2 = 'ST1HB64MAJ1MBV4CQ80GF01DZS4T1DSMX20ADCRA4' ;
70
70
const testContractAddr = 'ST27W5M8BRKA7C5MZE2R1S1F4XTPHFWFRNHA9M04Y.hello-world' ;
71
71
const testAddr4 = 'ST3DWSXBPYDB484QXFTR81K4AWG4ZB5XZNFF3H70C' ;
72
- const testTxId = '0x03807fdb726b3cb843e0330c564a4974037be8f9ea58ec7f8ebe03c34b890006 ' ;
72
+ const testTxId = '0x03807fdb726b3cb843e0330c564a4974037be8f9ea58ec7f8ebe03c34b890008 ' ;
73
73
74
74
const block : DbBlock = {
75
75
block_hash : '0x1234' ,
@@ -99,7 +99,8 @@ describe('address tests', () => {
99
99
canonical : boolean = true ,
100
100
stxEventCount = 1 ,
101
101
ftEventCount = 1 ,
102
- nftEventCount = 1
102
+ nftEventCount = 1 ,
103
+ eventAddressesOnly = false
103
104
) : [ DbTxRaw , DbStxEvent [ ] , DbFtEvent [ ] , DbNftEvent [ ] ] => {
104
105
const tx : DbTxRaw = {
105
106
tx_id :
@@ -117,7 +118,7 @@ describe('address tests', () => {
117
118
type_id : DbTxTypeId . TokenTransfer ,
118
119
token_transfer_amount : BigInt ( amount ) ,
119
120
token_transfer_memo : bufferToHex ( Buffer . from ( 'hi' ) ) ,
120
- token_transfer_recipient_address : recipient ,
121
+ token_transfer_recipient_address : eventAddressesOnly ? '' : recipient ,
121
122
status : 1 ,
122
123
raw_result : '0x0100000000000000000000000000000001' , // u1
123
124
canonical,
@@ -130,7 +131,7 @@ describe('address tests', () => {
130
131
fee_rate : 1234n ,
131
132
sponsored : false ,
132
133
sponsor_address : undefined ,
133
- sender_address : sender ,
134
+ sender_address : eventAddressesOnly ? '' : sender ,
134
135
origin_hash_mode : 1 ,
135
136
event_count : 0 ,
136
137
execution_cost_read_count : 1 ,
@@ -193,6 +194,8 @@ describe('address tests', () => {
193
194
return [ tx , stxEvents , ftEvents , nftEvents ] ;
194
195
} ;
195
196
const txs = [
197
+ createStxTx ( testAddr4 , testAddr2 , 0 , true , 0 , 1 , 0 , true ) ,
198
+ createStxTx ( testAddr4 , testAddr2 , 0 , true , 0 , 0 , 1 , true ) ,
196
199
createStxTx ( testAddr1 , testAddr2 , 100_000 , true , 1 , 1 , 1 ) ,
197
200
createStxTx ( testAddr2 , testContractAddr , 100 , true , 1 , 2 , 1 ) ,
198
201
createStxTx ( testAddr2 , testContractAddr , 250 , true , 1 , 0 , 1 ) ,
@@ -228,11 +231,11 @@ describe('address tests', () => {
228
231
const expected1 = {
229
232
limit : 3 ,
230
233
offset : 0 ,
231
- total : 4 ,
234
+ total : 6 ,
232
235
results : [
233
236
{
234
237
tx : {
235
- tx_id : '0x03807fdb726b3cb843e0330c564a4974037be8f9ea58ec7f8ebe03c34b890006 ' ,
238
+ tx_id : '0x03807fdb726b3cb843e0330c564a4974037be8f9ea58ec7f8ebe03c34b890008 ' ,
236
239
tx_type : 'token_transfer' ,
237
240
nonce : 0 ,
238
241
anchor_mode : 'any' ,
@@ -254,7 +257,7 @@ describe('address tests', () => {
254
257
parent_block_hash : '0x' ,
255
258
parent_burn_block_time : 1626122935 ,
256
259
parent_burn_block_time_iso : '2021-07-12T20:48:55.000Z' ,
257
- tx_index : 6 ,
260
+ tx_index : 8 ,
258
261
tx_result : { hex : '0x0100000000000000000000000000000001' , repr : 'u1' } ,
259
262
token_transfer : {
260
263
recipient_address : 'ST3DWSXBPYDB484QXFTR81K4AWG4ZB5XZNFF3H70C' ,
@@ -319,7 +322,7 @@ describe('address tests', () => {
319
322
} ,
320
323
{
321
324
tx : {
322
- tx_id : '0x03807fdb726b3cb843e0330c564a4974037be8f9ea58ec7f8ebe03c34b890003 ' ,
325
+ tx_id : '0x03807fdb726b3cb843e0330c564a4974037be8f9ea58ec7f8ebe03c34b890005 ' ,
323
326
tx_type : 'token_transfer' ,
324
327
nonce : 0 ,
325
328
anchor_mode : 'any' ,
@@ -341,7 +344,7 @@ describe('address tests', () => {
341
344
parent_block_hash : '0x' ,
342
345
parent_burn_block_time : 1626122935 ,
343
346
parent_burn_block_time_iso : '2021-07-12T20:48:55.000Z' ,
344
- tx_index : 3 ,
347
+ tx_index : 5 ,
345
348
tx_result : { hex : '0x0100000000000000000000000000000001' , repr : 'u1' } ,
346
349
token_transfer : {
347
350
recipient_address : 'ST27W5M8BRKA7C5MZE2R1S1F4XTPHFWFRNHA9M04Y.hello-world' ,
@@ -380,7 +383,7 @@ describe('address tests', () => {
380
383
} ,
381
384
{
382
385
tx : {
383
- tx_id : '0x03807fdb726b3cb843e0330c564a4974037be8f9ea58ec7f8ebe03c34b890002 ' ,
386
+ tx_id : '0x03807fdb726b3cb843e0330c564a4974037be8f9ea58ec7f8ebe03c34b890004 ' ,
384
387
tx_type : 'token_transfer' ,
385
388
nonce : 0 ,
386
389
anchor_mode : 'any' ,
@@ -402,7 +405,7 @@ describe('address tests', () => {
402
405
parent_block_hash : '0x' ,
403
406
parent_burn_block_time : 1626122935 ,
404
407
parent_burn_block_time_iso : '2021-07-12T20:48:55.000Z' ,
405
- tx_index : 2 ,
408
+ tx_index : 4 ,
406
409
tx_result : { hex : '0x0100000000000000000000000000000001' , repr : 'u1' } ,
407
410
token_transfer : {
408
411
recipient_address : 'ST27W5M8BRKA7C5MZE2R1S1F4XTPHFWFRNHA9M04Y.hello-world' ,
@@ -454,7 +457,8 @@ describe('address tests', () => {
454
457
} ,
455
458
] ,
456
459
} ;
457
- expect ( JSON . parse ( fetch1 . text ) ) . toEqual ( expected1 ) ;
460
+ const fetch1Json = JSON . parse ( fetch1 . text ) ;
461
+ expect ( fetch1Json ) . toEqual ( expected1 ) ;
458
462
459
463
// Test v2 endpoints
460
464
const v2Fetch1 = await supertest ( api . server ) . get (
@@ -463,6 +467,7 @@ describe('address tests', () => {
463
467
expect ( v2Fetch1 . status ) . toBe ( 200 ) ;
464
468
expect ( v2Fetch1 . type ) . toBe ( 'application/json' ) ;
465
469
const v2Fetch1Json = JSON . parse ( v2Fetch1 . text ) ;
470
+ expect ( v2Fetch1Json . total ) . toBe ( 6 ) ;
466
471
expect ( v2Fetch1Json . results [ 0 ] . tx ) . toStrictEqual ( expected1 . results [ 0 ] . tx ) ;
467
472
expect ( v2Fetch1Json . results [ 0 ] . stx_sent ) . toBe ( '1339' ) ;
468
473
expect ( v2Fetch1Json . results [ 0 ] . stx_received ) . toBe ( '0' ) ;
@@ -517,6 +522,40 @@ describe('address tests', () => {
517
522
mint : 0 ,
518
523
burn : 0 ,
519
524
} ) ;
525
+ expect ( v2Fetch1Json . results [ 4 ] . stx_sent ) . toBe ( '1234' ) ;
526
+ expect ( v2Fetch1Json . results [ 4 ] . stx_received ) . toBe ( '0' ) ;
527
+ expect ( v2Fetch1Json . results [ 4 ] . events . stx ) . toStrictEqual ( {
528
+ transfer : 0 ,
529
+ mint : 0 ,
530
+ burn : 0 ,
531
+ } ) ;
532
+ expect ( v2Fetch1Json . results [ 4 ] . events . ft ) . toStrictEqual ( {
533
+ transfer : 0 ,
534
+ mint : 0 ,
535
+ burn : 0 ,
536
+ } ) ;
537
+ expect ( v2Fetch1Json . results [ 4 ] . events . nft ) . toStrictEqual ( {
538
+ transfer : 1 ,
539
+ mint : 0 ,
540
+ burn : 0 ,
541
+ } ) ;
542
+ expect ( v2Fetch1Json . results [ 5 ] . stx_sent ) . toBe ( '1234' ) ;
543
+ expect ( v2Fetch1Json . results [ 5 ] . stx_received ) . toBe ( '0' ) ;
544
+ expect ( v2Fetch1Json . results [ 5 ] . events . stx ) . toStrictEqual ( {
545
+ transfer : 0 ,
546
+ mint : 0 ,
547
+ burn : 0 ,
548
+ } ) ;
549
+ expect ( v2Fetch1Json . results [ 5 ] . events . ft ) . toStrictEqual ( {
550
+ transfer : 1 ,
551
+ mint : 0 ,
552
+ burn : 0 ,
553
+ } ) ;
554
+ expect ( v2Fetch1Json . results [ 5 ] . events . nft ) . toStrictEqual ( {
555
+ transfer : 0 ,
556
+ mint : 0 ,
557
+ burn : 0 ,
558
+ } ) ;
520
559
521
560
const v2Fetch2 = await supertest ( api . server ) . get (
522
561
`/extended/v2/addresses/${ testAddr2 } /transactions/${ v2Fetch1Json . results [ 0 ] . tx . tx_id } /events?limit=3`
@@ -620,7 +659,7 @@ describe('address tests', () => {
620
659
expect ( fetchSingleTxInformation . type ) . toBe ( 'application/json' ) ;
621
660
const expectedSingleTxInformation = {
622
661
tx : {
623
- tx_id : '0x03807fdb726b3cb843e0330c564a4974037be8f9ea58ec7f8ebe03c34b890006 ' ,
662
+ tx_id : '0x03807fdb726b3cb843e0330c564a4974037be8f9ea58ec7f8ebe03c34b890008 ' ,
624
663
tx_type : 'token_transfer' ,
625
664
nonce : 0 ,
626
665
anchor_mode : 'any' ,
@@ -642,7 +681,7 @@ describe('address tests', () => {
642
681
parent_block_hash : '0x' ,
643
682
parent_burn_block_time : 1626122935 ,
644
683
parent_burn_block_time_iso : '2021-07-12T20:48:55.000Z' ,
645
- tx_index : 6 ,
684
+ tx_index : 8 ,
646
685
tx_result : { hex : '0x0100000000000000000000000000000001' , repr : 'u1' } ,
647
686
token_transfer : {
648
687
recipient_address : 'ST3DWSXBPYDB484QXFTR81K4AWG4ZB5XZNFF3H70C' ,
@@ -681,18 +720,18 @@ describe('address tests', () => {
681
720
682
721
// testing for multiple tx_ids given a single stx addr
683
722
const fetch2 = await supertest ( api . server ) . get (
684
- `/extended/v1/address/${ testAddr4 } /transactions_with_transfers`
723
+ `/extended/v1/address/${ testAddr4 } /transactions_with_transfers?limit=2 `
685
724
) ;
686
725
expect ( fetch2 . status ) . toBe ( 200 ) ;
687
726
expect ( fetch2 . type ) . toBe ( 'application/json' ) ;
688
727
const expected2 = {
689
- limit : 20 ,
728
+ limit : 2 ,
690
729
offset : 0 ,
691
- total : 2 ,
730
+ total : 4 ,
692
731
results : [
693
732
{
694
733
tx : {
695
- tx_id : '0x03807fdb726b3cb843e0330c564a4974037be8f9ea58ec7f8ebe03c34b890006 ' ,
734
+ tx_id : '0x03807fdb726b3cb843e0330c564a4974037be8f9ea58ec7f8ebe03c34b890008 ' ,
696
735
tx_type : 'token_transfer' ,
697
736
nonce : 0 ,
698
737
anchor_mode : 'any' ,
@@ -714,7 +753,7 @@ describe('address tests', () => {
714
753
parent_block_hash : '0x' ,
715
754
parent_burn_block_time : 1626122935 ,
716
755
parent_burn_block_time_iso : '2021-07-12T20:48:55.000Z' ,
717
- tx_index : 6 ,
756
+ tx_index : 8 ,
718
757
tx_result : { hex : '0x0100000000000000000000000000000001' , repr : 'u1' } ,
719
758
token_transfer : {
720
759
recipient_address : 'ST3DWSXBPYDB484QXFTR81K4AWG4ZB5XZNFF3H70C' ,
@@ -779,7 +818,7 @@ describe('address tests', () => {
779
818
} ,
780
819
{
781
820
tx : {
782
- tx_id : '0x03807fdb726b3cb843e0330c564a4974037be8f9ea58ec7f8ebe03c34b890005 ' ,
821
+ tx_id : '0x03807fdb726b3cb843e0330c564a4974037be8f9ea58ec7f8ebe03c34b890007 ' ,
783
822
tx_type : 'token_transfer' ,
784
823
nonce : 0 ,
785
824
anchor_mode : 'any' ,
@@ -801,7 +840,7 @@ describe('address tests', () => {
801
840
parent_block_hash : '0x' ,
802
841
parent_burn_block_time : 1626122935 ,
803
842
parent_burn_block_time_iso : '2021-07-12T20:48:55.000Z' ,
804
- tx_index : 5 ,
843
+ tx_index : 7 ,
805
844
tx_result : { hex : '0x0100000000000000000000000000000001' , repr : 'u1' } ,
806
845
token_transfer : {
807
846
recipient_address : 'ST3DWSXBPYDB484QXFTR81K4AWG4ZB5XZNFF3H70C' ,
0 commit comments