feat: 🎸 support matic + add prepare functions for both networks

This commit is contained in:
Daksh Miglani 2021-05-25 02:35:48 +05:30
parent 312fde1f26
commit c03b3b9aec
8 changed files with 10393 additions and 2371 deletions

4
.gitignore vendored
View File

@ -1,3 +1,5 @@
node_modules/ node_modules/
/generated /generated
/build /build
subgraph.yaml
src/utils/helpers/instaIndex.ts

5
config/mainnet.json Normal file
View File

@ -0,0 +1,5 @@
{
"network": "mainnet",
"InstaIndexAddress": "0x2971adfa57b20e5a416ae5a708a8655a9c74f723",
"InstaEventsAddress": "0x2af7ea6cb911035f3eb1ed895cb6692c39ecba97"
}

5
config/matic.json Normal file
View File

@ -0,0 +1,5 @@
{
"network": "matic",
"InstaIndexAddress": "0xA9B99766E6C676Cf1975c0D3166F96C0848fF5ad",
"InstaEventsAddress": "0xA4BF319968986D2352FA1c550D781bBFCCE3FcaB"
}

7934
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -9,10 +9,13 @@
"deploy-dev": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ protofire/instadapp-defi-smart-accounts", "deploy-dev": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ protofire/instadapp-defi-smart-accounts",
"create-local": "graph create --node http://localhost:8020/ protofire/instadapp-defi-smart-accounts", "create-local": "graph create --node http://localhost:8020/ protofire/instadapp-defi-smart-accounts",
"remove-local": "graph remove --node http://localhost:8020/ protofire/instadapp-defi-smart-accounts", "remove-local": "graph remove --node http://localhost:8020/ protofire/instadapp-defi-smart-accounts",
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 protofire/instadapp-defi-smart-accounts" "deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 protofire/instadapp-defi-smart-accounts",
"prepare:mainnet": "mustache config/mainnet.json subgraph.template.yaml > subgraph.yaml && mustache config/mainnet.json src/utils/helpers/instaIndex.template.ts src/utils/helpers/instaIndex.ts",
"prepare:matic": "mustache config/matic.json subgraph.template.yaml > subgraph.yaml && mustache config/matic.json src/utils/helpers/instaIndex.template.ts src/utils/helpers/instaIndex.ts"
}, },
"dependencies": { "dependencies": {
"@graphprotocol/graph-cli": "0.18.0", "@graphprotocol/graph-cli": "0.18.0",
"@graphprotocol/graph-ts": "0.18.0" "@graphprotocol/graph-ts": "0.18.0",
"mustache": "^4.2.0"
} }
} }

View File

@ -2,7 +2,7 @@ import {
User, User,
SmartAccount, SmartAccount,
AccountModule, AccountModule,
InstaIndex InstaIndex,
} from "../../../generated/schema"; } from "../../../generated/schema";
import { InstaAccount as AccountTemplate } from "../../../generated/templates"; import { InstaAccount as AccountTemplate } from "../../../generated/templates";
import { Address } from "@graphprotocol/graph-ts"; import { Address } from "@graphprotocol/graph-ts";
@ -36,8 +36,8 @@ export function getOrCreateSmartAccount(
smartAccount = new SmartAccount(id); smartAccount = new SmartAccount(id);
smartAccount.shield = false; smartAccount.shield = false;
if(address != null) { if (address != null) {
AccountTemplate.create(address as Address) AccountTemplate.create(address as Address);
} }
} }
@ -61,10 +61,10 @@ export function getOrCreateAccountModule(
} }
export function getOrCreateInstaIndex(): InstaIndex { export function getOrCreateInstaIndex(): InstaIndex {
let index = InstaIndex.load("0x2971adfa57b20e5a416ae5a708a8655a9c74f723"); let index = InstaIndex.load("{{InstaIndexAddress}}");
if (index == null) { if (index == null) {
index = new InstaIndex("0x2971adfa57b20e5a416ae5a708a8655a9c74f723"); index = new InstaIndex("{{InstaIndexAddress}}");
index.save(); index.save();
} }

View File

@ -6,9 +6,9 @@ schema:
dataSources: dataSources:
- kind: ethereum/contract - kind: ethereum/contract
name: InstaIndex name: InstaIndex
network: mainnet network: {{network}}
source: source:
address: "0x2971adfa57b20e5a416ae5a708a8655a9c74f723" address: "{{InstaIndexAddress}}"
abi: InstaIndex abi: InstaIndex
startBlock: 9747241 startBlock: 9747241
mapping: mapping:
@ -42,9 +42,9 @@ dataSources:
handler: handleBuild handler: handleBuild
- kind: ethereum/contract - kind: ethereum/contract
name: InstaEvents name: InstaEvents
network: mainnet network: {{network}}
source: source:
address: "0x2af7ea6cb911035f3eb1ed895cb6692c39ecba97" address: "{{InstaEventsAddress}}"
abi: InstaEvents abi: InstaEvents
startBlock: 9747294 startBlock: 9747294
mapping: mapping:
@ -67,7 +67,7 @@ dataSources:
templates: templates:
- name: InstaConnectors - name: InstaConnectors
kind: ethereum/contract kind: ethereum/contract
network: mainnet network: {{network}}
source: source:
abi: InstaConnectors abi: InstaConnectors
mapping: mapping:
@ -98,7 +98,7 @@ templates:
handler: handleLogRemoveController handler: handleLogRemoveController
- name: InstaAccount - name: InstaAccount
kind: ethereum/contract kind: ethereum/contract
network: mainnet network: {{network}}
source: source:
abi: InstaAccount abi: InstaAccount
mapping: mapping:

4785
yarn.lock

File diff suppressed because it is too large Load Diff