Skip to content

Commit

Permalink
updating subgrapjh
Browse files Browse the repository at this point in the history
  • Loading branch information
ethereumdegen committed Mar 20, 2023
1 parent cd71856 commit 8ee9c5b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/subgraph/config/goerli.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
"address_collateral_manager": "0x62824Ff0BDbc42874e23f3cA9966866659F39b09",
"block_collateral_manager": "8688915",
"address_lender_manager": "0x786a95b7605E52a6E8E6dA20d44a1E0aDA5E58b1",
"block_lender_manager": "8688915"
"block_lender_manager": "8688915",
"address_enumerable_set_allowlist": "0x5fe160b786a0274e115c2bee948ab60fc0bdab2f",
"block_enumerable_set_allowlist": "8688915"
}
33 changes: 33 additions & 0 deletions packages/subgraph/src/allowlist-mapping.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { UpdatedAllowList,EnumerableSetAllowlist } from "../generated/EnumerableSetAllowlist/EnumerableSetAllowlist";
import { loadCommitment } from "./helpers/loaders";
import { Address, BigInt, Bytes, store } from "@graphprotocol/graph-ts";



export function handleUpdatedAllowLists(events: UpdatedAllowList[]): void {
events.forEach(event => {
handleUpdatedAllowList(event);
});
}



export function handleUpdatedAllowList(event: UpdatedAllowList): void {

const enumerableSetAllowlistInstance = EnumerableSetAllowlist.bind(
event.address
);

const commitmentId = event.params.commitmentId.toString();
const commitment = loadCommitment(commitmentId);

const borrowers = enumerableSetAllowlistInstance.getAllowedAddresses(
BigInt.fromString(commitmentId)
);

if (borrowers) {
commitment.commitmentBorrowers = changetype<Bytes[]>(borrowers);
}


}
4 changes: 3 additions & 1 deletion packages/subgraph/src/subgraph.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,14 @@ dataSources:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
entities:
- Commitment
abis:
- name: EnumerableSetAllowlist
file: ./abis/{{network}}_EnumerableSetAllowlist.json
eventHandlers:
- event: UpdatedAllowList(uint256)
handler: handleUpdatedAllowlist
handler: handleUpdatedAllowLists
file: ./src/allowlist-mapping.ts
- kind: ethereum/contract
name: CollateralManager
Expand Down

0 comments on commit 8ee9c5b

Please sign in to comment.