diff --git a/src/server/adminJs/tabs/tokenTab.ts b/src/server/adminJs/tabs/tokenTab.ts index 90f2050a4..e35bb91d9 100644 --- a/src/server/adminJs/tabs/tokenTab.ts +++ b/src/server/adminJs/tabs/tokenTab.ts @@ -130,6 +130,43 @@ export const createToken = async ( organizations, } = request.payload; try { + if (!address || !decimals || !name || !networkId || !symbol) { + message = 'Please fill all required fields'; + type = 'danger'; + return { + notice: { + message, + type, + }, + }; + } + const duplicateAddress = await Token.createQueryBuilder('token') + .where('LOWER(token.address) = LOWER(:address)', { address }) + .andWhere('token.networkId = :networkId', { + networkId: Number(networkId), + }) + .getOne(); + + const duplicateSymbol = await Token.createQueryBuilder('token') + .where('LOWER(token.symbol) = LOWER(:symbol)', { symbol }) + .andWhere('token.networkId = :networkId', { + networkId: Number(networkId), + }) + .getOne(); + + if (duplicateSymbol || duplicateAddress) { + message = `Token ${ + duplicateAddress ? 'address' : 'symbol' + } already exists!`; + type = 'danger'; + return { + record: {}, + notice: { + message, + type, + }, + }; + } newToken = Token.create({ name, symbol,