@colony/colony-js-client
Version:
Reference implementation of the Colony API
195 lines (141 loc) • 5.81 kB
JavaScript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _bn = require('bn.js');
var _bn2 = _interopRequireDefault(_bn);
var _colonyJsContractClient = require('@colony/colony-js-contract-client');
var _colonyJsContractClient2 = _interopRequireDefault(_colonyJsContractClient);
var _CreateTokenAuthority = require('./senders/CreateTokenAuthority');
var _CreateTokenAuthority2 = _interopRequireDefault(_CreateTokenAuthority);
var _GetTokenInfo = require('./callers/GetTokenInfo');
var _GetTokenInfo2 = _interopRequireDefault(_GetTokenInfo);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* eslint-disable import/no-cycle */
var TokenClient = function (_ContractClient) {
(0, _inherits3.default)(TokenClient, _ContractClient);
function TokenClient() {
(0, _classCallCheck3.default)(this, TokenClient);
return (0, _possibleConstructorReturn3.default)(this, (TokenClient.__proto__ || Object.getPrototypeOf(TokenClient)).apply(this, arguments));
}
(0, _createClass3.default)(TokenClient, [{
key: 'initializeContractMethods',
value: function initializeContractMethods() {
var amount = ['amount', 'bigNumber'];
var sourceAddress = ['sourceAddress', 'address'];
var destinationAddress = ['destinationAddress', 'address'];
var address = ['address', 'address'];
// Events
this.addEvent('Transfer', [['from', 'anyAddress'], ['to', 'anyAddress'], ['value', 'bigNumber']]);
this.addEvent('Approval', [['owner', 'anyAddress'], ['spender', 'anyAddress'], ['value', 'bigNumber']]);
this.addEvent('Mint', [['address', 'anyAddress'], ['amount', 'bigNumber']]);
this.addEvent('Burn', [['address', 'anyAddress'], ['amount', 'bigNumber']]);
this.addEvent('LogSetOwner', [['owner', 'anyAddress']]);
this.addEvent('LogSetAuthority', [['authority', 'anyAddress']]);
// Callers
this.getTokenInfo = new _GetTokenInfo2.default({ client: this });
this.addCaller('getTotalSupply', {
functionName: 'totalSupply',
output: [amount]
});
this.addCaller('getBalanceOf', {
functionName: 'balanceOf',
input: [sourceAddress],
output: [amount]
});
this.addCaller('getAllowance', {
functionName: 'allowance',
input: [sourceAddress, address],
output: [amount]
});
this.addCaller('isLocked', {
functionName: 'locked',
output: [['locked', 'boolean']]
});
// Senders
this.createTokenAuthority = new _CreateTokenAuthority2.default({ client: this });
this.addSender('transfer', {
input: [destinationAddress, amount]
});
this.addSender('transferFrom', {
input: [sourceAddress, destinationAddress, amount]
});
this.addSender('approve', {
input: [address, amount]
});
this.addSender('mint', {
input: [address, amount]
});
this.addSender('burn', {
input: [address, amount]
});
this.addSender('setOwner', {
input: [['owner', 'address']]
});
this.addSender('setAuthority', {
input: [['authority', 'address']]
});
this.addSender('unlock', {});
}
}], [{
key: 'defaultQuery',
/*
Transfer tokens from one address to another address. The address the tokens are transferred from must have a sufficient token balance and it must have a sufficient token allowance approved by the token owner.
*/
/*
Set the `owner` of a token contract. This function can only be called by the current `owner` of the contract. In order to call token contract methods from within a colony, the token `owner` must be the address of the colony contract.
*/
/*
Mint new tokens. This function can only be called by the token owner or an address with authority.
*/
/*
Get the total supply of the token.
*/
/*
Get the the token balance of an address.
*/
/*
Deploy a TokenAuthority contract which can then be use to control the transfer of a token.
*/
/*
Approve a token allowance. This function can only be called by the token `owner`. The allowance is the amount of tokens that the `spender` is authorized to transfer using the `transferFrom` function.
*/
get: function get() {
return {
contractName: 'Token'
};
}
/*
Unlock the token.
*/
/*
Transfer tokens from the address calling the function to another address. The current address must have a sufficient token balance.
*/
/*
Assign an account the token authority role within a colony.
*/
/*
Get whether the token is locked.
*/
/*
Get information about the token.
*/
/*
Get the token allowance of an address. The allowance is the amount of tokens that the `spender` is authorized to transfer using the `transferFrom` function.
*/
/*
Burn tokens. This function can only be called by the token owner or an address with authority.
*/
}]);
return TokenClient;
}(_colonyJsContractClient2.default);
exports.default = TokenClient;
//# sourceMappingURL=index.js.map