Skip to content

Commit cb53979

Browse files
chore: cursor pagination v2 minor
1 parent 019cdea commit cb53979

File tree

4 files changed

+54
-60
lines changed

4 files changed

+54
-60
lines changed

packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcExplorerApi.spec.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,6 @@ describe('IndexerGrpcExplorerApi', () => {
267267
perPage: 10,
268268
})
269269

270-
console.log(JSON.stringify(response, null, 2))
271-
272270
expect(response).toBeDefined()
273271
} catch (e) {
274272
console.error(
@@ -283,8 +281,6 @@ describe('IndexerGrpcExplorerApi', () => {
283281
perPage: 10,
284282
})
285283

286-
console.log(JSON.stringify(response, null, 2))
287-
288284
expect(response).toBeDefined()
289285
} catch (e) {
290286
console.error(
@@ -300,8 +296,6 @@ describe('IndexerGrpcExplorerApi', () => {
300296
perPage: 10,
301297
})
302298

303-
console.log(JSON.stringify(response, null, 2))
304-
305299
expect(response).toBeDefined()
306300
} catch (e) {
307301
console.error(

packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcExplorerApi.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -571,21 +571,21 @@ export class IndexerGrpcExplorerApi extends BaseGrpcConsumer {
571571
}
572572

573573
async fetchTxsV2({
574-
blockNumber,
575-
startTime,
576-
endTime,
577-
perPage,
578-
status,
579-
token,
580574
type,
575+
token,
576+
status,
577+
perPage,
578+
endTime,
579+
startTime,
580+
blockNumber,
581581
}: {
582-
blockNumber?: number
583-
startTime?: number
584-
endTime?: number
585-
perPage?: number
586-
status?: string
587-
token?: string
588582
type?: string
583+
token?: string
584+
status?: string
585+
perPage?: number
586+
endTime?: number
587+
startTime?: number
588+
blockNumber?: number
589589
}) {
590590
const request = InjectiveExplorerRpc.GetTxsV2Request.create()
591591

@@ -641,19 +641,19 @@ export class IndexerGrpcExplorerApi extends BaseGrpcConsumer {
641641
}
642642

643643
async fetchAccountTxsV2({
644+
type,
645+
token,
644646
address,
645-
startTime,
646647
endTime,
647648
perPage,
648-
token,
649-
type,
649+
startTime,
650650
}: {
651+
type?: string
652+
token?: string
651653
address: string
652-
startTime?: number
653654
endTime?: number
654655
perPage?: number
655-
token?: string
656-
type?: string
656+
startTime?: number
657657
}) {
658658
const request = InjectiveExplorerRpc.GetAccountTxsV2Request.create()
659659

@@ -706,11 +706,11 @@ export class IndexerGrpcExplorerApi extends BaseGrpcConsumer {
706706
}
707707

708708
async fetchBlocksV2({
709-
perPage,
710709
token,
710+
perPage,
711711
}: {
712-
perPage?: number
713712
token?: string
713+
perPage?: number
714714
}) {
715715
const request = InjectiveExplorerRpc.GetBlocksV2Request.create({})
716716

packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcExplorerTransformer.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { BigNumberInWei, BigNumberInBase } from '@injectivelabs/utils'
21
import { isJsonString } from '../../../utils/helpers.js'
2+
import { BigNumberInWei, BigNumberInBase } from '@injectivelabs/utils'
33
import {
44
Block,
55
GasFee,
@@ -522,23 +522,23 @@ export class IndexerGrpcExplorerTransformer {
522522
const blockNumber = parseInt(tx.blockNumber)
523523

524524
return {
525-
id: tx.id,
526525
logs,
527-
code: tx.code,
528-
hash: tx.hash,
526+
info: '',
527+
memo: '',
528+
txType,
529529
claimIds,
530-
errorLog: tx.errorLog,
531530
messages,
532-
codespace: tx.codespace,
533-
txType,
531+
id: tx.id,
534532
signatures,
535533
blockNumber,
536-
blockTimestamp: tx.blockTimestamp,
537-
gasFee: { amounts: [], gasLimit: 0, granter: '', payer: '' },
538-
info: '',
539-
memo: '',
540534
gasUsed: 0,
541535
gasWanted: 0,
536+
hash: tx.hash,
537+
code: tx.code,
538+
errorLog: tx.errorLog,
539+
codespace: tx.codespace,
540+
blockTimestamp: tx.blockTimestamp,
541+
gasFee: { amounts: [], gasLimit: 0, granter: '', payer: '' },
542542
}
543543
}
544544

@@ -573,33 +573,33 @@ export class IndexerGrpcExplorerTransformer {
573573
payer: tx.gasFee?.payer ?? '',
574574
},
575575
events: tx.events,
576-
gasUsed: parseInt(tx.gasUsed, 10),
577576
errorLog: tx.errorLog,
578-
claimIds: tx.claimIds.map((claimId) => parseInt(claimId, 10)),
577+
codespace: tx.codespace,
578+
gasUsed: parseInt(tx.gasUsed, 10),
579+
blockTimestamp: tx.blockTimestamp,
579580
gasWanted: parseInt(tx.gasWanted, 10),
581+
blockNumber: parseInt(tx.blockNumber, 10),
580582
signatures: tx.signatures.map((signature) => ({
581583
address: signature.address,
582584
pubkey: signature.pubkey,
583585
signature: signature.signature,
584586
sequence: parseInt(signature.sequence, 10),
585587
})),
586-
blockNumber: parseInt(tx.blockNumber, 10),
587-
blockTimestamp: tx.blockTimestamp,
588-
data: '/' + Buffer.from(tx.data).toString('utf8').split('/').pop(),
589588
messages: transactionV2MessagesToMessages(tx.messages),
590589
logs: JSON.parse(Buffer.from(tx.logs).toString('utf8')),
591-
codespace: tx.codespace,
590+
data: '/' + Buffer.from(tx.data).toString('utf8').split('/').pop(),
591+
claimIds: tx.claimIds.map((claimId) => parseInt(claimId, 10)),
592592
}
593593
}
594594

595595
static getBlocksV2ResponseToBlocks(
596596
response: InjectiveExplorerRpc.GetBlocksV2Response,
597597
) {
598598
return {
599+
paging: response.paging,
599600
data: response.data.map((block) =>
600601
IndexerGrpcExplorerTransformer.grpcBlockV2ToBlock(block),
601602
),
602-
paging: response.paging,
603603
}
604604
}
605605

@@ -633,25 +633,25 @@ export class IndexerGrpcExplorerTransformer {
633633
const messages = transactionV2MessagesToMessages(tx.messages)
634634

635635
return {
636+
messages,
636637
code: tx.code,
637638
memo: tx.memo,
638639
type: tx.txType,
640+
txHash: tx.hash,
641+
error_log: tx.errorLog,
642+
height: parseInt(tx.blockNumber, 10),
643+
tx_number: parseInt(tx.txNumber, 10),
644+
time: parseInt(tx.blockTimestamp, 10),
645+
amount: getContractTransactionV2Amount(tx),
646+
logs: JSON.parse(Buffer.from(tx.logs).toString('utf8')),
647+
data: '/' + Buffer.from(tx.data).toString('utf8').split('/').pop(),
648+
fee: new BigNumberInWei(tx.gasFee?.amount[0]?.amount || '0').toBase(),
639649
signatures: tx.signatures.map((signature) => ({
640650
address: signature.address,
641651
pubkey: signature.pubkey,
642652
signature: signature.signature,
643653
sequence: parseInt(signature.sequence, 10),
644654
})),
645-
data: '/' + Buffer.from(tx.data).toString('utf8').split('/').pop(),
646-
messages,
647-
logs: JSON.parse(Buffer.from(tx.logs).toString('utf8')),
648-
height: parseInt(tx.blockNumber, 10),
649-
error_log: tx.errorLog,
650-
txHash: tx.hash,
651-
tx_number: parseInt(tx.txNumber, 10),
652-
time: parseInt(tx.blockTimestamp, 10),
653-
fee: new BigNumberInWei(tx.gasFee?.amount[0]?.amount || '0').toBase(),
654-
amount: getContractTransactionV2Amount(tx),
655655
}
656656
}
657657
}

packages/sdk-ts/src/client/indexer/types/explorer.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -397,20 +397,20 @@ export interface ExplorerTxsV2Response {
397397
}
398398

399399
export interface ExplorerTransactionV2 {
400-
id: string
401400
logs: any
401+
id: string
402402
code: number
403403
hash: string
404-
claimIds: string[]
405-
errorLog?: string
406404
messages: any
407-
codespace: string
408-
txMsgTypes: string[]
409-
signatures: InjectiveExplorerRpc.Signature[]
410405
txNumber: number
406+
errorLog?: string
407+
codespace: string
408+
claimIds: string[]
411409
blockNumber: number
410+
txMsgTypes: string[]
412411
blockTimestamp: number
413412
blockUnixTimestamp: number
413+
signatures: InjectiveExplorerRpc.Signature[]
414414
}
415415

416416
export type GrpcIBCTransferTx = InjectiveExplorerRpc.IBCTransferTx

0 commit comments

Comments
 (0)