Skip to content

Commit 45f5f3d

Browse files
flopez7portuu3
andauthored
[Subgraph] Fix internal transaction handling when there is more than one main method (#3713)
Co-authored-by: portuu3 <adrian.portugues.mas@gmail.com>
1 parent 91c1aaf commit 45f5f3d

4 files changed

Lines changed: 43 additions & 23 deletions

File tree

.changeset/tasty-groups-sing.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@human-protocol/sdk": patch
3+
"@human-protocol/python-sdk": patch
4+
---
5+
6+
Subgraph fix - Fix internal transaction handling when there is more than one main method event in the same transaction.

packages/sdk/python/human-protocol-sdk/human_protocol_sdk/constants.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class OperatorCategory(Enum):
3737
"https://api.studio.thegraph.com/query/74256/ethereum/version/latest"
3838
),
3939
"subgraph_url_api_key": (
40-
"https://gateway.thegraph.com/api/deployments/id/QmXGmcjEtwwEgB83KE2ECjjYY38kLMqzaq4ip8GWY7A6zz"
40+
"https://gateway.thegraph.com/api/deployments/id/QmeCB3KX49nRAkzgqancc3yL3VMJvt65YtL1zrLCFgr2n5"
4141
),
4242
"hmt_address": "0xd1ba9BAC957322D6e8c07a160a3A8dA11A0d2867",
4343
"factory_address": "0xD9c75a1Aa4237BB72a41E5E26bd8384f10c1f55a",
@@ -53,7 +53,7 @@ class OperatorCategory(Enum):
5353
"https://api.studio.thegraph.com/query/74256/sepolia/version/latest"
5454
),
5555
"subgraph_url_api_key": (
56-
"https://gateway.thegraph.com/api/deployments/id/QmT4xNvZh8ymarrk1zdytjLhCW59iuTavsd4JgHS4LbCVB"
56+
"https://gateway.thegraph.com/api/deployments/id/QmcMntqZSTh8wJddxgp2hYcdw78wZFU86LHTHzJ1bTVUDc"
5757
),
5858
"hmt_address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33",
5959
"factory_address": "0x5987A5558d961ee674efe4A8c8eB7B1b5495D3bf",
@@ -69,7 +69,7 @@ class OperatorCategory(Enum):
6969
"https://api.studio.thegraph.com/query/74256/bsc/version/latest"
7070
),
7171
"subgraph_url_api_key": (
72-
"https://gateway.thegraph.com/api/deployments/id/QmdVdpm9NnFz5B8QyzhW1bW1nNfRWemTiFn2MrhYZGTSQD"
72+
"https://gateway.thegraph.com/api/deployments/id/QmRexbu8eLZ1iE7ZLMtKxAr9GJnQ1JVrXhybKq6JkJ9XLE"
7373
),
7474
"hmt_address": "0x711Fd6ab6d65A98904522d4e3586F492B989c527",
7575
"factory_address": "0x92FD968AcBd521c232f5fB8c33b342923cC72714",
@@ -85,7 +85,7 @@ class OperatorCategory(Enum):
8585
"https://api.studio.thegraph.com/query/74256/bsc-testnet/version/latest"
8686
),
8787
"subgraph_url_api_key": (
88-
"https://gateway.thegraph.com/api/deployments/id/QmZjYMktZe8RAz7W7qL33VZBV6AC57xsLyE1cEfv6NABdZ"
88+
"https://gateway.thegraph.com/api/deployments/id/QmfFBXsAP7nbckFx34XYcNq2hRnfoVNrfqCvuk7hmAtYJT"
8989
),
9090
"hmt_address": "0xE3D74BBFa45B4bCa69FF28891fBE392f4B4d4e4d",
9191
"factory_address": "0x2bfA592DBDaF434DDcbb893B1916120d181DAD18",
@@ -103,7 +103,7 @@ class OperatorCategory(Enum):
103103
"https://api.studio.thegraph.com/query/74256/polygon/version/latest"
104104
),
105105
"subgraph_url_api_key": (
106-
"https://gateway.thegraph.com/api/deployments/id/QmUt9mmfNjtC5ZnQNiWHRbFG3k5zfngMuoTyky9jhXYqG2"
106+
"https://gateway.thegraph.com/api/deployments/id/QmUwHMDjnDHDB5cowGqd96SRJ1sZegoAPanjxBWUyLZghv"
107107
),
108108
"hmt_address": "0xc748B2A084F8eFc47E086ccdDD9b7e67aEb571BF",
109109
"factory_address": "0xBDBfD2cC708199C5640C6ECdf3B0F4A4C67AdfcB",
@@ -121,7 +121,7 @@ class OperatorCategory(Enum):
121121
"https://api.studio.thegraph.com/query/74256/amoy/version/latest"
122122
),
123123
"subgraph_url_api_key": (
124-
"https://gateway.thegraph.com/api/deployments/id/QmWRUFWpWoRRUh7Ec1HUJEwxc84DkP4iFTfLLsoVngJAPa"
124+
"https://gateway.thegraph.com/api/deployments/id/QmTJfcvVVmw8fe5CwRP6tZD5FzE2ESrm3ryygS1YZMYhM7"
125125
),
126126
"hmt_address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33",
127127
"factory_address": "0xAFf5a986A530ff839d49325A5dF69F96627E8D29",

