Skip to content

Commit 65b20a5

Browse files
committed
reorganize mainMethods and fix internal transaction handling when there is more than one main method event in the same transaction
1 parent dddf2b8 commit 65b20a5

1 file changed

Lines changed: 24 additions & 11 deletions

File tree

packages/sdk/typescript/subgraph/src/mapping/utils/transaction.ts

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { toEventId, toPreviousEventId } from './event';
55
const mainMethods: string[] = [
66
'createEscrow',
77
'setup',
8-
'fund',
9-
'bulkTransfer',
10-
'storeResults',
11-
'withdraw',
128
'requestCancellation',
9+
'withdraw',
1310
'cancel',
11+
'complete',
12+
'storeResults',
13+
'bulkTransfer',
1414
'stake',
1515
'unstake',
1616
'slash',
@@ -71,13 +71,26 @@ export function createTransaction(
7171
mainMethods.includes(method) &&
7272
Address.fromBytes(transaction.to) == to
7373
) {
74-
transaction.method = method;
75-
transaction.from = from;
76-
transaction.value = value !== null ? value : BigInt.fromI32(0);
77-
transaction.token = token;
78-
transaction.escrow = escrow;
79-
transaction.receiver = receiver;
80-
transaction.save();
74+
if (mainMethods.includes(transaction.method)) {
75+
const internalTransaction = new InternalTransaction(toEventId(event));
76+
internalTransaction.method = method;
77+
internalTransaction.from = from;
78+
internalTransaction.to = to;
79+
internalTransaction.value = value !== null ? value : BigInt.fromI32(0);
80+
internalTransaction.transaction = transaction.txHash;
81+
internalTransaction.token = token;
82+
internalTransaction.escrow = escrow;
83+
internalTransaction.receiver = receiver;
84+
internalTransaction.save();
85+
} else {
86+
transaction.method = method;
87+
transaction.from = from;
88+
transaction.value = value !== null ? value : BigInt.fromI32(0);
89+
transaction.token = token;
90+
transaction.escrow = escrow;
91+
transaction.receiver = receiver;
92+
transaction.save();
93+
}
8194
} else {
8295
if (
8396
transaction.method == 'set' &&

0 commit comments

Comments
 (0)