Skip to content

Commit

Permalink
feat: save last demurrage timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
vibern0 committed Oct 29, 2024
1 parent 7614a84 commit e9f07b0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ contracts:
- event: PersonalMint(address indexed human, uint256 amount, uint256 period, uint256 endPeriod)
- event: TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value)
- event: TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values)
- event: DiscountCost(address indexed account, uint256 indexed id, uint256 discountCost)
- name: ERC20Lift
handler: src/event_handlers/hubV2.ts
events:
Expand Down
1 change: 1 addition & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ type Avatar {
balance: BigInt!
lastMint: Int
mintEndPeriod: Int
lastDemurrageUpdate: Int
trustedByN: Int!
profile: Profile
}
Expand Down
15 changes: 14 additions & 1 deletion src/event_handlers/hubV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
HubV2_TransferSingle_eventArgs,
HubV2_TransferBatch_eventArgs,
WrapperERC20Personal_Transfer_eventArgs,
Token,
StandardTreasury,
NameRegistry,
SafeAccount,
Expand Down Expand Up @@ -96,6 +95,7 @@ HubV2.RegisterHuman.handler(async ({ event, context }) => {
balance: 0n,
lastMint: undefined,
mintEndPeriod: undefined,
lastDemurrageUpdate: undefined,
trustedByN: 0,
profile_id: event.params.avatar,
};
Expand Down Expand Up @@ -147,6 +147,7 @@ HubV2.RegisterOrganization.handler(async ({ event, context }) => {
balance: 0n,
lastMint: undefined,
mintEndPeriod: undefined,
lastDemurrageUpdate: undefined,
trustedByN: 0,
profile_id: event.params.organization,
};
Expand All @@ -173,6 +174,7 @@ HubV2.RegisterGroup.handler(async ({ event, context }) => {
balance: 0n,
lastMint: undefined,
mintEndPeriod: undefined,
lastDemurrageUpdate: undefined,
trustedByN: 0,
profile_id: event.params.group,
};
Expand Down Expand Up @@ -498,6 +500,16 @@ HubV2.TransferBatch.handler(
})
);

HubV2.DiscountCost.handler(async ({ event, context }) => {
const avatar = await context.Avatar.get(event.params.account);
if (avatar) {
context.Avatar.set({
...avatar,
lastDemurrageUpdate: event.block.timestamp,
});
}
});

WrapperERC20Personal.Transfer.handler(
async ({ event, context }) =>
await handleTransfer({
Expand Down Expand Up @@ -602,6 +614,7 @@ HubV2.Trust.handler(async ({ event, context }) => {
balance: 0n,
lastMint: undefined,
mintEndPeriod: undefined,
lastDemurrageUpdate: undefined,
trustedByN: 1,
profile_id: event.params.trustee,
});
Expand Down

0 comments on commit e9f07b0

Please sign in to comment.