Merge pull request #2 from Richa-iitr/new

updated to call handlers
This commit is contained in:
Richa 2022-09-05 22:56:06 +05:30 committed by GitHub
commit 9656b1faa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 79 additions and 32 deletions

View File

@ -31,8 +31,6 @@ type TransactionData @entity {
id: ID! id: ID!
# transaction index # transaction index
txnIndex: BigInt! txnIndex: BigInt!
# transaction log index
txnLogIndex: BigInt!
# from # from
from: Bytes! from: Bytes!
# to # to

View File

@ -1,38 +1,86 @@
import { import {
cUSDCv3, cUSDCv3,
Approval Approval,
} from "../generated/cUSDCv3/cUSDCv3" AllowCall,
import { createOrLoadManager, createOrLoadOwner, createOrLoadTransaction, isDSA, ZERO } from "./utils"; AllowBySigCall,
} from "../generated/cUSDCv3/cUSDCv3";
import {
createOrLoadManager,
createOrLoadOwner,
createOrLoadTransaction,
isDSA,
ZERO,
} from "./utils";
export function handleManagerToggled(event: Approval): void { export function handleManagerToggledByAllow(call: AllowCall): void {
let ownerID = event.params.owner.toHexString() + "#" + event.address.toHexString(); let ownerID =
let managerID = event.params.spender.toHexString() + "#" + event.params.owner.toHexString() + "#" + event.address.toHexString(); call.transaction.from.toHexString() + "#" + call.to.toHexString();
let transactionID = event.transaction.hash.toHexString() + "#" + event.logIndex.toString(); let managerID = call.inputs.manager.toHexString() + "#" + ownerID;
let transactionID =
call.transaction.hash.toHexString() +
"#" +
call.transaction.index.toString();
let transactionData = createOrLoadTransaction(transactionID); let transactionData = createOrLoadTransaction(transactionID);
transactionData.txnIndex = event.transaction.index; transactionData.txnIndex = call.transaction.index;
transactionData.txnLogIndex = event.transactionLogIndex; transactionData.from = call.transaction.from;
transactionData.from = event.transaction.from; transactionData.to = call.to;
transactionData.to = event.transaction.to; transactionData.input = call.transaction.input;
transactionData.input = event.transaction.input; transactionData.blockNumber = call.block.number;
transactionData.blockNumber = event.block.number; transactionData.timestamp = call.block.timestamp;
transactionData.timestamp = event.block.timestamp; transactionData.gasLimit = call.block.gasLimit;
transactionData.gasLimit = event.block.gasLimit; transactionData.blockGasUsed = call.block.gasUsed;
transactionData.blockGasUsed = event.block.gasUsed; transactionData.gasPrice = call.transaction.gasPrice;
transactionData.gasPrice = event.transaction.gasPrice; transactionData.value = call.transaction.value;
transactionData.value = event.transaction.value;
let manager = createOrLoadManager(managerID); let manager = createOrLoadManager(managerID);
manager.address = event.params.spender; manager.address = call.inputs.manager;
manager.isAllowed = event.params.amount == ZERO ? false : true; manager.isAllowed = call.inputs.isAllowed_;
manager.owner = ownerID; manager.owner = ownerID;
manager.market = event.address; manager.market = call.to;
manager.isDSA = isDSA(event.params.spender); manager.isDSA = isDSA(call.inputs.manager);
manager.transactionData = transactionID; manager.transactionData = transactionID;
let owner = createOrLoadOwner(ownerID); let owner = createOrLoadOwner(ownerID);
owner.address = event.params.owner; owner.address = call.transaction.from;
owner.market = event.address; owner.market = call.to;
transactionData.save();
manager.save();
owner.save();
}
export function handleManagerToggledByPermit(call: AllowBySigCall): void {
let ownerID = call.inputs.owner.toHexString() + "#" + call.to.toHexString();
let managerID = call.inputs.manager.toHexString() + "#" + ownerID;
let transactionID =
call.transaction.hash.toHexString() +
"#" +
call.transaction.index.toString();
let transactionData = createOrLoadTransaction(transactionID);
transactionData.txnIndex = call.transaction.index;
transactionData.from = call.transaction.from;
transactionData.to = call.to;
transactionData.input = call.transaction.input;
transactionData.blockNumber = call.block.number;
transactionData.timestamp = call.block.timestamp;
transactionData.gasLimit = call.block.gasLimit;
transactionData.blockGasUsed = call.block.gasUsed;
transactionData.gasPrice = call.transaction.gasPrice;
transactionData.value = call.transaction.value;
let manager = createOrLoadManager(managerID);
manager.address = call.inputs.manager;
manager.isAllowed = call.inputs.isAllowed_;
manager.owner = ownerID;
manager.market = call.to;
manager.isDSA = isDSA(call.inputs.manager);
manager.transactionData = transactionID;
let owner = createOrLoadOwner(ownerID);
owner.address = call.inputs.owner;
owner.market = call.to;
transactionData.save(); transactionData.save();
manager.save(); manager.save();

View File

@ -52,7 +52,6 @@ export function createOrLoadTransaction(id: string): TransactionData {
if (txn == null) { if (txn == null) {
txn = new TransactionData(id); txn = new TransactionData(id);
txn.txnIndex = ZERO; txn.txnIndex = ZERO;
txn.txnLogIndex = ZERO;
txn.from = new Address(0); txn.from = new Address(0);
txn.to = new Address(0); txn.to = new Address(0);
txn.input = new Bytes(0); txn.input = new Bytes(0);

View File

@ -22,7 +22,9 @@ dataSources:
file: ./abis/cUSDCv3.json file: ./abis/cUSDCv3.json
- name: InstaList - name: InstaList
file: ./abis/InstaList.json file: ./abis/InstaList.json
eventHandlers: callHandlers:
- event: Approval(indexed address,indexed address,uint256) - function: allow(address,bool)
handler: handleManagerToggled handler: handleManagerToggledByAllow
- function: allowBySig(address,address,bool,uint256,uint256,uint8,bytes32,bytes32)
handler: handleManagerToggledByPermit
file: ./src/compound-v3-managers.ts file: ./src/compound-v3-managers.ts