Skip to content

Commit e1b8c25

Browse files
ianrowanilijabojanovic
authored andcommitted
dynamic ABI
1 parent 8cc0ec7 commit e1b8c25

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

packages/commonwealth/server/migrations/20240904153821-new-chain-event-sources.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,47 @@ module.exports = {
1515
},
1616
);
1717

18+
const contractAbis = await queryInterface.sequelize.query(
19+
'SELECT id, nickname FROM "ContractAbis" WHERE nickname IN (:nicknames)',
20+
{
21+
replacements: { nicknames: ['NamespaceFactory', 'CommunityStakes'] },
22+
type: Sequelize.QueryTypes.SELECT,
23+
transaction,
24+
},
25+
);
26+
27+
const abiIds = {
28+
NamespaceFactory: contractAbis.find(
29+
(abi) => abi.nickname === 'NamespaceFactory',
30+
).id,
31+
CommunityStakes: contractAbis.find(
32+
(abi) => abi.nickname === 'CommunityStakes',
33+
).id,
34+
};
35+
1836
const hardCodedValueSetsL2 = [
1937
{
2038
contract_address: '0xedf43C919f59900C82d963E99d822dA3F95575EA',
2139
event_signature:
2240
'0x8870ba2202802ce285ce6bead5ac915b6dc2d35c8a9d6f96fa56de9de12829d5',
2341
kind: 'DeployedNamespace',
24-
abi_id: 53,
42+
abi_id: abiIds.NamespaceFactory,
2543
active: true,
2644
},
2745
{
2846
contract_address: '0xcc752fd15A7Dd0d5301b6A626316E7211352Cf62',
2947
event_signature:
3048
'0xfc13c9a8a9a619ac78b803aecb26abdd009182411d51a986090f82519d88a89e',
3149
kind: 'Trade',
32-
abi_id: 52,
50+
abi_id: abiIds.CommunityStakes,
3351
active: true,
3452
},
3553
{
3654
contract_address: '0xedf43C919f59900C82d963E99d822dA3F95575EA',
3755
event_signature:
3856
'0x990f533044dbc89b838acde9cd2c72c400999871cf8f792d731edcae15ead693',
3957
kind: 'NewContest',
40-
abi_id: 53,
58+
abi_id: abiIds.NamespaceFactory,
4159
active: true,
4260
},
4361
];
@@ -48,23 +66,23 @@ module.exports = {
4866
event_signature:
4967
'0x8870ba2202802ce285ce6bead5ac915b6dc2d35c8a9d6f96fa56de9de12829d5',
5068
kind: 'DeployedNamespace',
51-
abi_id: 53,
69+
abi_id: abiIds.NamespaceFactory,
5270
active: true,
5371
},
5472
{
5573
contract_address: '0x9ed281e62db1b1d98af90106974891a4c1ca3a47',
5674
event_signature:
5775
'0xfc13c9a8a9a619ac78b803aecb26abdd009182411d51a986090f82519d88a89e',
5876
kind: 'Trade',
59-
abi_id: 52,
77+
abi_id: abiIds.CommunityStakes,
6078
active: true,
6179
},
6280
{
6381
contract_address: '0x90aa47bf6e754f69ee53f05b5187b320e3118b0f',
6482
event_signature:
6583
'0x990f533044dbc89b838acde9cd2c72c400999871cf8f792d731edcae15ead693',
6684
kind: 'NewContest',
67-
abi_id: 53,
85+
abi_id: abiIds.NamespaceFactory,
6886
active: true,
6987
},
7088
];

0 commit comments

Comments
 (0)