tokamak-staking-lib
Version:
tokamak staking library
46 lines (45 loc) • 1.59 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const { toBN } = require("web3-utils");
const web3_connector_1 = __importDefault(require("../common/web3-connector"));
const TONABI = require("./abi/TON.json");
const deposit_manager_1 = __importDefault(require("./deposit-manager"));
class TON {
constructor() {
const web3 = web3_connector_1.default.instance().web3;
this._contract = new web3.eth.Contract(TONABI, TON._address);
}
static instance() {
if (!TON._instance) {
TON._instance = new TON();
}
return TON._instance;
}
static setNetwork(net) {
switch (net) {
case "mainnet":
TON._address = "0x2be5e8c109e2197d077d13a82daead6a9b3433c5";
break;
case "rinkeby":
TON._address = "0x3734E35231abE68818996dC07Be6a8889202DEe9";
break;
}
}
static get address() {
return TON._address;
}
async totalSupply() {
return toBN(await this._contract.methods.totalSupply().call());
}
async balanceOf(account) {
return toBN(await this._contract.methods.balanceOf(account).call());
}
async tonBalanceOfDepositManager() {
return await this._contract.methods.balanceOf(deposit_manager_1.default.address).call();
}
}
exports.default = TON;
TON._address = "0x2be5e8c109e2197d077d13a82daead6a9b3433c5";