Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: save last demurrage timestamp #2

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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