Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions backend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Server Configuration
PORT=3000
NODE_ENV=development

# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=vesting_vault
DB_USER=postgres
DB_PASSWORD=1234

# JWT Configuration (if needed)
JWT_SECRET=your-super-secret-jwt-key-here

# External Services (if needed)
# BLOCKCHAIN_RPC_URL=https://mainnet.infura.io/v3/YOUR_PROJECT_ID
# ETHEREUM_PRIVATE_KEY=your-private-key-here

# Discord Bot Configuration
DISCORD_BOT_TOKEN=your-discord-bot-token-here
DISCORD_CHANNEL_ID=your-discord-channel-id-here

# Redis Configuration
REDIS_URL=redis://localhost:6379

# Slack Webhook Configuration
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
2 changes: 1 addition & 1 deletion backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DB_HOST=localhost
DB_PORT=5432
DB_NAME=vesting_vault
DB_USER=postgres
DB_PASSWORD=password
DB_PASSWORD=1234

# JWT Configuration (if needed)
JWT_SECRET=your-super-secret-jwt-key-here
Expand Down
Empty file added backend/nano
Empty file.
7 changes: 1 addition & 6 deletions backend/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const express = require('express');
const { ClaimGateway } = require('./websocket/claim.gateway');
const { RedisIoAdapter } = require('./websocket/redis.adapter');
const cors = require('cors');
const dotenv = require('dotenv');
const http = require('http');
Expand Down Expand Up @@ -326,10 +324,7 @@ const startServer = async () => {
if (graphQLServer) {
console.log(`GraphQL API available at: http://localhost:${PORT}/graphql`);
}
// Initialize WebSocket Gateway with Redis adapter
const redisIoAdapter = new RedisIoAdapter(httpServer);
const claimGateway = new ClaimGateway();
claimGateway.server = redisIoAdapter.createIOServer(PORT, { transports: ['websocket'] });

});
} catch (error) {
console.error('Unable to start server:', error);
Expand Down
6 changes: 0 additions & 6 deletions backend/src/models/subSchedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ const SubSchedule = sequelize.define('SubSchedule', {
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',

},
top_up_amount: {
type: DataTypes.DECIMAL(36, 18),
allowNull: false,
comment: 'Amount of tokens added in this top-up',
},

},
created_at: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
Expand All @@ -42,9 +39,6 @@ const SubSchedule = sequelize.define('SubSchedule', {
{
fields: ['vault_id'],
},
{

},
],
});

Expand Down
39 changes: 39 additions & 0 deletions backend/src/routes/token.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const express = require('express');
const router = express.Router();
const db = require('../db'); // adjust if your db import is different

// GET /api/token/:address/supply
router.get('/:address/supply', async (req, res) => {
try {
const tokenAddress = req.params.address.toLowerCase();

// 1. Get total minted (from db or a model)
const totalMintedResult = await db.query(
'SELECT SUM(amount) AS total_minted FROM tokens WHERE address = $1',
[tokenAddress]
);
const totalMinted = totalMintedResult.rows[0]?.total_minted || 0;

// 2. Sum unvested balances
const unvestedResult = await db.query(
'SELECT SUM(unvested_balance) AS total_unvested FROM vesting_vaults WHERE token_address = $1 AND active = true',
[tokenAddress]
);
const totalUnvested = unvestedResult.rows[0]?.total_unvested || 0;

// 3. Calculate circulating
const circulatingSupply = totalMinted - totalUnvested;

return res.json({
token: tokenAddress,
circulatingSupply,
totalMinted,
totalUnvested
});
} catch (err) {
console.error(err);
res.status(500).json({ error: 'Internal Server Error' });
}
});

module.exports = router;
30 changes: 6 additions & 24 deletions backend/src/services/vestingService.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,16 @@
class VestingService {

throw error;
}
}


throw error;
}
}


throw error;
}
}


throw error;
}
}


});

async exampleFunction() {
try {
return {
success: true,

message: "Vesting service is working"
};
} catch (error) {
throw error;
}
}


}

module.exports = new VestingService();