Skip to content

Commit

Permalink
Merge branch 'release/0.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
taha-abbasi committed Mar 30, 2023
2 parents 8967e2a + 5795774 commit 52a7e69
Show file tree
Hide file tree
Showing 11 changed files with 246 additions and 236 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ export const getNetworkConfigurations = async () => {

export const nonCirculatingSupplyAddressesConfig = [
{
Name: "Deployer",
Address: "0xc2fdcb728170192c72ada2c08957f2e9390076b7",
TokenContractAddress: "0xe5caef4af8780e59df925470b050fb23c43ca68c",
JsonRpcUrl: "https://nd-770-685-838.p2pify.com/e30d3ea257d1588823179ce4d5811a61",
ChainId: "1"
name: "Deployer",
address: "0xc2fdcb728170192c72ada2c08957f2e9390076b7",
tokenContractAddress: "0xe5caef4af8780e59df925470b050fb23c43ca68c",
jsonRpcUrl: "https://nd-770-685-838.p2pify.com/e30d3ea257d1588823179ce4d5811a61",
chainId: "1"
},
// Add more addresses here...
];
Expand Down
116 changes: 61 additions & 55 deletions build/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.nonCirculatingSupplyAddressesConfig = exports.getNetworkConfigurations = exports.chainIdToNetworkMap = void 0;
exports.getNonCirculatingSupplyAddressConfigurations = exports.getNetworkConfigurations = exports.chainIdToNetworkMap = void 0;
// src/config.ts
const node_fetch_1 = __importDefault(require("node-fetch"));
const API_URL = 'https://api-leaderboard.dev.svcs.ferrumnetwork.io/api/v1/currencies/token/data';
const tokenContractAddress = "0xa719b8ab7ea7af0ddb4358719a34631bb79d15dc";
const chainId = 56;
Expand Down Expand Up @@ -38,92 +43,93 @@ exports.chainIdToNetworkMap = {
function getNetworkConfigurations() {
return __awaiter(this, void 0, void 0, function* () {
const url = `${API_URL}?tokenContractAddress=${tokenContractAddress}&chainId=${chainId}&offset=0`;
const response = yield fetch(url);
const response = yield (0, node_fetch_1.default)(url);
const data = yield response.json();
const networks = {};
for (const item of data.body.currencyAddressesByNetworks) {
const network = exports.chainIdToNetworkMap[item.network.chainId];
if (network) {
networks[network.name] = {
jsonRpcUrl: network.jsonRpcUrl,
tokenContractAddress: item.tokenContractAddress
tokenContractAddress: item.tokenContractAddress,
chainId: item.network.chainId
};
}
}
return networks;
});
}
exports.getNetworkConfigurations = getNetworkConfigurations;
const nonCirculatingSupplyAddressesConfig = [
const nonCirculatingSupplyAddressesConfigInput = [
{
Name: "Deployer",
Address: "0xc2fdcb728170192c72ada2c08957f2e9390076b7",
TokenContractAddress: "0xe5caef4af8780e59df925470b050fb23c43ca68c",
JsonRpcUrl: "https://nd-770-685-838.p2pify.com/e30d3ea257d1588823179ce4d5811a61",
ChainId: "1"
name: "Deployer",
address: "0xc2fdcb728170192c72ada2c08957f2e9390076b7",
chainId: "1"
},
{
Name: "Treasury",
Address: "0x517873ca1edaaa0f6403a0dab2cb0162433de9d1",
TokenContractAddress: "0xa719b8ab7ea7af0ddb4358719a34631bb79d15dc",
JsonRpcUrl: "https://nd-605-906-592.p2pify.com/df9065025f5e18317e708040b1f2ab13",
ChainId: "56"
name: "Treasury",
address: "0x517873ca1edaaa0f6403a0dab2cb0162433de9d1",
chainId: "56"
},
{
Name: "Deployer",
Address: "0xc2fdcb728170192c72ada2c08957f2e9390076b7",
TokenContractAddress: "0xd99bafe5031cc8b345cb2e8c80135991f12d7130",
JsonRpcUrl: "https://nd-662-671-431.p2pify.com/72aea5a70bbd5482f9a498540072b1e1",
ChainId: "137"
name: "Deployer",
address: "0xc2fdcb728170192c72ada2c08957f2e9390076b7",
chainId: "137"
},
{
Name: "Deployer",
Address: "0xc2fdcb728170192c72ada2c08957f2e9390076b7",
TokenContractAddress: "0xe5caef4af8780e59df925470b050fb23c43ca68c",
JsonRpcUrl: "https://nd-900-134-973.p2pify.com/0a4e07e77ebc245f0bf7839745b4803b/ext/bc/C/rpc",
ChainId: "43114"
name: "Deployer",
address: "0xc2fdcb728170192c72ada2c08957f2e9390076b7",
chainId: "43114"
},
// {
// Name: "Deployer",
// Address: "bnb1um8ntkgwle8yrdk0yn5hwdf7hckjpyjjg29k2p",
// TokenContractAddress: "FRM-DE7",
// JsonRpcUrl: "https://dex.binance.org",
// ChainId: "bnbBeaconChain"
// name: "Deployer",
// address: "bnb1um8ntkgwle8yrdk0yn5hwdf7hckjpyjjg29k2p",
// chainId: "bnbBeaconChain"
// },
{
Name: "Treasury",
Address: "0xe42b80dA58ccEAbe0A6ECe8e3311AE939Ef6b96c",
TokenContractAddress: "0x9f6abbf0ba6b5bfa27f4deb6597cc6ec20573fda",
JsonRpcUrl: "https://nd-674-145-610.p2pify.com/bc9acaa6f1386224186fb1e794c40c14",
ChainId: "42161"
name: "Treasury",
address: "0xe42b80dA58ccEAbe0A6ECe8e3311AE939Ef6b96c",
chainId: "42161"
},
{
Name: "Bridge Pool",
Address: "0x8e01cc26d6dd73581347c4370573ce9e59e74802",
TokenContractAddress: "0xe5caef4af8780e59df925470b050fb23c43ca68c",
JsonRpcUrl: "https://nd-770-685-838.p2pify.com/e30d3ea257d1588823179ce4d5811a61",
ChainId: "1"
name: "Bridge Pool",
address: "0x8e01cc26d6dd73581347c4370573ce9e59e74802",
chainId: "1"
},
{
Name: "Bridge Pool",
Address: "0x8e01cc26d6dd73581347c4370573ce9e59e74802",
TokenContractAddress: "0xa719b8ab7ea7af0ddb4358719a34631bb79d15dc",
JsonRpcUrl: "https://nd-605-906-592.p2pify.com/df9065025f5e18317e708040b1f2ab13",
ChainId: "56"
name: "Bridge Pool",
address: "0x8e01cc26d6dd73581347c4370573ce9e59e74802",
chainId: "56"
},
{
Name: "Bridge Pool",
Address: "0x8e01cc26d6dd73581347c4370573ce9e59e74802",
TokenContractAddress: "0xd99bafe5031cc8b345cb2e8c80135991f12d7130",
JsonRpcUrl: "https://nd-662-671-431.p2pify.com/72aea5a70bbd5482f9a498540072b1e1",
ChainId: "137"
name: "Bridge Pool",
address: "0x8e01cc26d6dd73581347c4370573ce9e59e74802",
chainId: "137"
},
{
Name: "Bridge Pool",
Address: "0x8e01cc26d6dd73581347c4370573ce9e59e74802",
TokenContractAddress: "0xe5caef4af8780e59df925470b050fb23c43ca68c",
JsonRpcUrl: "https://nd-900-134-973.p2pify.com/0a4e07e77ebc245f0bf7839745b4803b/ext/bc/C/rpc",
ChainId: "43114"
name: "Bridge Pool",
address: "0x8e01cc26d6dd73581347c4370573ce9e59e74802",
chainId: "43114"
}
];
exports.nonCirculatingSupplyAddressesConfig = nonCirculatingSupplyAddressesConfig;
function getNonCirculatingSupplyAddressConfigurations() {
return __awaiter(this, void 0, void 0, function* () {
const url = `${API_URL}?tokenContractAddress=${tokenContractAddress}&chainId=${chainId}&offset=0`;
const response = yield (0, node_fetch_1.default)(url);
const data = yield response.json();
const nonCirculatingSupplyAddresses = [];
for (const item of nonCirculatingSupplyAddressesConfigInput) {
const network = exports.chainIdToNetworkMap[item.chainId];
let networkItemFromGatewayConfig = data.body.currencyAddressesByNetworks.find(i => i.network.chainId === item.chainId);
nonCirculatingSupplyAddresses.push({
name: item.name,
address: item.address,
tokenContractAddress: networkItemFromGatewayConfig === null || networkItemFromGatewayConfig === void 0 ? void 0 : networkItemFromGatewayConfig.tokenContractAddress,
jsonRpcUrl: network.jsonRpcUrl,
chainId: item.chainId
});
}
return nonCirculatingSupplyAddresses;
});
}
exports.getNonCirculatingSupplyAddressConfigurations = getNonCirculatingSupplyAddressConfigurations;
26 changes: 13 additions & 13 deletions build/getSupplyAcrossNetworks.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@ const web3_1 = __importDefault(require("web3"));
const config_1 = require("./config");
const utils_1 = require("./utils");
// export interface NonCirculatingSupplyBalance {
// ChainId: string;
// Address: string;
// TokenContractAddress: string;
// Name: string;
// chainId: string;
// address: string;
// tokenContractAddress: string;
// name: string;
// balance: BigNumber;
// }
function getNonCirculatingSupplyBalances() {
return __awaiter(this, void 0, void 0, function* () {
const nonCirculatingSupplyBalances = [];
let total = new bignumber_js_1.default(0);
for (const { ChainId, Address, JsonRpcUrl, TokenContractAddress, Name } of config_1.nonCirculatingSupplyAddressesConfig) {
for (const { chainId, address, jsonRpcUrl, tokenContractAddress, name } of yield (0, config_1.getNonCirculatingSupplyAddressConfigurations)()) {
let balance;
if (ChainId === "bnbBeaconChain") {
balance = new bignumber_js_1.default(yield (0, utils_1.getBep2TokenBalance)(Address, JsonRpcUrl, TokenContractAddress));
if (chainId === "bnbBeaconChain") {
balance = new bignumber_js_1.default(yield (0, utils_1.getBep2TokenBalance)(address, jsonRpcUrl, tokenContractAddress));
}
else {
balance = new bignumber_js_1.default(yield (0, utils_1.getErc20TokenBalance)(Address, JsonRpcUrl, TokenContractAddress));
balance = new bignumber_js_1.default(yield (0, utils_1.getErc20TokenBalance)(address, jsonRpcUrl, tokenContractAddress));
}
total = total.plus(balance);
nonCirculatingSupplyBalances.push({
ChainId,
Address,
TokenContractAddress,
Name,
Balance: balance
chainId,
address,
tokenContractAddress,
name,
balance: balance
});
}
return {
Expand Down
11 changes: 6 additions & 5 deletions build/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ app.get('/totalSupply', (req, res) => __awaiter(void 0, void 0, void 0, function
res.status(500).send('Error getting total supply');
}
}));
app.get("/nonCirculatingSupplyAddresses", (req, res) => {
res.json(config_1.nonCirculatingSupplyAddressesConfig);
});
app.get("/nonCirculatingSupplyAddresses", (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const nonCirculatingSupplyAddressConfigurations = yield (0, config_1.getNonCirculatingSupplyAddressConfigurations)();
res.json(nonCirculatingSupplyAddressConfigurations);
}));
app.get('/nonCirculatingSupplyBalancesByAddress', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
try {
const nonCirculatingSupplyBalances = yield (0, getSupplyAcrossNetworks_1.getNonCirculatingSupplyBalances)();
Expand All @@ -58,7 +59,7 @@ app.get('/nonCirculatingSupplyBalancesByAddress', (req, res) => __awaiter(void 0
app.get('/nonCirculatingSupplyBalance', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
try {
const { balances } = yield (0, getSupplyAcrossNetworks_1.getNonCirculatingSupplyBalances)();
const totalBalance = balances.reduce((sum, balance) => sum.plus(balance.Balance), new bignumber_js_1.default(0));
const totalBalance = balances.reduce((sum, balance) => sum.plus(balance.balance), new bignumber_js_1.default(0));
res.send(totalBalance.toString());
}
catch (error) {
Expand All @@ -72,7 +73,7 @@ app.get('/circulatingSupplyBalance', (req, res) => __awaiter(void 0, void 0, voi
const totalSupplyData = yield (0, getSupplyAcrossNetworks_1.getTotalSupplyAcrossNetworks)(networks);
const totalSupply = new bignumber_js_1.default(totalSupplyData.total);
const { balances } = yield (0, getSupplyAcrossNetworks_1.getNonCirculatingSupplyBalances)();
const nonCirculatingSupply = balances.reduce((sum, balance) => sum.plus(balance.Balance), new bignumber_js_1.default(0));
const nonCirculatingSupply = balances.reduce((sum, balance) => sum.plus(balance.balance), new bignumber_js_1.default(0));
const circulatingSupply = totalSupply.minus(nonCirculatingSupply);
res.send(circulatingSupply.toString());
}
Expand Down
48 changes: 48 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@types/axios": "^0.14.0",
"@types/bignumber.js": "^5.0.0",
"@types/node": "^18.15.5",
"@types/node-fetch": "^2.6.3",
"@types/web3": "^1.2.2",
"nodemon": "^2.0.22",
"ts-node": "^10.9.1",
Expand Down
58 changes: 0 additions & 58 deletions src/config-example.ts

This file was deleted.

Loading

0 comments on commit 52a7e69

Please sign in to comment.