Skip to content

Commit

Permalink
Merge pull request #71 from aavegotchi/SUB-93-handle-whitelist-owners…
Browse files Browse the repository at this point in the history
…hip-transferred

SUB-93: handle whitelist ownership transferred
  • Loading branch information
cinnabarhorse authored Oct 4, 2022
2 parents 4f1fa6b + bdb2d62 commit e9bb263
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
19 changes: 19 additions & 0 deletions abis/AavegotchiDiamond.json
Original file line number Diff line number Diff line change
Expand Up @@ -9008,6 +9008,25 @@
"name": "WhitelistUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint32",
"name": "whitelistId",
"type": "uint32"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "WhitelistOwnershipTransferred",
"type": "event"
},
{
"inputs": [
{
Expand Down
7 changes: 7 additions & 0 deletions src/mappings/diamond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
GotchiLendingClaimed,
GotchiLendingAdded,
WhitelistAccessRightSet,
WhitelistOwnershipTransferred,
} from "../../generated/AavegotchiDiamond/AavegotchiDiamond";
import {
getOrCreateUser,
Expand Down Expand Up @@ -1006,6 +1007,12 @@ export function handleWhitelistUpdated(event: WhitelistUpdated): void {
createOrUpdateWhitelist(event.params.whitelistId, event);
}

export function handleWhitelistOwnershipTransferred(
event: WhitelistOwnershipTransferred
): void {
createOrUpdateWhitelist(event.params.whitelistId, event);
}

export function handleGotchiLendingAdd(event: GotchiLendingAdd): void {
if (event.block.number.gt(BLOCK_DISABLE_OLD_LENDING_EVENTS)) {
return;
Expand Down
8 changes: 4 additions & 4 deletions src/utils/helpers/diamond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,13 +747,13 @@ export function createOrUpdateWhitelist(
if (!whitelist) {
whitelist = new Whitelist(id.toString());
whitelist.maxBorrowLimit = 1;
whitelist.ownerAddress = result.owner;
let user = getOrCreateUser(result.owner.toHexString());
user.save();
whitelist.owner = user.id;
whitelist.name = name;
}

let user = getOrCreateUser(result.owner.toHexString());
user.save();
whitelist.owner = user.id;
whitelist.ownerAddress = result.owner;
whitelist.members = members.map<Bytes>((e) => e);

whitelist.save();
Expand Down
2 changes: 2 additions & 0 deletions subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ dataSources:
handler: handleWhitelistCreated
- event: WhitelistUpdated(indexed uint32)
handler: handleWhitelistUpdated
- event: WhitelistOwnershipTransferred(indexed uint32,indexed address)
handler: handleWhitelistOwnershipTransferred
- event: GotchiLendingAdd(indexed uint32)
handler: handleGotchiLendingAdd
- event: GotchiLendingClaim(indexed uint32,address[],uint256[])
Expand Down

0 comments on commit e9bb263

Please sign in to comment.