Skip to content

Commit

Permalink
fix generate manifests
Browse files Browse the repository at this point in the history
  • Loading branch information
mendesfabio committed Jan 28, 2025
1 parent 5b218bc commit c0e1708
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 16 deletions.
18 changes: 14 additions & 4 deletions scripts/generate-manifests.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');

const networksData = JSON.parse(fs.readFileSync('networks.json', 'utf8'));

function replacePlaceholders(template, network, networkData) {
template = template.replace(/{{#if ([^}]+)}}([\s\S]*?){{\/if}}/g, (match, factoryName, content) => {
if (networkData[factoryName]) {
return content;
}
return '';
});

let result = template.replace(/{{ network }}/g, network);

for (const [contractName, contractData] of Object.entries(networkData)) {
result = result.replace(new RegExp(`{{ ${contractName}\\.address }}`, 'g'), contractData.address);
result = result.replace(new RegExp(`{{ ${contractName}\\.startBlock }}`, 'g'), contractData.startBlock.toString());
}

return result;
result = result
.split('\n')
.filter(line => line.trim() !== '')
.join('\n');

return result + '\n';
}

['v3-pools', 'v3-vault'].forEach(subgraph => {
Expand All @@ -24,7 +35,6 @@ function replacePlaceholders(template, network, networkData) {
}

const template = fs.readFileSync(templatePath, 'utf8');

Object.entries(networksData).forEach(([network, networkData]) => {
const config = replacePlaceholders(template, network, networkData);
const outputPath = path.join('subgraphs', subgraph, `subgraph${network === 'mainnet' ? '' : `.${network}`}.yaml`);
Expand All @@ -33,4 +43,4 @@ function replacePlaceholders(template, network, networkData) {
});
});

console.log('🎉 v3 subgraphs successfully generated\n');
console.log('🎉 v3 subgraphs successfully generated\n');
46 changes: 46 additions & 0 deletions subgraphs/v3-pools/subgraph.sepolia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,49 @@ dataSources:
- event: PoolCreated(indexed address)
handler: handleStablePoolCreated
file: ./src/mappings/stable.ts
- kind: ethereum
name: Gyro2CLPPoolFactory
network: sepolia
source:
abi: BasePoolFactory
address: "0x97701aa7c9ae4497874C54B1C779221d6F1081C9"
startBlock: 7563127
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- Factory
- Pool
abis:
- name: Gyro2CLPPool
file: ./abis/Gyro2CLPPool.json
- name: BasePoolFactory
file: ./abis/BasePoolFactory.json
eventHandlers:
- event: PoolCreated(indexed address)
handler: handleGyro2PoolCreated
file: ./src/mappings/gyro2.ts
- kind: ethereum
name: GyroECLPPoolFactory
network: sepolia
source:
abi: BasePoolFactory
address: "0xaC06eD505b0d85e46Bf90590f835A12E5EAac86E"
startBlock: 7563132
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- Factory
- Pool
abis:
- name: GyroECLPPool
file: ./abis/GyroECLPPool.json
- name: BasePoolFactory
file: ./abis/BasePoolFactory.json
eventHandlers:
- event: PoolCreated(indexed address)
handler: handleGyroEPoolCreated
file: ./src/mappings/gyroE.ts
8 changes: 8 additions & 0 deletions subgraphs/v3-pools/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ specVersion: 1.0.0
schema:
file: ./schema.graphql
dataSources:
{{#if WeightedPoolFactory}}
- kind: ethereum
name: WeightedPoolFactory
network: {{ network }}
Expand All @@ -25,6 +26,8 @@ dataSources:
- event: PoolCreated(indexed address)
handler: handleWeightedPoolCreated
file: ./src/mappings/weighted.ts
{{/if}}
{{#if StablePoolFactory}}
- kind: ethereum
name: StablePoolFactory
network: {{ network }}
Expand All @@ -48,6 +51,8 @@ dataSources:
- event: PoolCreated(indexed address)
handler: handleStablePoolCreated
file: ./src/mappings/stable.ts
{{/if}}
{{#if Gyro2CLPPoolFactory}}
- kind: ethereum
name: Gyro2CLPPoolFactory
network: {{ network }}
Expand All @@ -71,6 +76,8 @@ dataSources:
- event: PoolCreated(indexed address)
handler: handleGyro2PoolCreated
file: ./src/mappings/gyro2.ts
{{/if}}
{{#if GyroECLPPoolFactory}}
- kind: ethereum
name: GyroECLPPoolFactory
network: {{ network }}
Expand All @@ -94,3 +101,4 @@ dataSources:
- event: PoolCreated(indexed address)
handler: handleGyroEPoolCreated
file: ./src/mappings/gyroE.ts
{{/if}}
2 changes: 0 additions & 2 deletions subgraphs/v3-vault/subgraph.arbitrum-one.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ dataSources:
- event: Unwrap(indexed address,uint256,uint256,bytes32)
handler: handleUnwrap
file: ./src/mappings/vault.ts

- kind: ethereum
name: ProtocolFeeController
network: arbitrum-one
Expand Down Expand Up @@ -83,7 +82,6 @@ dataSources:
- event: ProtocolFeesWithdrawn(indexed address,indexed address,indexed address,uint256)
handler: handleProtocolFeesWithdrawn
file: ./src/mappings/controller.ts

templates:
- kind: ethereum/contract
name: BPT
Expand Down
2 changes: 0 additions & 2 deletions subgraphs/v3-vault/subgraph.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ dataSources:
- event: Unwrap(indexed address,uint256,uint256,bytes32)
handler: handleUnwrap
file: ./src/mappings/vault.ts

- kind: ethereum
name: ProtocolFeeController
network: base
Expand Down Expand Up @@ -83,7 +82,6 @@ dataSources:
- event: ProtocolFeesWithdrawn(indexed address,indexed address,indexed address,uint256)
handler: handleProtocolFeesWithdrawn
file: ./src/mappings/controller.ts

templates:
- kind: ethereum/contract
name: BPT
Expand Down
2 changes: 0 additions & 2 deletions subgraphs/v3-vault/subgraph.gnosis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ dataSources:
- event: Unwrap(indexed address,uint256,uint256,bytes32)
handler: handleUnwrap
file: ./src/mappings/vault.ts

- kind: ethereum
name: ProtocolFeeController
network: gnosis
Expand Down Expand Up @@ -83,7 +82,6 @@ dataSources:
- event: ProtocolFeesWithdrawn(indexed address,indexed address,indexed address,uint256)
handler: handleProtocolFeesWithdrawn
file: ./src/mappings/controller.ts

templates:
- kind: ethereum/contract
name: BPT
Expand Down
2 changes: 0 additions & 2 deletions subgraphs/v3-vault/subgraph.sepolia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ dataSources:
- event: Unwrap(indexed address,uint256,uint256,bytes32)
handler: handleUnwrap
file: ./src/mappings/vault.ts

- kind: ethereum
name: ProtocolFeeController
network: sepolia
Expand Down Expand Up @@ -83,7 +82,6 @@ dataSources:
- event: ProtocolFeesWithdrawn(indexed address,indexed address,indexed address,uint256)
handler: handleProtocolFeesWithdrawn
file: ./src/mappings/controller.ts

templates:
- kind: ethereum/contract
name: BPT
Expand Down
2 changes: 0 additions & 2 deletions subgraphs/v3-vault/subgraph.sonic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ dataSources:
- event: Unwrap(indexed address,uint256,uint256,bytes32)
handler: handleUnwrap
file: ./src/mappings/vault.ts

- kind: ethereum
name: ProtocolFeeController
network: sonic
Expand Down Expand Up @@ -83,7 +82,6 @@ dataSources:
- event: ProtocolFeesWithdrawn(indexed address,indexed address,indexed address,uint256)
handler: handleProtocolFeesWithdrawn
file: ./src/mappings/controller.ts

templates:
- kind: ethereum/contract
name: BPT
Expand Down
2 changes: 0 additions & 2 deletions subgraphs/v3-vault/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ dataSources:
- event: Unwrap(indexed address,uint256,uint256,bytes32)
handler: handleUnwrap
file: ./src/mappings/vault.ts

- kind: ethereum
name: ProtocolFeeController
network: mainnet
Expand Down Expand Up @@ -83,7 +82,6 @@ dataSources:
- event: ProtocolFeesWithdrawn(indexed address,indexed address,indexed address,uint256)
handler: handleProtocolFeesWithdrawn
file: ./src/mappings/controller.ts

templates:
- kind: ethereum/contract
name: BPT
Expand Down

0 comments on commit c0e1708

Please sign in to comment.