tokamak-staking-lib
Version:
tokamak staking library
46 lines (45 loc) • 1.61 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 WTONABI = require("./abi/WTON.json");
const deposit_manager_1 = __importDefault(require("./deposit-manager"));
class WTON {
constructor() {
const web3 = web3_connector_1.default.instance().web3;
this._contract = new web3.eth.Contract(WTONABI, WTON._address);
}
static instance() {
if (!WTON._instance) {
WTON._instance = new WTON();
}
return WTON._instance;
}
static setNetwork(net) {
switch (net) {
case "mainnet":
WTON._address = "0xc4A11aaf6ea915Ed7Ac194161d2fC9384F15bff2";
break;
case "rinkeby":
WTON._address = "0x9985d94ee25a1eB0459696667f071ECE121ACce6";
break;
}
}
static get address() {
return WTON._address;
}
async totalSupply() {
return toBN(await this._contract.methods.totalSupply().call());
}
async balanceOf(account) {
return toBN(await this._contract.methods.balanceOf(account).call());
}
async wtonBalanceOfDepositManager() {
return await this._contract.methods.balanceOf(deposit_manager_1.default.address).call();
}
}
exports.default = WTON;
WTON._address = "0xc4A11aaf6ea915Ed7Ac194161d2fC9384F15bff2";