@celo/contractkit
Version:
Celo's ContractKit to interact with Celo network
54 lines • 2.61 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Erc20Wrapper = void 0;
const BaseWrapper_1 = require("./BaseWrapper");
/**
* ERC-20 contract only containing the non-optional functions
*/
class Erc20Wrapper extends BaseWrapper_1.BaseWrapper {
constructor() {
super(...arguments);
/**
* Querying allowance.
* @param from Account who has given the allowance.
* @param to Address of account to whom the allowance was given.
* @returns Amount of allowance.
*/
this.allowance = (0, BaseWrapper_1.proxyCall)(this.contract.methods.allowance, undefined, BaseWrapper_1.valueToBigNumber);
/**
* Returns the total supply of the token, that is, the amount of tokens currently minted.
* @returns Total supply.
*/
this.totalSupply = (0, BaseWrapper_1.proxyCall)(this.contract.methods.totalSupply, undefined, BaseWrapper_1.valueToBigNumber);
/**
* Approve a user to transfer the token on behalf of another user.
* @param spender The address which is being approved to spend the token.
* @param value The amount of the token approved to the spender.
* @return True if the transaction succeeds.
*/
this.approve = (0, BaseWrapper_1.proxySend)(this.connection, this.contract.methods.approve);
/**
* Transfers the token from one address to another.
* @param to The address to transfer the token to.
* @param value The amount of the token to transfer.
* @return True if the transaction succeeds.
*/
this.transfer = (0, BaseWrapper_1.proxySend)(this.connection, this.contract.methods.transfer);
/**
* Transfers the token from one address to another on behalf of a user.
* @param from The address to transfer the token from.
* @param to The address to transfer the token to.
* @param value The amount of the token to transfer.
* @return True if the transaction succeeds.
*/
this.transferFrom = (0, BaseWrapper_1.proxySend)(this.connection, this.contract.methods.transferFrom);
/**
* Gets the balance of the specified address.
* @param owner The address to query the balance of.
* @return The balance of the specified address.
*/
this.balanceOf = (0, BaseWrapper_1.proxyCall)(this.contract.methods.balanceOf, undefined, BaseWrapper_1.valueToBigNumber);
}
}
exports.Erc20Wrapper = Erc20Wrapper;
//# sourceMappingURL=Erc20Wrapper.js.map