Skip to content

Commit

Permalink
fix: bug fix and removed commented blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
xianglupeng authored and joonaun93 committed Sep 16, 2023
1 parent 1320bf3 commit 1074b69
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
4 changes: 4 additions & 0 deletions server/models/Transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ class Transfer {
} else {
log.debug('transfer tokens');
const tokens = await this._token.getTokensByPendingTransferId(transferId);
// expect(transfer).match({
// source_wallet_id: expect.any(String),
// });

Joi.assert(
transfer,
Joi.object({
Expand Down
4 changes: 4 additions & 0 deletions server/models/Trust.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,10 @@ class Trust {
* target wallet
*/
async hasTrust(walletLoginId, trustType, senderWallet, receiveWallet) {
// expect(trustType).oneOf(
// Object.keys(TrustRelationshipEnums.ENTITY_TRUST_REQUEST_TYPE),
// );

Joi.assert(
trustType,
Joi.string().valid(
Expand Down
6 changes: 6 additions & 0 deletions server/repositories/BaseRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ class BaseRepository {
.count()
.table(this._tableName)
.where(filter);
// expect(result).match([
// {
// count: expect.any(String),
// },
// ]);

Joi.assert(
result,
Expand Down Expand Up @@ -156,6 +161,7 @@ class BaseRepository {
.getDB()
.batchInsert(this._tableName, objects)
.returning('id');
// expect(result).match([expect.any(String)]);
Joi.assert(result, Joi.array().items(Joi.string()));
return result;
}
Expand Down
21 changes: 1 addition & 20 deletions server/repositories/TokenRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,6 @@ class TokenRepository extends BaseRepository {
this._session = session;
}

// async getById(id) {
// const result = await this._session
// .getDB()(this._tableName)
// .where('id', id)
// .first();
// expect(
// result,
// () => new HttpError(404, `can not found token by id:${id}`),
// ).match({
// id: expect.any(String),
// });
// return result;
// }

async getById(id) {
Joi.assert(id, Joi.string().uuid());

Expand All @@ -31,12 +17,7 @@ class TokenRepository extends BaseRepository {
.where('id', id)
.first();

try {
Joi.assert(
result,
Joi.object({ id: Joi.string().required() }).unknown().required(),
);
} catch (error) {
if (!result) {
throw new HttpError(404, `can not found token by id:${id}`);
}

Expand Down
4 changes: 4 additions & 0 deletions server/repositories/TransferRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class TransferRepository extends BaseRepository {
'destination_wallet.id',
);

// expect(result[0]).match({
// id: expect.anything(),
// });

Joi.assert(
result[0],
Joi.object({
Expand Down

0 comments on commit 1074b69

Please sign in to comment.