generated from blockmatic-icebox/powerstack
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: presale token issuance part 3 (#325)
* chore(alchemy): export types * chore(indexer): log process event id * chore(indexer): log process event id * chore: prod network conig, validate networks * wip(indexer): validate before triggering * chore: add try catch Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- Loading branch information
1 parent
85ff357
commit 4235767
Showing
12 changed files
with
133 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Alchemy, Network, WebhookType } from 'alchemy-sdk' | ||
import { appConfig } from './config' | ||
|
||
async function createAddressActivityNotification() { | ||
try { | ||
const settings = { | ||
authToken: appConfig.alchemyNotifyToken, | ||
network: Network.MATIC_MAINNET, // Replace with your network. | ||
} | ||
|
||
const alchemy = new Alchemy(settings) | ||
const addressActivityWebhook = await alchemy.notify.createWebhook( | ||
appConfig.alchemyActivityWebhookUrl, | ||
WebhookType.ADDRESS_ACTIVITY, | ||
{ | ||
addresses: [appConfig.presaleAddress], | ||
network: Network.MATIC_MAINNET, | ||
}, | ||
) | ||
console.log('Address Activity Webhook Details:') | ||
console.log(JSON.stringify(addressActivityWebhook, null, 2)) | ||
console.log( | ||
'Alchemy Notify address activity notification created, go to https://dashboard.alchemy.com/notify to see details of your custom hook.', | ||
) | ||
} catch (error) { | ||
console.error('Failed to create address activity notification:', error) | ||
} | ||
} | ||
|
||
createAddressActivityNotification() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1 @@ | ||
import { Alchemy, Network, WebhookType } from 'alchemy-sdk' | ||
import { appConfig } from './config' | ||
|
||
async function createAddressActivityNotification() { | ||
const settings = { | ||
authToken: appConfig.alchemyNotifyToken, | ||
network: Network.MATIC_MAINNET, // Replace with your network. | ||
} | ||
|
||
const alchemy = new Alchemy(settings) | ||
const addressActivityWebhook = await alchemy.notify.createWebhook( | ||
appConfig.alchemyActivityWebhookUrl, | ||
WebhookType.ADDRESS_ACTIVITY, | ||
{ | ||
addresses: [appConfig.presaleAddress], | ||
network: Network.MATIC_MAINNET, | ||
}, | ||
) | ||
console.log('Address Activity Webhook Details:') | ||
console.log(JSON.stringify(addressActivityWebhook, null, 2)) | ||
console.log( | ||
'Alchemy Notify address activity notification created, go to https://dashboard.alchemy.com/notify to see details of your custom hook.', | ||
) | ||
} | ||
|
||
createAddressActivityNotification() | ||
export * from './types' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Network } from 'alchemy-sdk' | ||
export interface AlchemyWebhookEvent { | ||
webhookId: string | ||
id: string | ||
createdAt: Date | ||
type: AlchemyWebhookType | ||
event: Record<any, any> | ||
} | ||
|
||
export type AlchemyWebhookType = | ||
| 'MINED_TRANSACTION' | ||
| 'DROPPED_TRANSACTION' | ||
| 'ADDRESS_ACTIVITY' | ||
|
||
export interface AlchemyActivity { | ||
fromAddress: string | ||
toAddress: string | ||
blockNum: string | ||
hash: string | ||
value: number | ||
asset: string | ||
category: string | ||
rawContract: { | ||
rawValue: string | ||
decimals: number | ||
} | ||
} | ||
|
||
export interface AlchemyActivityEvent { | ||
network: Network | ||
activity: AlchemyActivity[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
import type { AlchemyWebhookEvent, AlchemyActivity } from '@repo/alchemy' | ||
import { logger, task } from '@trigger.dev/sdk/v3' | ||
import { getErrorMessage } from 'app-lib' | ||
|
||
// AlchemyWebhookEvent | ||
export const addressActivityTask = task({ | ||
id: 'address-activity', | ||
run: async (payload: any, { ctx }) => { | ||
run: async (payload: AlchemyWebhookEvent) => { | ||
try { | ||
logger.log('Address activity', { payload, ctx }) | ||
const activity: AlchemyActivity = payload.event.activity[0] | ||
console.log(activity) | ||
} catch (error) { | ||
logger.error('Error processing address activity', { | ||
error: getErrorMessage(error), | ||
error: (error as Error).message, | ||
}) | ||
throw error | ||
} | ||
}, | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters