diff --git a/package.json b/package.json index e6faefc..9bcb0c7 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,10 @@ "codegen": "graph codegen", "build": "graph build", "deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ juanmardefago/dsa", - "deploy-dev": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ protofire/augur-v2-kovan", - "create-local": "graph create --node http://localhost:8020/ protofire/augur-v2-kovan", - "remove-local": "graph remove --node http://localhost:8020/ protofire/augur-v2-kovan", - "deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 protofire/augur-v2-kovan" + "deploy-dev": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ protofire/instadapp-dsa", + "create-local": "graph create --node http://localhost:8020/ protofire/instadapp-dsa", + "remove-local": "graph remove --node http://localhost:8020/ protofire/instadapp-dsa", + "deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 protofire/instadapp-dsa" }, "dependencies": { "@graphprotocol/graph-cli": "0.18.0", diff --git a/schema.graphql b/schema.graphql index 90ffaf5..8207ec4 100644 --- a/schema.graphql +++ b/schema.graphql @@ -20,11 +20,11 @@ type AccountModule @entity { "ID is the account module version" id: ID! - version: Int + address: String! connectors: String! - check: String! + check: String instaIndex: InstaIndex! } diff --git a/src/index.ts b/src/index.ts index 555e47a..7da5950 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,5 +3,6 @@ export { handleLogNewAccount, handleLogNewCheck, handleLogNewMaster, - handleLogUpdateMaster + handleLogUpdateMaster, + handleSetBasics } from "./mappings/instaIndex"; diff --git a/src/mappings/instaIndex.ts b/src/mappings/instaIndex.ts index 9e6ed9b..8f9e680 100644 --- a/src/mappings/instaIndex.ts +++ b/src/mappings/instaIndex.ts @@ -5,12 +5,14 @@ import { LogNewCheck, LogNewMaster, LogUpdateMaster, + SetBasicsCall, InstaIndex } from "../../generated/InstaIndex/InstaIndex"; import { getOrCreateAccountModule, getOrCreateUser, - getOrCreateSmartAccount + getOrCreateSmartAccount, + getOrCreateInstaIndex } from '../utils/helpers' // - event: LogAccountCreated(address,indexed address,indexed address,indexed address) @@ -24,7 +26,7 @@ export function handleLogAccountCreated(event: LogAccountCreated): void { let sender = getOrCreateUser(event.params.sender.toHexString()) smartAccount.owner = owner.id; - smartAccount.sender = sender.id; + smartAccount.creator = sender.id; smartAccount.origin = event.params.origin.toHexString(); smartAccount.save(); @@ -79,3 +81,16 @@ export function handleLogUpdateMaster(event: LogUpdateMaster): void { index.save(); } + +// - event: LogUpdateMaster(indexed address) +// handler: handleLogUpdateMaster + +export function handleSetBasics(call: SetBasicsCall): void { + let accountVersion = InstaIndex.bind(call.to).versionCount(); + let accountModule = getOrCreateAccountModule(accountVersion.toString()) + + accountModule.address = call.inputs._account.toHexString(); + accountModule.connectors = call.inputs._connectors.toHexString(); + + accountModule.save(); +} diff --git a/src/utils/helpers/instaIndex.ts b/src/utils/helpers/instaIndex.ts index a32083a..118451e 100644 --- a/src/utils/helpers/instaIndex.ts +++ b/src/utils/helpers/instaIndex.ts @@ -50,7 +50,7 @@ export function getOrCreateAccountModule( export function getOrCreateInstaIndex(): InstaIndex { let index = InstaIndex.load("INDEX"); - if (index == null && createIfNotFound) { + if (index == null) { index = new InstaIndex("INDEX"); index.save(); } diff --git a/subgraph.yaml b/subgraph.yaml index e5e4449..5eecd55 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -1,6 +1,6 @@ specVersion: 0.0.2 -description: Augur v2 subgraph -repository: https://github.com/protofire/augur-v2-subgraph +description: InstaDapp Defi Smart Account +repository: https://github.com/protofire/instadapp-dsa-subgraph schema: file: ./schema.graphql dataSources: @@ -33,3 +33,6 @@ dataSources: handler: handleLogNewMaster - event: LogUpdateMaster(indexed address) handler: handleLogUpdateMaster + callHandlers: + - function: setBasics(address,address,address,address) + handler: handleSetBasics