Skip to content

Commit

Permalink
update handler logic and event templating
Browse files Browse the repository at this point in the history
  • Loading branch information
ryley-o committed Aug 28, 2024
1 parent 1cd3cf6 commit 446bd39
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
24 changes: 24 additions & 0 deletions abis-supplemental/MinPriceLib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "MinPriceLib",
"sourceName": "contracts/libs/v0.8.x/minter-libs/MinPriceLib.sol",
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "defaultMintFee",
"type": "uint256"
}
],
"name": "DefaultMintFeeUpdated",
"type": "event"
}
],
"bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203f3c50a0befcee8c62454a866b00f1cb35d917b564e88c2758a433ea6d7c872164736f6c63430008160033",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203f3c50a0befcee8c62454a866b00f1cb35d917b564e88c2758a433ea6d7c872164736f6c63430008160033",
"linkReferences": {},
"deployedLinkReferences": {}
}
5 changes: 5 additions & 0 deletions config/generic.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
"address": ""
}
],
"minPriceLibContracts": [
{
"address": ""
}
],
"maxInvocationsLibContracts": [
{
"address": ""
Expand Down
35 changes: 35 additions & 0 deletions src/min-price-lib-mapping.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { DefaultMintFeeUpdated } from "../generated/MinPriceLib/MinPriceLib";
import { loadOrCreateMinter } from "./helpers";
import { setMinterExtraMinterDetailsValue } from "./extra-minter-details-helpers";

///////////////////////////////////////////////////////////////////////////////
// EVENT HANDLERS start here
///////////////////////////////////////////////////////////////////////////////

/**
* Handles the update of contract-level default mint fee.
* Loads or creates the minter, updates the minter's extra minter details with
* the updated value, and induces a sync of the minter entity.
* @param event The event carrying new default mint fee value.
*/
export function handleDefaultMintFeeUpdated(
event: DefaultMintFeeUpdated
): void {
// load minter
const minter = loadOrCreateMinter(event.address, event.block.timestamp);

// update minter entity
setMinterExtraMinterDetailsValue(
"defaultMintFee",
event.params.defaultMintFee.toString(),
minter
);

// update minter's updatedAt timestamp to induce a sync, and save
minter.updatedAt = event.block.timestamp;
minter.save();
}

///////////////////////////////////////////////////////////////////////////////
// EVENT HANDLERS end here
///////////////////////////////////////////////////////////////////////////////
51 changes: 51 additions & 0 deletions subgraph.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,57 @@ dataSources:
handler: handlePricePerTokenReset
file: ./src/set-price-lib-mapping.ts
{{/setPriceLibContracts}}
{{#minPriceLibContracts}}
- kind: ethereum/contract
name: 'MinPriceLib{{#address}}-{{address}}{{/address}}'
network: {{network}}
source:
address: "{{#address}}{{address}}{{/address}}{{^address}}0x0000000000000000000000000000000000000000{{/address}}"
abi: MinPriceLib
{{#startBlock}}startBlock: {{startBlock}}{{/startBlock}}
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
entities:
- Project
- ProjectScript
- Token
- Contract
- Account
- AccountProject
- Whitelisting
- MinterFilter
- Minter
- ProjectMinterConfiguration
abis:
- name: MinPriceLib
file: ./abis/MinPriceLib.json
- name: ISharedMinterV0
file: ./abis/ISharedMinterV0.json
- name: IFilteredMinterV2
file: ./abis/IFilteredMinterV2.json
- name: IFilteredMinterDALinV1
file: ./abis/IFilteredMinterDALinV1.json
- name: IFilteredMinterDAExpV1
file: ./abis/IFilteredMinterDAExpV1.json
- name: IFilteredMinterDAExpSettlementV1
file: ./abis/IFilteredMinterDAExpSettlementV1.json
- name: IFilteredMinterV2
file: ./abis/IFilteredMinterV2.json
- name: IFilteredMinterHolderV2
file: ./abis/IFilteredMinterHolderV2.json
- name: IFilteredMinterMerkleV2
file: ./abis/IFilteredMinterMerkleV2.json
- name: IFilteredMinterSEAV0
file: ./abis/IFilteredMinterSEAV0.json
- name: ERC20
file: ./abis/ERC20.json
eventHandlers:
- event: DefaultMintFeeUpdated(uint256)
handler: handleDefaultMintFeeUpdated
file: ./src/min-price-lib-mapping.ts
{{/minPriceLibContracts}}
{{#maxInvocationsLibContracts}}
- kind: ethereum/contract
name: 'MaxInvocationsLib{{#address}}-{{address}}{{/address}}'
Expand Down

0 comments on commit 446bd39

Please sign in to comment.