Initial commit

This commit is contained in:
Richa-iitr 2022-08-15 20:57:05 +05:30
commit de97b161b1
7 changed files with 379 additions and 0 deletions

244
abis/InstaIndex.json Normal file
View File

@ -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"
}
]

7
networks.json Normal file
View File

@ -0,0 +1,7 @@
{
"mainnet": {
"undefined": {
"address": "0x2971AdFa57b20E5a416aE5a708A8655A9c74f723"
}
}
}

16
package.json Normal file
View File

@ -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"
}
}

6
schema.graphql Normal file
View File

@ -0,0 +1,6 @@
type ExampleEntity @entity {
id: ID!
count: BigInt!
sender: Bytes! # address
owner: Bytes! # address
}

67
src/insta-index.ts Normal file
View File

@ -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 {}

35
subgraph.yaml Normal file
View File

@ -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

4
tsconfig.json Normal file
View File

@ -0,0 +1,4 @@
{
"extends": "@graphprotocol/graph-ts/types/tsconfig.base.json",
"include": ["src"]
}