-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PRO-2501-Arka_Contract_Events_Whitelist (#123)
* added contract whitelist for etherspot prime and modular sdk * updated package version * changed parameter and API route path names
- Loading branch information
1 parent
881c856
commit 9a796de
Showing
17 changed files
with
564 additions
and
26 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
52 changes: 52 additions & 0 deletions
52
backend/migrations/2024080800001-create-contract-whitelist.cjs
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,52 @@ | ||
const { Sequelize } = require('sequelize') | ||
|
||
async function up({ context: queryInterface }) { | ||
await queryInterface.createTable('contract_whitelist', { | ||
ID: { | ||
type: Sequelize.INTEGER, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
allowNull: false | ||
}, | ||
WALLET_ADDRESS: { | ||
type: Sequelize.TEXT, | ||
allowNull: false, | ||
}, | ||
CONTRACT_ADDRESS: { | ||
type: Sequelize.TEXT, | ||
allowNull: false, | ||
}, | ||
FUNCTION_SELECTORS: { | ||
type: Sequelize.ARRAY(Sequelize.TEXT), | ||
allowNull: false, | ||
}, | ||
ABI: { | ||
type: Sequelize.TEXT, | ||
allowNull: false, | ||
}, | ||
CHAIN_ID: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
}, | ||
CREATED_AT: { | ||
type: Sequelize.DATE, | ||
allowNull: false, | ||
defaultValue: Sequelize.NOW | ||
}, | ||
UPDATED_AT: { | ||
type: Sequelize.DATE, | ||
allowNull: false, | ||
defaultValue: Sequelize.NOW | ||
} | ||
}, { | ||
schema: process.env.DATABASE_SCHEMA_NAME | ||
}); | ||
} | ||
async function down({ context: queryInterface }) { | ||
await queryInterface.dropTable({ | ||
tableName: 'contract_whitelist', | ||
schema: process.env.DATABASE_SCHEMA_NAME | ||
}) | ||
} | ||
|
||
module.exports = { up, down } |
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,11 @@ | ||
require('dotenv').config(); | ||
|
||
async function up({ context: queryInterface }) { | ||
await queryInterface.sequelize.query(`ALTER TABLE IF EXISTS "${process.env.DATABASE_SCHEMA_NAME}".api_keys ADD COLUMN "CONTRACT_WHITELIST_MODE" text default false`); | ||
} | ||
|
||
async function down({ context: queryInterface }) { | ||
await queryInterface.sequelize.query(`ALTER TABLE "${process.env.DATABASE_SCHEMA_NAME}".api_keys DROP COLUMN CONTRACT_WHITELIST_MODE;`); | ||
} | ||
|
||
module.exports = { up, down } |
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,71 @@ | ||
import { Sequelize, DataTypes, Model } from 'sequelize'; | ||
|
||
export class ContractWhitelist extends Model { | ||
public id!: number; | ||
public walletAddress!: string; | ||
public contractAddress!: string; | ||
public functionSelectors!: string[]; | ||
public abi!: string; | ||
public chainId!: number; | ||
public createdAt!: Date; | ||
public updatedAt!: Date; | ||
} | ||
|
||
export function initializeContractWhitelistModel(sequelize: Sequelize, schema: string) { | ||
const initializedContractWhitelistModel = ContractWhitelist.init({ | ||
id: { | ||
type: DataTypes.INTEGER, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
field: 'ID' | ||
}, | ||
walletAddress: { | ||
type: DataTypes.TEXT, | ||
allowNull: false, | ||
field: 'WALLET_ADDRESS' | ||
}, | ||
contractAddress: { | ||
type: DataTypes.TEXT, | ||
allowNull: false, | ||
field: 'CONTRACT_ADDRESS' | ||
}, | ||
functionSelectors: { | ||
type: DataTypes.ARRAY(DataTypes.TEXT), | ||
allowNull: false, | ||
field: 'FUNCTION_SELECTORS' | ||
}, | ||
abi: { | ||
type: DataTypes.TEXT, | ||
allowNull: false, | ||
field: 'ABI' | ||
}, | ||
chainId: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
field: 'CHAIN_ID' | ||
}, | ||
createdAt: { | ||
type: DataTypes.DATE, | ||
allowNull: false, | ||
field: 'CREATED_AT', | ||
defaultValue: DataTypes.NOW, | ||
}, | ||
updatedAt: { | ||
type: DataTypes.DATE, | ||
allowNull: false, | ||
field: 'UPDATED_AT', | ||
defaultValue: DataTypes.NOW, | ||
}, | ||
}, { | ||
tableName: 'contract_whitelist', | ||
sequelize, // passing the `sequelize` instance is required | ||
modelName: '', | ||
timestamps: true, // enabling timestamps | ||
createdAt: 'createdAt', // mapping 'createdAt' to 'CREATED_AT' | ||
updatedAt: 'updatedAt', // mapping 'updatedAt' to 'UPDATED_AT' | ||
freezeTableName: true, | ||
schema: schema, | ||
}); | ||
|
||
return initializedContractWhitelistModel; | ||
} |
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.