generated from defi-wonderland/ts-turborepo-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
128 additions
and
4 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
28 changes: 28 additions & 0 deletions
28
packages/data-flow/src/data-loader/handlers/applicationPayout.handlers.ts
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,28 @@ | ||
import { | ||
ApplicationPayoutChangeset, | ||
IApplicationPayoutRepository, | ||
} from "@grants-stack-indexer/repository"; | ||
|
||
import { ChangesetHandler } from "../types/index.js"; | ||
|
||
/** | ||
* Collection of handlers for application-related operations. | ||
* Each handler corresponds to a specific Application changeset type. | ||
*/ | ||
export type ApplicationPayoutHandlers = { | ||
[K in ApplicationPayoutChangeset["type"]]: ChangesetHandler<K>; | ||
}; | ||
|
||
/** | ||
* Creates handlers for managing application-related operations. | ||
* | ||
* @param repository - The application repository instance used for database operations | ||
* @returns An object containing all application-related handlers | ||
*/ | ||
export const createApplicationPayoutHandlers = ( | ||
repository: IApplicationPayoutRepository, | ||
): ApplicationPayoutHandlers => ({ | ||
InsertApplicationPayout: (async (changeset): Promise<void> => { | ||
await repository.insertApplicationPayout(changeset.args.applicationPayout); | ||
}) satisfies ChangesetHandler<"InsertApplicationPayout">, | ||
}); |
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
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
10 changes: 10 additions & 0 deletions
10
packages/repository/src/interfaces/applicationPayoutRepository.interface.ts
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,10 @@ | ||
import { NewApplicationPayout } from "../types/applicationPayout.types.js"; | ||
|
||
export interface IApplicationPayoutRepository { | ||
/** | ||
* Inserts a new application payout into the database. | ||
* @param applicationPayout - The new application payout to insert. | ||
* @returns A promise that resolves when the application payout is inserted. | ||
*/ | ||
insertApplicationPayout(applicationPayout: NewApplicationPayout): Promise<void>; | ||
} |
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
19 changes: 19 additions & 0 deletions
19
packages/repository/src/repositories/kysely/applicationPayout.repository.ts
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,19 @@ | ||
import { Kysely } from "kysely"; | ||
|
||
import { Database, IApplicationPayoutRepository, NewApplicationPayout } from "../../internal.js"; | ||
|
||
export class KyselyApplicationPayoutRepository implements IApplicationPayoutRepository { | ||
constructor( | ||
private readonly db: Kysely<Database>, | ||
private readonly schemaName: string, | ||
) {} | ||
|
||
/** @inheritdoc */ | ||
async insertApplicationPayout(applicationPayout: NewApplicationPayout): Promise<void> { | ||
await this.db | ||
.withSchema(this.schemaName) | ||
.insertInto("applicationsPayouts") | ||
.values(applicationPayout) | ||
.execute(); | ||
} | ||
} |
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,17 @@ | ||
import { Address, ChainId, Hex } from "@grants-stack-indexer/shared"; | ||
|
||
export type ApplicationPayout = { | ||
id: number; | ||
chainId: ChainId; | ||
roundId: string; | ||
applicationId: string; | ||
amount: bigint; | ||
tokenAddress: Address; | ||
amountInUsd: string; | ||
amountInRoundMatchToken: bigint; | ||
transactionHash: Hex; | ||
sender: Address; | ||
timestamp: Date | null; | ||
}; | ||
|
||
export type NewApplicationPayout = Omit<ApplicationPayout, "id">; |
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