Skip to content

Commit

Permalink
Update crowdSaleMapping.ts
Browse files Browse the repository at this point in the history
Update stakedLockingCrowdSaleMapping.ts

remove deprecated subgraph reference

remove started event params
  • Loading branch information
schmackofant authored and elmariachi111 committed Oct 27, 2023
1 parent 7d006b6 commit 8b1d945
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 52 deletions.
2 changes: 1 addition & 1 deletion subgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"prepare:local": "mustache config/local.js subgraph.template.yaml > subgraph.yaml",
"prepare:goerli": "mustache config/goerli.js subgraph.template.yaml > subgraph.yaml",
"prepare:mainnet": "mustache config/mainnet.js subgraph.template.yaml > subgraph.yaml",
"deploy:goerli": "graph deploy --product hosted-service elmariachi111/schrotti-galoppi-schmacko-1",
"deploy:goerli": "graph deploy --product hosted-service moleculeprotocol/ip-nft-goerli",
"deploy": "graph deploy --product hosted-service moleculeprotocol/ip-nft-mainnet",
"create:local": "graph create --node http://localhost:8020/ moleculeprotocol/ipnft-subgraph",
"remove:local": "graph remove --node http://localhost:8020/ moleculeprotocol/ipnft-subgraph",
Expand Down
59 changes: 10 additions & 49 deletions subgraph/src/crowdSaleMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,6 @@ import {
import { CrowdSale, ERC20Token, IPT, Contribution } from '../generated/schema'

// Helpers & Generic Handlers to handle different types of CrowdSales

export class StartedEventParams {
saleId: BigInt
issuer: Address
auctionToken: Address
biddingToken: Address
beneficiary: Address
fundingGoal: BigInt
salesAmount: BigInt
closingTime: BigInt
permissioner: Address

constructor(
saleId: BigInt,
issuer: Address,
auctionToken: Address,
biddingToken: Address,
beneficiary: Address,
fundingGoal: BigInt,
salesAmount: BigInt,
closingTime: BigInt,
permissioner: Address
) {
this.saleId = saleId
this.issuer = issuer
this.auctionToken = auctionToken
this.biddingToken = biddingToken
this.beneficiary = beneficiary
this.fundingGoal = fundingGoal
this.salesAmount = salesAmount
this.closingTime = closingTime
this.permissioner = permissioner
}
}
export class BidEventParams {
saleId: BigInt
bidder: Address
Expand Down Expand Up @@ -109,9 +75,7 @@ export function makeERC20Token(_contract: IERC20Metadata): ERC20Token {
export function handleSettledGeneric(saleId: string): void {
let crowdSale = CrowdSale.load(saleId)
if (!crowdSale) {
return log.error('[handleSettled] Plain CrowdSale not found for id: {}', [
saleId
])
return log.error('[handleSettled] CrowdSale not found for id: {}', [saleId])
}
crowdSale.state = 'SETTLED'
crowdSale.save()
Expand All @@ -120,9 +84,7 @@ export function handleSettledGeneric(saleId: string): void {
export function handleFailedGeneric(saleId: string): void {
let crowdSale = CrowdSale.load(saleId)
if (!crowdSale) {
return log.error('[handleFailed] Plain CrowdSale not found for id: {}', [
saleId
])
return log.error('[handleFailed] CrowdSale not found for id: {}', [saleId])
}
crowdSale.state = 'FAILED'
crowdSale.save()
Expand Down Expand Up @@ -162,7 +124,7 @@ export function handleBidGeneric(params: BidEventParams): void {
export function handleClaimedGeneric(params: ClaimedEventParams): void {
let crowdSale = CrowdSale.load(params.saleId.toString())
if (!crowdSale) {
log.error('[HANDLECLAIMED] Plain CrowdSale not found for id: {}', [
log.error('[HANDLECLAIMED] CrowdSale not found for id: {}', [
params.saleId.toString()
])
return
Expand All @@ -174,7 +136,7 @@ export function handleClaimedGeneric(params: ClaimedEventParams): void {

if (contribution === null) {
log.error(
'[HANDLECLAIMED] No contribution found for Plain CrowdSale | user : {} | {}',
'[HANDLECLAIMED] No contribution found for CrowdSale | user : {} | {}',
[params.saleId.toString(), params.claimer.toHexString()]
)
return
Expand All @@ -192,7 +154,7 @@ export function handleClaimedSuccessfulSaleGeneric(
): void {
let crowdSale = CrowdSale.load(saleId)
if (!crowdSale) {
log.error('[handleClaimed] Plain CrowdSale not found for id: {}', [saleId])
log.error('[handleClaimed] CrowdSale not found for id: {}', [saleId])
return
}
crowdSale.claimedAt = timestamp
Expand All @@ -205,10 +167,9 @@ export function handleClaimedFailedSaleGeneric(
): void {
let crowdSale = CrowdSale.load(saleId)
if (!crowdSale) {
log.error(
'[handleClaimedFailedSale] Plain CrowdSale not found for id: {}',
[saleId]
)
log.error('[handleClaimedFailedSale] CrowdSale not found for id: {}', [
saleId
])
return
}
crowdSale.claimedAt = timestamp
Expand All @@ -222,7 +183,7 @@ export function handleStarted(event: StartedEvent): void {

let ipt = IPT.load(event.params.sale.auctionToken.toHexString())
if (!ipt) {
log.error('[Plain Crowdsale] Ipt not found for id: {}', [
log.error('[Crowdsale] Ipt not found for id: {}', [
event.params.sale.auctionToken.toHexString()
])
return
Expand All @@ -249,7 +210,7 @@ export function handleStarted(event: StartedEvent): void {
crowdSale.amountStaked = BigInt.fromU32(0)

crowdSale.save()
log.info('[handleStarted] plain crowdsale {}', [crowdSale.id])
log.info('[handleStarted] crowdsale {}', [crowdSale.id])
}

export function handleSettled(event: SettledEvent): void {
Expand Down
4 changes: 2 additions & 2 deletions subgraph/src/stakedLockingCrowdSaleMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ export function handleStarted(event: StartedEvent): void {

crowdSale.permissioner = event.params.sale.permissioner

crowdSale.type = 'STAKED_LOCKING_CROWDSALE'

crowdSale.auctionLockingDuration = event.params.lockingDuration
crowdSale.stakingToken = makeERC20Token(
IERC20Metadata.bind(event.params.staking.stakedToken)
Expand All @@ -122,6 +120,8 @@ export function handleStarted(event: StartedEvent): void {
crowdSale.wadFixedStakedPerBidPrice =
event.params.staking.wadFixedStakedPerBidPrice

crowdSale.type = 'STAKED_LOCKING_CROWDSALE'

crowdSale.save()
log.info('[handleStarted] crowdsale {}', [crowdSale.id])
}
Expand Down

0 comments on commit 8b1d945

Please sign in to comment.