Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🗼 Add token id to CRT notifications #326

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions schema/notifications.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ type CreatorTokenIssued @variant {
"symbol of the token"
tokenSymbol: String!

"id of the token"
tokenId: String!

"channel Id used for link"
channelId: String!
}
Expand All @@ -441,6 +444,9 @@ type CreatorTokenSaleStarted @variant {
"symbol of the token"
tokenSymbol: String!

"id of the token"
tokenId: String!

"channel Id used for link"
channelId: String!
}
Expand All @@ -452,6 +458,9 @@ type CreatorTokenMarketStarted @variant {
"symbol of the token"
tokenSymbol: String!

"id of the token"
tokenId: String!

"channel Id used for link"
channelId: String!
}
Expand All @@ -474,6 +483,9 @@ type CreatorTokenMarketMint @variant {

"symbol of the token"
tokenSymbol: String!

"id of the token"
tokenId: String!
}

type CreatorTokenMarketBurn @variant {
Expand All @@ -494,6 +506,9 @@ type CreatorTokenMarketBurn @variant {

"symbol of the token"
tokenSymbol: String!

"id of the token"
tokenId: String!
}

type CreatorTokenSaleMint @variant {
Expand All @@ -514,6 +529,9 @@ type CreatorTokenSaleMint @variant {

"symbol of the token"
tokenSymbol: String!

"id of the token"
tokenId: String!
}

type CreatorTokenRevenueShareStarted @variant {
Expand Down Expand Up @@ -543,6 +561,9 @@ type CreatorTokenRevenueSharePlanned @variant {
"symbol of the token"
tokenSymbol: String!

"id of the token"
tokenId: String!

"block on which split is planned to start"
plannedAt: Int!

Expand Down
7 changes: 7 additions & 0 deletions src/mappings/token/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
},
}: EventHandlerContext<'ProjectToken.TokenIssued'>) {
// create token
const totalSupply = initialAllocation.reduce((acc, [_, allocation]) => {

Check warning on line 80 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

'_' is defined but never used
return acc + allocation.amount
}, BigInt(0))

Expand Down Expand Up @@ -152,6 +152,7 @@
// CreatorTokenIssued event is dispatch after TokenIssued
const notificationData = new CreatorTokenIssued({
tokenSymbol: parseCreatorTokenSymbol(token),
tokenId: token.id,
channelId: channelId.toString(),
channelTitle: parseChannelTitle(channel),
})
Expand Down Expand Up @@ -242,6 +243,7 @@

const notificationData = new CreatorTokenMarketStarted({
tokenSymbol: parseCreatorTokenSymbol(token),
tokenId: token.id,
channelId: tokenChannel.channelId,
channelTitle: parseChannelTitle(channel),
})
Expand Down Expand Up @@ -326,6 +328,7 @@

const notificationData = new CreatorTokenSaleStarted({
tokenSymbol: parseCreatorTokenSymbol(token),
tokenId: token.id,
channelId: tokenChannel.channelId,
channelTitle: parseChannelTitle(channel),
})
Expand Down Expand Up @@ -384,7 +387,7 @@
buyerAccount.totalAmount += crtMinted
}

const activeAmm = await overlay.getRepository(AmmCurve).getByIdOrFail(token.currentAmmSaleId!)

Check warning on line 390 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

Forbidden non-null assertion

activeAmm.mintedByAmm += crtMinted
const tx = overlay.getRepository(AmmTransaction).new({
Expand Down Expand Up @@ -412,6 +415,7 @@
const notificationData = new CreatorTokenMarketMint({
channelId: tokenChannel.channelId,
tokenSymbol: parseCreatorTokenSymbol(token),
tokenId: token.id,
mintedTokenAmount: crtMinted,
minterHandle: minter?.handle ?? 'Someone',
paiedJoyAmount: joysDeposited,
Expand Down Expand Up @@ -443,7 +447,7 @@
.getOneByRelationOrFail('tokenId', tokenId.toString())
const channel = await overlay.getRepository(Channel).getByIdOrFail(tokenChannel.channelId)
token.totalSupply -= crtBurned
const activeAmm = await overlay.getRepository(AmmCurve).getByIdOrFail(token.currentAmmSaleId!)

Check warning on line 450 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

Forbidden non-null assertion
const ammId = activeAmm.id

const sellerAccount = await getTokenAccountByMemberByTokenOrFail(overlay, memberId, tokenId)
Expand Down Expand Up @@ -477,6 +481,7 @@
const notificationData = new CreatorTokenMarketBurn({
channelId: tokenChannel.channelId,
tokenSymbol: parseCreatorTokenSymbol(token),
tokenId: token.id,
burnedTokenAmount: crtBurned,
burnerHandle: burnerMember?.handle ?? 'Someone',
receivedJoyAmount: joysRecovered,
Expand Down Expand Up @@ -515,7 +520,7 @@
}

const token = await overlay.getRepository(CreatorToken).getByIdOrFail(tokenId.toString())
const sale = await overlay.getRepository(Sale).getByIdOrFail(token.currentSaleId!)

Check warning on line 523 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

Forbidden non-null assertion
sale.tokensSold += amountPurchased

const tx = overlay.getRepository(SaleTransaction).new({
Expand Down Expand Up @@ -551,6 +556,7 @@
const notificationData = new CreatorTokenSaleMint({
channelId: tokenChannel.channelId,
tokenSymbol: parseCreatorTokenSymbol(token),
tokenId: token.id,
mintedTokenAmount: amountPurchased,
minterHandle: minterMember?.handle ?? 'Someone',
paiedJoyAmount: sale.pricePerUnit * amountPurchased,
Expand All @@ -574,7 +580,7 @@
},
}: EventHandlerContext<'ProjectToken.UpcomingTokenSaleUpdated'>) {
const token = await overlay.getRepository(CreatorToken).getByIdOrFail(tokenId.toString())
const sale = await overlay.getRepository(Sale).getByIdOrFail(token.currentSaleId!)

Check warning on line 583 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

Forbidden non-null assertion

if (newStart) {
sale.startBlock = newStart
Expand Down Expand Up @@ -658,6 +664,7 @@
channelId: channel.id,
plannedAt: startBlock,
tokenSymbol: parseCreatorTokenSymbol(token),
tokenId: token.id,
})

await notifyTokenHolders(overlay, tokenId.toString(), revenueSharePlannedNotification, event)
Expand Down Expand Up @@ -692,13 +699,13 @@
export async function processAmmDeactivatedEvent({
overlay,
event: {
asV2002: [tokenId, , burnedAmount],

Check warning on line 702 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

'burnedAmount' is defined but never used
},
}: EventHandlerContext<'ProjectToken.AmmDeactivated'>) {
const token = await overlay.getRepository(CreatorToken).getByIdOrFail(tokenId.toString())
token.status = TokenStatus.IDLE

const activeAmm = await overlay.getRepository(AmmCurve).getByIdOrFail(token.currentAmmSaleId!)

Check warning on line 708 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

Forbidden non-null assertion
activeAmm.finalized = true

token.currentAmmSaleId = null
Expand Down Expand Up @@ -737,12 +744,12 @@
},
}: EventHandlerContext<'ProjectToken.TokenSaleFinalized'>) {
const token = await overlay.getRepository(CreatorToken).getByIdOrFail(tokenId.toString())
const sale = await overlay.getRepository(Sale).getByIdOrFail(token.currentSaleId!)

Check warning on line 747 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

Forbidden non-null assertion
sale.finalized = true

const sourceAccount = await overlay
.getRepository(TokenAccount)
.getByIdOrFail(sale.fundsSourceAccountId!)

Check warning on line 752 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

Forbidden non-null assertion
sourceAccount.totalAmount += quantityLeft

token.status = TokenStatus.IDLE
Expand Down Expand Up @@ -778,7 +785,7 @@
const token = await overlay.getRepository(CreatorToken).getByIdOrFail(tokenId.toString())
const revenueShare = await overlay
.getRepository(RevenueShare)
.getByIdOrFail(token.currentRevenueShareId!)

Check warning on line 788 in src/mappings/token/index.ts

View workflow job for this annotation

GitHub Actions / Local build, linting and formatting (ubuntu-latest, 16.x)

Forbidden non-null assertion
revenueShare.finalized = true
token.currentRevenueShareId = null
}
Expand Down
Loading