Skip to content

Commit

Permalink
fix migration file for multisigSession
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosQ96 committed Sep 23, 2023
1 parent ba439c5 commit d6bba57
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 79 deletions.
106 changes: 59 additions & 47 deletions migrations/1695476070385-UpdateMultisigSessionEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,68 +10,80 @@ export class UpdateMultisigSessionEntity1695476070385
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
const table = await queryRunner.getTable('multisig_session');
if (!table) return;

// Adding new columns
await queryRunner.addColumn(
'multisig_session',
new TableColumn({
name: 'messageHash',
type: 'varchar',
isNullable: false,
}),
);
await queryRunner.addColumn(
'multisig_session',
new TableColumn({
name: 'status',
type: 'varchar',
isNullable: true,
}),
);
const statusColumnExists = table.columns.some(c => c.name === 'status');
if (!statusColumnExists) {
await queryRunner.addColumn(
'multisig_session',
new TableColumn({
name: 'status',
type: 'varchar',
isNullable: true,
}),
);
}

// Renaming column safeTransactionMessage to safeMessageHash
await queryRunner.renameColumn(
'multisig_session',
'safeTransactionMessage',
'safeMessageHash',
const safeTransactionMessageColumnExists = table.columns.some(
c => c.name === 'safeTransactionMessage',
);
if (safeTransactionMessageColumnExists) {
await queryRunner.renameColumn(
'multisig_session',
'safeTransactionMessage',
'safeMessageHash',
);
}

// Creating indices for messageHash and safeMessageHash
await queryRunner.createIndex(
'multisig_session',
new TableIndex({
name: 'IDX_MULTISIG_MESSAGE_HASH',
columnNames: ['messageHash'],
}),
);
await queryRunner.createIndex(
'multisig_session',
new TableIndex({
name: 'IDX_MULTISIG_SAFE_MESSAGE_HASH',
columnNames: ['safeMessageHash'],
}),
// Creating indices for safeMessageHash
const safeMessageHashIndexExists = table.indices.some(
idx => idx.columnNames.indexOf('safeMessageHash') !== -1,
);
if (!safeMessageHashIndexExists) {
await queryRunner.createIndex(
'multisig_session',
new TableIndex({
name: 'IDX_MULTISIG_SAFE_MESSAGE_HASH',
columnNames: ['safeMessageHash'],
}),
);
}
}

public async down(queryRunner: QueryRunner): Promise<void> {
const table = await queryRunner.getTable('multisig_session');
if (!table) return;

// Dropping indices for messageHash and safeMessageHash
await queryRunner.dropIndex(
'multisig_session',
'IDX_MULTISIG_MESSAGE_HASH',
);
await queryRunner.dropIndex(
'multisig_session',
'IDX_MULTISIG_SAFE_MESSAGE_HASH',
const safeMessageHashIndexExists = table.indices.some(
idx => idx.columnNames.indexOf('safeMessageHash') !== -1,
);
if (safeMessageHashIndexExists) {
await queryRunner.dropIndex(
'multisig_session',
'IDX_MULTISIG_SAFE_MESSAGE_HASH',
);
}

// Renaming column back to safeTransactionMessage
await queryRunner.renameColumn(
'multisig_session',
'safeMessageHash',
'safeTransactionMessage',
const safeMessageHashColumnExists = table.columns.some(
c => c.name === 'safeMessageHash',
);
if (safeMessageHashColumnExists) {
await queryRunner.renameColumn(
'multisig_session',
'safeMessageHash',
'safeTransactionMessage',
);
}

// Dropping the added columns
await queryRunner.dropColumn('multisig_session', 'isSuccessful');
await queryRunner.dropColumn('multisig_session', 'messageHash');
const statusColumnExists = table.columns.some(c => c.name === 'status');
if (statusColumnExists) {
await queryRunner.dropColumn('multisig_session', 'status');
}
}
}
4 changes: 0 additions & 4 deletions src/entities/multisigSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ export class MultisigSession extends BaseEntity {
@Column({ nullable: false })
safeMessageHash: string;

@Index()
@Column({ nullable: false })
messageHash: string;

@Index()
@Column({ nullable: false })
safeTransactionHash: string;
Expand Down
28 changes: 0 additions & 28 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,34 +61,6 @@ export const initServer = async () => {
app.use(express.static('public'));
app.use(bodyParser.json());
app.use(adminJsRootPath, await getAdminBroRouter());

const provider = getProvider(100);

const ethAdapter = new EthersAdapter({
ethers,
signerOrProvider: provider,
});

const safeService = new SafeApiKit({
txServiceUrl: getSafeTransactionNetworkUrl(100),
ethAdapter,
});

const safeMultisigTransactionResponse = await safeService.getTransaction(
'0x859d6268bb7bc3f99b2a0236b388d0e7e577889fdf1a1c68461489bf665dcae5',
);

const safeInfo = await safeService.getSafeInfo(
safeMultisigTransactionResponse.safe,
);
const safeCreationInfo = await safeService.getSafeCreationInfo(
safeMultisigTransactionResponse.safe,
);

// const pendingTxs = await safeService.getPendingTransactions(
// '0xF60382eE734c8C82bfA8f5973Cffd5fD808d9189'
// );
console.log(safeCreationInfo);
app.use(v1Router);
app.use(
'/docs',
Expand Down

0 comments on commit d6bba57

Please sign in to comment.