Skip to content

Commit

Permalink
Add initial skeleton logic for including CMARK credit issuance and tr…
Browse files Browse the repository at this point in the history
…ansfers
  • Loading branch information
0xAurelius committed Dec 11, 2024
1 parent 3594fb6 commit b8605ba
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/abis/CarbonmarkCreditToken.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/abis/CarbonmarkCreditTokenFactory.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { CarbonmarkCreditToken } from '../../generated/templates'
import {
NewTokenProject
} from '../../generated/C3ProjectTokenFactory/C3ProjectTokenFactory'
import { loadOrCreateCarbonCredit, updateCarbonCreditWithCall } from '../utils/CarbonCredit'
import { createTokenWithCall } from '../utils/Token'


export function handleNewCarbonmarkCredit(event: NewTokenProject): void {
// Start indexing the C3T tokens; `event.params.tokenAddress` is the
// address of the new token contract
CarbonmarkCreditToken.create(event.params.tokenAddress)
loadOrCreateCarbonCredit(event.params.tokenAddress, 'CMARK', null)
createTokenWithCall(event.params.tokenAddress, event.block)
updateCarbonCreditWithCall(event.params.tokenAddress, '')
}
85 changes: 68 additions & 17 deletions polygon-digital-carbon/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ schema:
file: ./schema.graphql
dataSources:
- kind: ethereum/contract
name: CarbonProjectsAddress
name: CarbonProjectsAddress
network: matic
source:
address: '0x599a978c43F5cEa1B26a399D28869Ad4690DC07d'
Expand Down Expand Up @@ -74,12 +74,12 @@ dataSources:
- name: ERC20
file: ../lib/abis/ERC20.json
- name: ToucanContractRegistry
file: ../lib/abis/ToucanContractRegistry.json
file: ../lib/abis/ToucanContractRegistry.json
- name: ToucanCarbonOffsetBatches
file: ../lib/abis/ToucanCarbonOffsetBatches.json
file: ../lib/abis/ToucanCarbonOffsetBatches.json
eventHandlers:
- event: TokenCreated(uint256,address)
handler: handleNewPuroTCO2
handler: handleNewPuroTCO2
- kind: ethereum/contract
name: ToucanCarbonOffsetBatch
network: matic
Expand Down Expand Up @@ -107,7 +107,7 @@ dataSources:
- event: BatchUpdated(uint256,string,uint256)
handler: handleBatchUpdated
- event: Transfer(indexed address,indexed address,indexed uint256)
handler: handleBatchTransfer
handler: handleBatchTransfer
- kind: ethereum/contract
name: BCT
network: matic
Expand Down Expand Up @@ -238,7 +238,7 @@ dataSources:
file: ../lib/abis/ERC20.json
eventHandlers:
- event: Transfer(indexed address,indexed address,uint256)
handler: handleCreditTransfer
handler: handleCreditTransfer
- kind: ethereum/contract
name: MossCarbonOffset
network: matic
Expand Down Expand Up @@ -280,11 +280,11 @@ dataSources:
file: ../lib/abis/CCO2.json
- name: ERC20
file: ../lib/abis/ERC20.json
eventHandlers:
eventHandlers:
- event: Transfer(indexed address,indexed address,uint256)
handler: handleCreditTransfer
handler: handleCreditTransfer
- event: burnedCO2Token(uint256)
handler: handleCCO2Retired
handler: handleCCO2Retired
- kind: ethereum/contract
name: Coorest
network: matic
Expand All @@ -302,9 +302,9 @@ dataSources:
abis:
- name: Coorest
file: ../lib/abis/Coorest.json
eventHandlers:
- event: returnedPoccID(uint256)
handler: handleReturnedPoccID
eventHandlers:
- event: returnedPoccID(uint256)
handler: handleReturnedPoccID
- kind: ethereum/contract
name: C3ProjectTokenFactory
network: matic
Expand Down Expand Up @@ -336,6 +336,37 @@ dataSources:
handler: handleStartAsyncToken
- event: EndAsyncToken(address,address,address,uint256,string,string,uint256,uint256,bool,uint256)
handler: handleEndAsyncToken
- kind: ethereum/contract
name: CarbonmarkCreditTokenFactory
network: matic
source:
address: '0xa4c951B30952f5E2feFC8a92F4d3c7551925A63B'
abi: CarbonmarkCreditTokenFactory
startBlock: 65350000
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
file: ./src/templates/CarbonmarkCreditTokenFactory.ts
entities:
- CarbonmarkCreditTokenFactory
abis:
- name: CarbonmarkCreditTokenFactory
file: ../lib/abis/CarbonmarkCreditTokenFactory.json
- name: C3ProjectToken
file: ../lib/abis/CarbonmarkCreditToken.json
- name: ERC20
file: ../lib/abis/ERC20.json
# TODO: determine whether to include
# - name: CarbonmarkCertificateNFT
# file: ../lib/abis/CarbonmarkCertificateNFT.json
eventHandlers:
# TODO: implement this handler
- event: Issued(string,uint256,address,address)
handler: handleNewCarbonmarkCredit
# TODO: determine if we need a handler for cancellation event
# - event: Issued(string,uint256,address,address)
# handler: handleCancelledCMARK
- kind: ethereum/contract
name: UBO
network: matic
Expand Down Expand Up @@ -510,7 +541,7 @@ dataSources:
file: ../lib/abis/ERC20.json
eventHandlers:
- event: C3Retired(indexed address,indexed address,string,string,indexed address,address,uint256)
handler: handleC3Retired
handler: handleC3Retired
- kind: ethereum/contract
name: KlimaInfinity
network: matic
Expand All @@ -535,9 +566,9 @@ dataSources:
- name: ToucanCarbonOffsets
file: ../lib/abis/ToucanCarbonOffsets.json
- name: ToucanContractRegistry
file: ../lib/abis/ToucanContractRegistry.json
file: ../lib/abis/ToucanContractRegistry.json
- name: ToucanCarbonOffsetBatches
file: ../lib/abis/ToucanCarbonOffsetBatches.json
file: ../lib/abis/ToucanCarbonOffsetBatches.json
eventHandlers:
- event: CarbonRetired(uint8,indexed address,string,indexed address,string,string,indexed address,address,uint256)
handler: handleCarbonRetired
Expand Down Expand Up @@ -620,7 +651,7 @@ templates:
handler: handleToucanPuroRetirementReverted
- event: Transfer(indexed address,indexed address,uint256)
handler: handleCreditTransfer
file: ./src/TransferHandler.ts
file: ./src/TransferHandler.ts
- name: C3ProjectToken
kind: ethereum/contract
network: matic
Expand All @@ -641,6 +672,26 @@ templates:
- event: Transfer(indexed address,indexed address,uint256)
handler: handleCreditTransfer
file: ./src/TransferHandler.ts
- name: CarbonmarkCreditToken
kind: ethereum/contract
network: matic
source:
abi: CarbonmarkCreditToken
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- CarbonmarkCreditToken
abis:
- name: CarbonmarkCreditToken
file: ../lib/abis/CarbonmarkCreditToken.json
- name: ERC20
file: ../lib/abis/ERC20.json
eventHandlers:
- event: Transfer(indexed address,indexed address,uint256)
handler: handleCreditTransfer
file: ./src/TransferHandler.ts
- name: ICRProjectToken
kind: ethereum/contract
network: matic
Expand Down Expand Up @@ -677,7 +728,7 @@ templates:
file: ./src/MetadataHandler.ts
handler: handleC3RetirementMetadata
entities:
- C3RetireRequest
- C3RetireRequest
- C3RetirementMetadata
- C3MetadataProject
abis:
Expand Down

0 comments on commit b8605ba

Please sign in to comment.