diff --git a/data/migrations/1698968851768-update-invocation-table.ts b/data/migrations/1698968851768-update-invocation-table.ts new file mode 100644 index 00000000..6786c3e2 --- /dev/null +++ b/data/migrations/1698968851768-update-invocation-table.ts @@ -0,0 +1,23 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class UpdateInvocationTable1698968851768 implements MigrationInterface { + name = 'UpdateInvocationTable1698968851768'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE \`invocation\` DROP FOREIGN KEY \`FK_7476022a2c5bec2a3a499979e95\``, + ); + await queryRunner.query( + `ALTER TABLE \`invocation\` ADD CONSTRAINT \`FK_7476022a2c5bec2a3a499979e95\` FOREIGN KEY (\`selected_method_id\`) REFERENCES \`method\`(\`id\`) ON DELETE SET NULL ON UPDATE CASCADE`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE \`invocation\` DROP FOREIGN KEY \`FK_7476022a2c5bec2a3a499979e95\``, + ); + await queryRunner.query( + `ALTER TABLE \`invocation\` ADD CONSTRAINT \`FK_7476022a2c5bec2a3a499979e95\` FOREIGN KEY (\`selected_method_id\`) REFERENCES \`method\`(\`id\`) ON DELETE SET NULL ON UPDATE NO ACTION`, + ); + } +} diff --git a/src/common/application/service/stellar.service.ts b/src/common/application/service/stellar.service.ts index 7f398247..7df920dd 100644 --- a/src/common/application/service/stellar.service.ts +++ b/src/common/application/service/stellar.service.ts @@ -265,8 +265,18 @@ export class StellarService implements IContractService { newresponse = await this.server.getTransaction(response.hash); await new Promise((resolve) => setTimeout(resolve, 1000)); } - - return JSON.stringify(newresponse); + return JSON.stringify( + newresponse.status === 'SUCCESS' + ? { + method: selectedMethod, + response: newresponse.returnValue.value(), + status: newresponse.status, + } + : { + status: 'FAILED', + method: selectedMethod, + }, + ); } catch (e) { console.log(e); return e; diff --git a/src/modules/invocation/infrastructure/persistence/invocation.schema.ts b/src/modules/invocation/infrastructure/persistence/invocation.schema.ts index c25e89fc..e3e916c5 100644 --- a/src/modules/invocation/infrastructure/persistence/invocation.schema.ts +++ b/src/modules/invocation/infrastructure/persistence/invocation.schema.ts @@ -68,6 +68,7 @@ export const InvocationSchema = new EntitySchema({ }, onDelete: 'SET NULL', nullable: true, + onUpdate: 'CASCADE', }, }, });