UNPKG

@colony/colony-js-client

Version:

Reference implementation of the Colony API

124 lines (90 loc) 4.01 kB
'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); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var TokenLockingClient = function (_ContractClient) { (0, _inherits3.default)(TokenLockingClient, _ContractClient); function TokenLockingClient() { (0, _classCallCheck3.default)(this, TokenLockingClient); return (0, _possibleConstructorReturn3.default)(this, (TokenLockingClient.__proto__ || Object.getPrototypeOf(TokenLockingClient)).apply(this, arguments)); } (0, _createClass3.default)(TokenLockingClient, [{ key: 'initializeContractMethods', value: function initializeContractMethods() { // Callers this.addCaller('getTotalLockCount', { input: [['token', 'anyAddress']], output: [['count', 'number']] }); this.addCaller('getUserLock', { input: [['token', 'anyAddress'], ['user', 'address']], output: [['lockCount', 'number'], ['amount', 'bigNumber'], ['timestamp', 'date']] }); // Events this.addEvent('TokenLocked', [['token', 'anyAddress'], ['lockCount', 'bigNumber']]); this.addEvent('UserTokenDeposited', [['token', 'anyAddress'], ['user', 'address'], ['amount', 'bigNumber'], ['timestamp', 'date']]); this.addEvent('UserTokenUnlocked', [['token', 'anyAddress'], ['user', 'address'], ['lockId', 'number']]); this.addEvent('UserTokenWithdrawn', [['token', 'anyAddress'], ['user', 'address'], ['amount', 'bigNumber']]); // Senders this.addSender('deposit', { input: [['token', 'anyAddress'], ['amount', 'bigNumber']] }); this.addSender('incrementLockCounterTo', { input: [['token', 'anyAddress'], ['lockId', 'number']] }); this.addSender('lockToken', { input: [['token', 'anyAddress']] }); this.addSender('unlockTokenForUser', { input: [['token', 'anyAddress'], ['user', 'address'], ['lockId', 'number']] }); this.addSender('withdraw', { input: [['token', 'anyAddress'], ['amount', 'bigNumber']] }); } }], [{ key: 'defaultQuery', /* Unlock all tokens for a user on a given token contract. */ /* Lock all tokens for a given token contract. */ /* Get the total number of locked tokens. */ get: function get() { return { contractName: 'ITokenLocking' }; } /* Withdraw tokens. This function only be called if the tokens that the user is attempting to withdraw are not locked. */ /* Increment the token lock counter. This method allows users to waive reward payouts for past reward payout cycles, unlocking the tokens that were locked in previous reward payout cycles. */ /* Get the total number of locked tokens for a given user. */ /* Deposit tokens. This function only be called if the tokens that the user is attempting to deposit are not locked and if the user has allowed the token locking contract to transfer the tokens. */ }]); return TokenLockingClient; }(_colonyJsContractClient2.default); exports.default = TokenLockingClient; //# sourceMappingURL=index.js.map