From 446bd39049d2584277db1a56f1433645ea339ecc Mon Sep 17 00:00:00 2001 From: ryley-o <30364988+ryley-o@users.noreply.github.com> Date: Wed, 28 Aug 2024 12:56:21 -0700 Subject: [PATCH] update handler logic and event templating --- abis-supplemental/MinPriceLib.json | 24 ++++++++++++++ config/generic.json | 5 +++ src/min-price-lib-mapping.ts | 35 ++++++++++++++++++++ subgraph.template.yaml | 51 ++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 abis-supplemental/MinPriceLib.json create mode 100644 src/min-price-lib-mapping.ts diff --git a/abis-supplemental/MinPriceLib.json b/abis-supplemental/MinPriceLib.json new file mode 100644 index 00000000..72a5aacb --- /dev/null +++ b/abis-supplemental/MinPriceLib.json @@ -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": {} +} diff --git a/config/generic.json b/config/generic.json index e247f9d5..84b425b0 100644 --- a/config/generic.json +++ b/config/generic.json @@ -75,6 +75,11 @@ "address": "" } ], + "minPriceLibContracts": [ + { + "address": "" + } + ], "maxInvocationsLibContracts": [ { "address": "" diff --git a/src/min-price-lib-mapping.ts b/src/min-price-lib-mapping.ts new file mode 100644 index 00000000..6ab9213d --- /dev/null +++ b/src/min-price-lib-mapping.ts @@ -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 +/////////////////////////////////////////////////////////////////////////////// diff --git a/subgraph.template.yaml b/subgraph.template.yaml index f6ed7d04..80df80a1 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -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}}'