|
| 1 | +const Web3 = require("web3"); |
| 2 | +const fs = require("fs"); |
| 3 | +const async = require("async"); |
| 4 | +const path = require("path"); |
| 5 | +const web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/")); |
| 6 | + |
| 7 | +const securityTokenRegistryABI = JSON.parse(require('fs').readFileSync('../build/contracts/SecurityTokenRegistry.json').toString()).abi; |
| 8 | +const securityTokenABI = JSON.parse(require('fs').readFileSync('../build/contracts/SecurityToken.json').toString()).abi; |
| 9 | +const generalTransferManagerABI = JSON.parse(require('fs').readFileSync('../build/contracts/GeneralTransferManager.json').toString()).abi; |
| 10 | +const securityTokenRegistryAddress = "0xEf58491224958d978fACF55D2120c55A24516B98"; |
| 11 | +const securityTokenRegistry = new web3.eth.Contract(securityTokenRegistryABI, securityTokenRegistryAddress); |
| 12 | + |
| 13 | +async function getTokens() { |
| 14 | + let strEvents = await web3.eth.getPastLogs({fromBlock:'0x5C5C18', address:securityTokenRegistry.address, topics: ["0x2510d802a0818e71139a7680a6388bcffcd3fa686e02a0f7319488c5bdb38fcb"]}); |
| 15 | + for (let i = 0; i < strEvents.length; i++) { |
| 16 | + let tokenAddress = '0x' + strEvents[i].topics[1].slice(26,66) |
| 17 | + await getInfo(tokenAddress); |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +async function getInfo(tokenAddress) { |
| 22 | + let token = new web3.eth.Contract(securityTokenABI, tokenAddress); |
| 23 | + console.log("Token - " + tokenAddress); |
| 24 | + console.log("----------------------"); |
| 25 | + console.log("Owner: " + await token.methods.owner().call()); |
| 26 | + console.log("Name: " + await token.methods.name().call()); |
| 27 | + console.log("Symbol: " + await token.methods.symbol().call()); |
| 28 | + console.log("Total Supply: " + await token.methods.totalSupply().call()); |
| 29 | + console.log("Frozen: " + await token.methods.freeze().call()); |
| 30 | + console.log("Investors: " + await token.methods.investorCount().call()); |
| 31 | + console.log("Latest Checkpoint: " + await token.methods.currentCheckpointId().call()); |
| 32 | + console.log("Finished Issuer Minting: " + await token.methods.finishedIssuerMinting().call()); |
| 33 | + console.log("Finished STO Minting: " + await token.methods.finishedSTOMinting().call()); |
| 34 | + let gtmRes = await token.methods.modules(2, 0).call(); |
| 35 | + let gtmEvents = await web3.eth.getPastLogs({fromBlock:'0x5C5C18', address:gtmRes.moduleAddress}); |
| 36 | + console.log("Count of GeneralTransferManager Events: " + gtmEvents.length); |
| 37 | + console.log("Modules Attached (TransferManager):"); |
| 38 | + await getModules(2, token); |
| 39 | + console.log("Modules Attached (PermissionManager):"); |
| 40 | + await getModules(1, token); |
| 41 | + console.log("Modules Attached (STO):"); |
| 42 | + await getModules(3, token); |
| 43 | + console.log("Modules Attached (Checkpoint):"); |
| 44 | + await getModules(4, token); |
| 45 | + console.log("") |
| 46 | + console.log(); |
| 47 | + console.log(); |
| 48 | +} |
| 49 | + |
| 50 | +async function getModules(type, token) { |
| 51 | + let index = 0; |
| 52 | + while (true) { |
| 53 | + try { |
| 54 | + let res = await token.methods.modules(type, index).call(); |
| 55 | + console.log(" Name: " + web3.utils.toAscii(res.name)); |
| 56 | + console.log(" Address: " + res.moduleAddress); |
| 57 | + } catch (err) { |
| 58 | + // console.log(err); |
| 59 | + if (index == 0) { |
| 60 | + console.log(" None"); |
| 61 | + } |
| 62 | + return; |
| 63 | + } |
| 64 | + index = index + 1; |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +getTokens(); |
0 commit comments