-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10344 from hicommonwealth/tim/referral-ce
- Loading branch information
Showing
45 changed files
with
763 additions
and
514 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# EVM Chain Events | ||
|
||
There are 2 methods of adding chain events sources. Parent contracts are contracts that we (Common) deploy and child | ||
contracts are contracts deployed by users (e.g. Single Contests). Parent contract addresses are stable (almost never | ||
change) and are therefore hardcoded in `chainConfig.ts`. On the other hand, we cannot know the address of a child | ||
contract ahead of time since it is deployed at runtime. For this reason, child contract sources are stored in the | ||
EvmEventSources table with a reference to the parent contract in the EventRegistry. | ||
|
||
These instructions only describe how to ensure events are picked it up by EVM CE _not_ how these events are processed. | ||
|
||
## Adding Parent Contract Events | ||
1. Add the contract address in the `factoryContracts` object in `chainConfig.ts`. | ||
2. Add the relevant event signatures in `eventSignatures.ts`. | ||
3. Update the `EventRegistry` object in `eventRegistry.ts` to reference the new contract/event. | ||
|
||
## Adding Child Contract Events | ||
1. Add the relevant event signatures in `eventSignatures.ts`. | ||
2. Update the `EventRegistry` object in `eventRegistry.ts` to reference the new events. | ||
3. Ensure that the parent events pertaining to child contract launches create sources in the `EvmEventSources` table. |
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
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,49 @@ | ||
import * as schemas from '@hicommonwealth/schemas'; | ||
import Sequelize from 'sequelize'; | ||
import { z } from 'zod'; | ||
import type { ModelInstance } from './types'; | ||
|
||
export type ReferralFeesAttributes = z.infer<typeof schemas.ReferralFees>; | ||
export type ReferralFeesInstance = ModelInstance<ReferralFeesAttributes>; | ||
|
||
export const ReferralFee = ( | ||
sequelize: Sequelize.Sequelize, | ||
): Sequelize.ModelStatic<ReferralFeesInstance> => | ||
sequelize.define<ReferralFeesInstance>( | ||
'ReferralFee', | ||
{ | ||
eth_chain_id: { | ||
type: Sequelize.INTEGER, | ||
primaryKey: true, | ||
}, | ||
transaction_hash: { | ||
type: Sequelize.STRING, | ||
primaryKey: true, | ||
}, | ||
namespace_address: { | ||
type: Sequelize.STRING, | ||
allowNull: false, | ||
}, | ||
distributed_token_address: { | ||
type: Sequelize.STRING, | ||
allowNull: false, | ||
}, | ||
referrer_recipient_address: { | ||
type: Sequelize.STRING, | ||
allowNull: false, | ||
}, | ||
referrer_received_amount: { | ||
type: Sequelize.FLOAT, | ||
allowNull: false, | ||
}, | ||
transaction_timestamp: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
}, | ||
}, | ||
{ | ||
timestamps: false, | ||
underscored: true, | ||
tableName: 'ReferralFees', | ||
}, | ||
); |
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
Oops, something went wrong.