diff --git a/config.yaml b/config.yaml index a9fff88..4924cac 100644 --- a/config.yaml +++ b/config.yaml @@ -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: diff --git a/schema.graphql b/schema.graphql index ab4acfe..55db3bf 100644 --- a/schema.graphql +++ b/schema.graphql @@ -104,6 +104,7 @@ type Avatar { balance: BigInt! lastMint: Int mintEndPeriod: Int + lastDemurrageUpdate: Int trustedByN: Int! profile: Profile } diff --git a/src/event_handlers/hubV2.ts b/src/event_handlers/hubV2.ts index b8d222f..3ce94b7 100644 --- a/src/event_handlers/hubV2.ts +++ b/src/event_handlers/hubV2.ts @@ -12,7 +12,6 @@ import { HubV2_TransferSingle_eventArgs, HubV2_TransferBatch_eventArgs, WrapperERC20Personal_Transfer_eventArgs, - Token, StandardTreasury, NameRegistry, SafeAccount, @@ -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, }; @@ -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, }; @@ -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, }; @@ -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({ @@ -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, });