diff --git a/migration/1722549878186-addAdminAddressHistoryToProject.ts b/migration/1722549878186-addAdminAddressHistoryToProject.ts new file mode 100644 index 000000000..53c5224ba --- /dev/null +++ b/migration/1722549878186-addAdminAddressHistoryToProject.ts @@ -0,0 +1,21 @@ +import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'; + +export class AddAdminAddressHistoryToProject1722549878186 + implements MigrationInterface +{ + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.addColumn( + 'project', + new TableColumn({ + name: 'adminAddressHistory', + type: 'text', + isArray: true, + isNullable: true, + }), + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.dropColumn('project', 'adminAddressHistory'); + } +} diff --git a/src/entities/project.ts b/src/entities/project.ts index 83adb224c..215ec0047 100644 --- a/src/entities/project.ts +++ b/src/entities/project.ts @@ -439,6 +439,10 @@ export class Project extends BaseEntity { @Field(_type => [Campaign], { nullable: true }) campaigns: Campaign[]; + @Field(_type => [String], { nullable: true }) + @Column('text', { array: true, nullable: true }) + adminAddressHistory: string[]; + // only projects with status active can be listed automatically static pendingReviewSince(maximumDaysForListing: number) { const maxDaysForListing = moment() diff --git a/src/server/adminJs/tabs/projectsTab.ts b/src/server/adminJs/tabs/projectsTab.ts index d0cf6fbe2..11dca8670 100644 --- a/src/server/adminJs/tabs/projectsTab.ts +++ b/src/server/adminJs/tabs/projectsTab.ts @@ -715,6 +715,17 @@ export const projectsTab = { }, position: 1, }, + adminAddressHistory: { + type: 'string[]', + isVisible: { + list: false, + filter: false, + show: true, + edit: false, + new: false, + }, + position: 2, + }, contacts: { isVisible: { list: false, @@ -1030,6 +1041,14 @@ export const projectsTab = { const adminUser = await User.findOne({ where: { id: request?.record?.params?.newAdminId }, }); + const previousAdminAddress = project.adminUser.walletAddress; + if (previousAdminAddress) { + if (project.adminAddressHistory) { + project.adminAddressHistory.push(previousAdminAddress); + } else { + project.adminAddressHistory = [previousAdminAddress]; + } + } project.adminUser = adminUser!; await project.save(); }