@volare.finance/utils.js
Version:
The Blockchain Utils
78 lines • 2.64 kB
JavaScript
;
/**
* @file native.ts
* @author astra <astra@volare.finance>
* @date 2022
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Native = void 0;
const tslib_1 = require("tslib");
const network_1 = require("../network");
const provider_1 = require("../provider");
const type_1 = require("../type");
class Native extends provider_1.Provider {
static ABI() {
return [];
}
static Name() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const chainId = yield Native.ChainId();
return network_1.SYMBOLS[chainId];
});
}
static Symbol() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const chainId = yield Native.ChainId();
return network_1.SYMBOLS[chainId];
});
}
static Decimals() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const chainId = yield Native.ChainId();
return network_1.DECIMALS[chainId];
});
}
static BalanceOf(owner) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return new type_1.BigNumber((yield Native.provider.getBalance(owner)).toString());
});
}
static Transfer(owner, to, value) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return owner.connect(Native.provider).sendTransaction({ to, value: value.toString(10) });
});
}
constructor(endpoint) {
super(endpoint);
}
name() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const chainId = yield this.chainId();
return network_1.SYMBOLS[chainId];
});
}
symbol() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const chainId = yield this.chainId();
return network_1.SYMBOLS[chainId];
});
}
decimals() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const chainId = yield this.chainId();
return network_1.DECIMALS[chainId];
});
}
balanceOf(owner) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return new type_1.BigNumber((yield this.provider.getBalance(owner)).toString());
});
}
transfer(owner, to, value) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return owner.connect(this.provider).sendTransaction({ to, value: value.toString(10) });
});
}
}
exports.Native = Native;
//# sourceMappingURL=native.js.map