Skip to content

Commit

Permalink
Feat/update invocation service (#40)
Browse files Browse the repository at this point in the history
## Summary

Add response to the contract service.

Add new migrations

---------

Co-authored-by: Ivan Tammaro <[email protected]>
  • Loading branch information
leotammaro and tammaroivan authored Nov 3, 2023
1 parent af6aa19 commit 1baa7ae
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
23 changes: 23 additions & 0 deletions data/migrations/1698968851768-update-invocation-table.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class UpdateInvocationTable1698968851768 implements MigrationInterface {
name = 'UpdateInvocationTable1698968851768';

public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
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`,
);
}
}
14 changes: 12 additions & 2 deletions src/common/application/service/stellar.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const InvocationSchema = new EntitySchema<Invocation>({
},
onDelete: 'SET NULL',
nullable: true,
onUpdate: 'CASCADE',
},
},
});

0 comments on commit 1baa7ae

Please sign in to comment.