commit de97b161b13705cc88e62e8a4bcd9718ee1fe557 Author: Richa-iitr Date: Mon Aug 15 20:57:05 2022 +0530 Initial commit diff --git a/abis/InstaIndex.json b/abis/InstaIndex.json new file mode 100644 index 0000000..d652b80 --- /dev/null +++ b/abis/InstaIndex.json @@ -0,0 +1,244 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "origin", + "type": "address" + } + ], + "name": "LogAccountCreated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_newAccount", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_connectors", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_check", + "type": "address" + } + ], + "name": "LogNewAccount", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "accountVersion", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "check", + "type": "address" + } + ], + "name": "LogNewCheck", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "master", + "type": "address" + } + ], + "name": "LogNewMaster", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "master", + "type": "address" + } + ], + "name": "LogUpdateMaster", + "type": "event" + }, + { + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "account", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_newAccount", "type": "address" }, + { "internalType": "address", "name": "_connectors", "type": "address" }, + { "internalType": "address", "name": "_check", "type": "address" } + ], + "name": "addNewAccount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" }, + { + "internalType": "uint256", + "name": "accountVersion", + "type": "uint256" + }, + { "internalType": "address", "name": "_origin", "type": "address" } + ], + "name": "build", + "outputs": [ + { "internalType": "address", "name": "_account", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" }, + { + "internalType": "uint256", + "name": "accountVersion", + "type": "uint256" + }, + { "internalType": "address[]", "name": "_targets", "type": "address[]" }, + { "internalType": "bytes[]", "name": "_datas", "type": "bytes[]" }, + { "internalType": "address", "name": "_origin", "type": "address" } + ], + "name": "buildWithCast", + "outputs": [ + { "internalType": "address", "name": "_account", "type": "address" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "accountVersion", + "type": "uint256" + }, + { "internalType": "address", "name": "_newCheck", "type": "address" } + ], + "name": "changeCheck", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_newMaster", "type": "address" } + ], + "name": "changeMaster", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "check", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "connectors", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "version", "type": "uint256" }, + { "internalType": "address", "name": "query", "type": "address" } + ], + "name": "isClone", + "outputs": [{ "internalType": "bool", "name": "result", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "list", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "master", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_master", "type": "address" }, + { "internalType": "address", "name": "_list", "type": "address" }, + { "internalType": "address", "name": "_account", "type": "address" }, + { "internalType": "address", "name": "_connectors", "type": "address" } + ], + "name": "setBasics", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "updateMaster", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "versionCount", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + } +] diff --git a/networks.json b/networks.json new file mode 100644 index 0000000..47c1399 --- /dev/null +++ b/networks.json @@ -0,0 +1,7 @@ +{ + "mainnet": { + "undefined": { + "address": "0x2971AdFa57b20E5a416aE5a708A8655A9c74f723" + } + } +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..6b4a9a4 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "erc20-allowance", + "license": "UNLICENSED", + "scripts": { + "codegen": "graph codegen", + "build": "graph build", + "deploy": "graph deploy --node https://api.thegraph.com/deploy/ Richa-iitr/erc20-allowance", + "create-local": "graph create --node http://localhost:8020/ Richa-iitr/erc20-allowance", + "remove-local": "graph remove --node http://localhost:8020/ Richa-iitr/erc20-allowance", + "deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 Richa-iitr/erc20-allowance" + }, + "dependencies": { + "@graphprotocol/graph-cli": "0.30.0", + "@graphprotocol/graph-ts": "0.27.0" + } +} diff --git a/schema.graphql b/schema.graphql new file mode 100644 index 0000000..c61e248 --- /dev/null +++ b/schema.graphql @@ -0,0 +1,6 @@ +type ExampleEntity @entity { + id: ID! + count: BigInt! + sender: Bytes! # address + owner: Bytes! # address +} diff --git a/src/insta-index.ts b/src/insta-index.ts new file mode 100644 index 0000000..19e4d4c --- /dev/null +++ b/src/insta-index.ts @@ -0,0 +1,67 @@ +import { BigInt } from "@graphprotocol/graph-ts" +import { + InstaIndex, + LogAccountCreated, + LogNewAccount, + LogNewCheck, + LogNewMaster, + LogUpdateMaster +} from "../generated/InstaIndex/InstaIndex" +import { ExampleEntity } from "../generated/schema" + +export function handleLogAccountCreated(event: LogAccountCreated): void { + // Entities can be loaded from the store using a string ID; this ID + // needs to be unique across all entities of the same type + let entity = ExampleEntity.load(event.transaction.from.toHex()) + + // Entities only exist after they have been saved to the store; + // `null` checks allow to create entities on demand + if (!entity) { + entity = new ExampleEntity(event.transaction.from.toHex()) + + // Entity fields can be set using simple assignments + entity.count = BigInt.fromI32(0) + } + + // BigInt and BigDecimal math are supported + entity.count = entity.count + BigInt.fromI32(1) + + // Entity fields can be set based on event parameters + entity.sender = event.params.sender + entity.owner = event.params.owner + + // Entities can be written to the store with `.save()` + entity.save() + + // Note: If a handler doesn't require existing field values, it is faster + // _not_ to load the entity from the store. Instead, create it fresh with + // `new Entity(...)`, set the fields that should be updated and save the + // entity back to the store. Fields that were not set or unset remain + // unchanged, allowing for partial updates to be applied. + + // It is also possible to access smart contracts from mappings. For + // example, the contract that has emitted the event can be connected to + // with: + // + // let contract = Contract.bind(event.address) + // + // The following functions can then be called on this contract to access + // state variables and other data: + // + // - contract.account(...) + // - contract.build(...) + // - contract.check(...) + // - contract.connectors(...) + // - contract.isClone(...) + // - contract.list(...) + // - contract.master(...) + // - contract.versionCount(...) +} + +export function handleLogNewAccount(event: LogNewAccount): void {} + +export function handleLogNewCheck(event: LogNewCheck): void {} + +export function handleLogNewMaster(event: LogNewMaster): void {} + +export function handleLogUpdateMaster(event: LogUpdateMaster): void {} diff --git a/subgraph.yaml b/subgraph.yaml new file mode 100644 index 0000000..8de1e83 --- /dev/null +++ b/subgraph.yaml @@ -0,0 +1,35 @@ +specVersion: 0.0.1 +schema: + file: ./schema.graphql +dataSources: + - kind: ethereum + name: undefined + network: mainnet + source: + address: "0x2971AdFa57b20E5a416aE5a708A8655A9c74f723" + abi: InstaIndex + mapping: + kind: ethereum/events + apiVersion: 0.0.5 + language: wasm/assemblyscript + entities: + - LogAccountCreated + - LogNewAccount + - LogNewCheck + - LogNewMaster + - LogUpdateMaster + abis: + - name: InstaIndex + file: ./abis/InstaIndex.json + eventHandlers: + - event: LogAccountCreated(address,indexed address,indexed address,indexed address) + handler: handleLogAccountCreated + - event: LogNewAccount(indexed address,indexed address,indexed address) + handler: handleLogNewAccount + - event: LogNewCheck(indexed uint256,indexed address) + handler: handleLogNewCheck + - event: LogNewMaster(indexed address) + handler: handleLogNewMaster + - event: LogUpdateMaster(indexed address) + handler: handleLogUpdateMaster + file: ./src/insta-index.ts diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..5c5d17c --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@graphprotocol/graph-ts/types/tsconfig.base.json", + "include": ["src"] +}