Skip to content

Commit

Permalink
Basic support for innerTx in transfers endpoint (#1351)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghel authored Oct 14, 2024
1 parent dce8f8b commit 64040d5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/common/indexer/elastic/elastic.indexer.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ export class ElasticIndexerHelper {
QueryType.Exists('canBeIgnored'),
]))
.withCondition(QueryConditionOptions.should, QueryType.Must([
QueryType.Match('type', 'normal'),
QueryType.Should([
QueryType.Match('type', 'normal'),
QueryType.Match('type', 'innerTx'),
]),
QueryType.Should([
QueryType.Match('sender', filter.address),
QueryType.Match('receiver', filter.address),
Expand Down
6 changes: 5 additions & 1 deletion src/endpoints/transactions/entities/transaction.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { registerEnumType } from "@nestjs/graphql";
export enum TransactionType {
Transaction = 'Transaction',
SmartContractResult = 'SmartContractResult',
Reward = 'Reward'
InnerTransaction = 'InnerTransaction',
Reward = 'Reward',
}

registerEnumType(TransactionType, {
Expand All @@ -16,6 +17,9 @@ registerEnumType(TransactionType, {
SmartContractResult: {
description: 'SmartContractResult type.',
},
InnerTransaction: {
description: 'InnerTransaction type.',
},
Reward: {
description: 'Reward type.',
},
Expand Down
13 changes: 12 additions & 1 deletion src/endpoints/transfers/transfer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,20 @@ export class TransferService {

for (const elasticOperation of elasticOperations) {
const transaction = ApiUtils.mergeObjects(new TransactionDetailed(), elasticOperation);
transaction.type = elasticOperation.type === 'normal' ? TransactionType.Transaction : TransactionType.SmartContractResult;
transaction.relayer = elasticOperation.relayerAddr;

switch (elasticOperation.type) {
case 'normal':
transaction.type = TransactionType.Transaction;
break;
case 'unsigned':
transaction.type = TransactionType.SmartContractResult;
break;
case 'innerTx':
transaction.type = TransactionType.InnerTransaction;
break;
}

if (transaction.type === TransactionType.SmartContractResult) {
delete transaction.gasLimit;
delete transaction.gasPrice;
Expand Down

0 comments on commit 64040d5

Please sign in to comment.