packages/sdk/typescript/human-protocol-sdk/src/constants.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const NETWORKS: {
3636
subgraphUrl:
3737
'https://api.studio.thegraph.com/query/74256/ethereum/version/latest',
3838
subgraphUrlApiKey:
39-
'https://gateway.thegraph.com/api/deployments/id/QmXGmcjEtwwEgB83KE2ECjjYY38kLMqzaq4ip8GWY7A6zz',
39+
'https://gateway.thegraph.com/api/deployments/id/QmeCB3KX49nRAkzgqancc3yL3VMJvt65YtL1zrLCFgr2n5',
4040
oldSubgraphUrl: '',
4141
oldFactoryAddress: '',
4242
},
@@ -51,7 +51,7 @@ export const NETWORKS: {
5151
subgraphUrl:
5252
'https://api.studio.thegraph.com/query/74256/sepolia/version/latest',
5353
subgraphUrlApiKey:
54-
'https://gateway.thegraph.com/api/deployments/id/QmT4xNvZh8ymarrk1zdytjLhCW59iuTavsd4JgHS4LbCVB',
54+
'https://gateway.thegraph.com/api/deployments/id/QmcMntqZSTh8wJddxgp2hYcdw78wZFU86LHTHzJ1bTVUDc',
5555
oldSubgraphUrl: '',
5656
oldFactoryAddress: '',
5757
},
@@ -66,7 +66,7 @@ export const NETWORKS: {
6666
subgraphUrl:
6767
'https://api.studio.thegraph.com/query/74256/bsc/version/latest',
6868
subgraphUrlApiKey:
69-
'https://gateway.thegraph.com/api/deployments/id/QmdVdpm9NnFz5B8QyzhW1bW1nNfRWemTiFn2MrhYZGTSQD',
69+
'https://gateway.thegraph.com/api/deployments/id/QmRexbu8eLZ1iE7ZLMtKxAr9GJnQ1JVrXhybKq6JkJ9XLE',
7070
oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc',
7171
oldFactoryAddress: '0xc88bC422cAAb2ac8812de03176402dbcA09533f4',
7272
},
@@ -81,7 +81,7 @@ export const NETWORKS: {
8181
subgraphUrl:
8282
'https://api.studio.thegraph.com/query/74256/bsc-testnet/version/latest',
8383
subgraphUrlApiKey:
84-
'https://gateway.thegraph.com/api/deployments/id/QmZjYMktZe8RAz7W7qL33VZBV6AC57xsLyE1cEfv6NABdZ',
84+
'https://gateway.thegraph.com/api/deployments/id/QmfFBXsAP7nbckFx34XYcNq2hRnfoVNrfqCvuk7hmAtYJT',
8585
oldSubgraphUrl:
8686
'https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest',
8787
oldFactoryAddress: '0xaae6a2646c1f88763e62e0cd08ad050ea66ac46f',
@@ -97,7 +97,7 @@ export const NETWORKS: {
9797
subgraphUrl:
9898
'https://api.studio.thegraph.com/query/74256/polygon/version/latest',
9999
subgraphUrlApiKey:
100-
'https://gateway.thegraph.com/api/deployments/id/QmUt9mmfNjtC5ZnQNiWHRbFG3k5zfngMuoTyky9jhXYqG2',
100+
'https://gateway.thegraph.com/api/deployments/id/QmUwHMDjnDHDB5cowGqd96SRJ1sZegoAPanjxBWUyLZghv',
101101
oldSubgraphUrl:
102102
'https://api.thegraph.com/subgraphs/name/humanprotocol/polygon',
103103
oldFactoryAddress: '0x45eBc3eAE6DA485097054ae10BA1A0f8e8c7f794',
@@ -113,7 +113,7 @@ export const NETWORKS: {
113113
subgraphUrl:
114114
'https://api.studio.thegraph.com/query/74256/amoy/version/latest',
115115
subgraphUrlApiKey:
116-
'https://gateway.thegraph.com/api/deployments/id/QmWRUFWpWoRRUh7Ec1HUJEwxc84DkP4iFTfLLsoVngJAPa',
116+
'https://gateway.thegraph.com/api/deployments/id/QmTJfcvVVmw8fe5CwRP6tZD5FzE2ESrm3ryygS1YZMYhM7',
117117
oldSubgraphUrl: '',
118118
oldFactoryAddress: '',
119119
},

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

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ 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',
10+
'fund',
1311
'cancel',
12+
'complete',
13+
'storeResults',
14+
'bulkTransfer',
1415
'stake',
1516
'unstake',
1617
'slash',
@@ -71,13 +72,26 @@ export function createTransaction(
7172
mainMethods.includes(method) &&
7273
Address.fromBytes(transaction.to) == to
7374
) {
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();
75+
if (mainMethods.includes(transaction.method)) {
76+
const internalTransaction = new InternalTransaction(toEventId(event));
77+
internalTransaction.method = method;
78+
internalTransaction.from = from;
79+
internalTransaction.to = to;
80+
internalTransaction.value = value !== null ? value : BigInt.fromI32(0);
81+
internalTransaction.transaction = transaction.txHash;
82+
internalTransaction.token = token;
83+
internalTransaction.escrow = escrow;
84+
internalTransaction.receiver = receiver;
85+
internalTransaction.save();
86+
} else {
87+
transaction.method = method;
88+
transaction.from = from;
89+
transaction.value = value !== null ? value : BigInt.fromI32(0);
90+
transaction.token = token;
91+
transaction.escrow = escrow;
92+
transaction.receiver = receiver;
93+
transaction.save();
94+
}
8195
} else {
8296
if (
8397
transaction.method == 'set' &&

0 commit comments

Comments
 (0)