Skip to content

Commit d397ea6

Browse files
committed
Syscoin 5 upgrade
1 parent 1206811 commit d397ea6

File tree

4 files changed

+19
-32
lines changed

4 files changed

+19
-32
lines changed

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SYSCOIN_CORE_RPC_HOST=localhost
2+
SYSCOIN_CORE_RPC_PORT=8370
3+
SYSCOIN_CORE_RPC_USERNAME=user
4+
SYSCOIN_CORE_RPC_PASSWORD=pass

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ COPY package-lock.json ./
99
RUN npm ci
1010

1111
COPY ./index.js ./index.js
12+
COPY ./config.js ./config.js
1213

1314
EXPOSE 3000
1415

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,18 @@ Host: https://info.syscoin.org/
3333
- `SYSCOIN_CORE_RPC_PASSWORD` - password for auth to RPC
3434
- `SYSCOIN_CORE_RPC_USERNAME` - username for auth to RPC
3535

36+
An `.env.example` is provided for convenience.
37+
38+
3639
You can generate password and username:
3740

3841
```bash
3942
curl -sSL https://raw.githubusercontent.com/syscoin/syscoin/master/share/rpcauth/rpcauth.py | python - <username>
4043
```
4144

45+
## Syscoin Vault Manager
46+
47+
Please refer to `vault.js` for the current official address of SyscoinVaultManager contract.
48+
49+
4250
For more information you can check it here: https://github.com/syscoin/docker-syscoin-core#usage

index.js

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const axios = require('axios');
33
const express = require("express");
44
const app = express();
55
const port = process.env.PORT || 3000;
6+
const CONFIGURATION = require("./config");
67

78
let lastRecordedTotalSupply = {
89
value: undefined,
@@ -78,7 +79,7 @@ const getSupply = async () => {
7879
"https://explorer-v5.syscoin.org/api?module=stats&action=coinsupply"
7980
),
8081
explorerApi.get(
81-
"https://explorer.syscoin.org/api?module=account&action=balance&address=0xA738a563F9ecb55e0b2245D1e9E380f0fE455ea1"
82+
`https://explorer.syscoin.org/api?module=account&action=balance&address=${CONFIGURATION.SyscoinVaultManager}`
8283
)
8384
]);
8485

@@ -121,38 +122,11 @@ const getCirculatingSupply = async () => {
121122
throw new Error("Dependency Error: Total Supply unavailable");
122123
}
123124

124-
try {
125-
const treasuryResponse = await explorerApi.get(
126-
"https://explorer.syscoin.org/api?module=account&action=balance&address=0x94EBc5528bE5Ec6914B0d7366aF68aA4b6cB2696"
127-
);
128-
129-
// Validate treasury balance response
130-
const treasuryData = treasuryResponse.data;
131-
if (!treasuryData || treasuryData.status !== "1" || typeof treasuryData.result !== 'string') {
132-
throw new Error(`Invalid treasury balance response structure or status: ${JSON.stringify(treasuryData)}`);
133-
}
134-
const treasuryBalanceWei = treasuryData.result;
135-
136-
const balanceInEther = parseFloat(treasuryBalanceWei) / largeNumber;
137-
if (isNaN(balanceInEther)) throw new Error(`Could not parse treasuryBalanceWei: ${treasuryBalanceWei}`);
138-
if (balanceInEther < 0) throw new Error(`Invalid treasury balance calculated: ${balanceInEther}`);
125+
const treasuryBalance = 0; // Treasury is now factored into sys5 governance/utxo
126+
const finalCirculatingSupply = lastRecordedTotalSupply.value - treasuryBalance;
139127

140-
console.log(`Treasury Balance (SYS): ${balanceInEther}`);
141-
const circulatingSupply = lastRecordedTotalSupply.value - balanceInEther;
142-
143-
if (isNaN(circulatingSupply)) throw new Error(`Circulating supply calculation resulted in NaN`);
144-
if (circulatingSupply < -1) { // Allow small negative tolerance
145-
throw new Error(`Calculated circulatingSupply is unexpectedly negative: ${circulatingSupply}`);
146-
}
147-
const finalCirculatingSupply = Math.max(0, circulatingSupply); // Clamp to 0
148-
149-
console.log("Circulating supply calculated successfully.");
150-
return finalCirculatingSupply;
151-
} catch (error) {
152-
console.error(`Error in getCirculatingSupply: ${error.message}`);
153-
if (error.response) console.error(" -> Axios Response Error Data:", error.response.data);
154-
throw error; // Re-throw
155-
}
128+
console.log("Circulating supply calculated successfully.");
129+
return finalCirculatingSupply;
156130
};
157131

158132
const recordTotalSupply = async () => {

0 commit comments

Comments
 (0)