UNPKG

@colony/colony-js-client

Version:

Reference implementation of the Colony API

1,443 lines (1,075 loc) 78.5 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray'); var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); var _defineProperty2 = require('babel-runtime/helpers/defineProperty'); var _defineProperty3 = _interopRequireDefault(_defineProperty2); var _regenerator = require('babel-runtime/regenerator'); var _regenerator2 = _interopRequireDefault(_regenerator); var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator'); var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2); var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); var _get2 = require('babel-runtime/helpers/get'); var _get3 = _interopRequireDefault(_get2); var _createClass2 = require('babel-runtime/helpers/createClass'); var _createClass3 = _interopRequireDefault(_createClass2); var _inherits2 = require('babel-runtime/helpers/inherits'); var _inherits3 = _interopRequireDefault(_inherits2); var _assert = require('assert'); var _assert2 = _interopRequireDefault(_assert); var _colonyJsContractClient = require('@colony/colony-js-contract-client'); var _colonyJsContractClient2 = _interopRequireDefault(_colonyJsContractClient); var _colonyJsUtils = require('@colony/colony-js-utils'); var _index = require('../ColonyNetworkClient/index'); var _index2 = _interopRequireDefault(_index); var _index3 = require('../TokenClient/index'); var _index4 = _interopRequireDefault(_index3); var _index5 = require('../TokenLockingClient/index'); var _index6 = _interopRequireDefault(_index5); var _GetTask = require('./callers/GetTask'); var _GetTask2 = _interopRequireDefault(_GetTask); var _GetExtensionAddress = require('./callers/GetExtensionAddress'); var _GetExtensionAddress2 = _interopRequireDefault(_GetExtensionAddress); var _AddExtension = require('./senders/AddExtension'); var _AddExtension2 = _interopRequireDefault(_AddExtension); var _AddPayment = require('./senders/AddPayment'); var _AddPayment2 = _interopRequireDefault(_AddPayment); var _AddTask = require('./senders/AddTask'); var _AddTask2 = _interopRequireDefault(_AddTask); var _AddExpenditure = require('./senders/AddExpenditure'); var _AddExpenditure2 = _interopRequireDefault(_AddExpenditure); var _MakePayment = require('./senders/MakePayment'); var _MakePayment2 = _interopRequireDefault(_MakePayment); var _MakePaymentFundedFromDomain = require('./senders/MakePaymentFundedFromDomain'); var _MakePaymentFundedFromDomain2 = _interopRequireDefault(_MakePaymentFundedFromDomain); var _RemoveExtension = require('./senders/RemoveExtension'); var _RemoveExtension2 = _interopRequireDefault(_RemoveExtension); var _TransferExpenditure = require('./senders/TransferExpenditure'); var _TransferExpenditure2 = _interopRequireDefault(_TransferExpenditure); var _DomainAuth = require('./senders/DomainAuth'); var _DomainAuth2 = _interopRequireDefault(_DomainAuth); var _SetAdminRole = require('./senders/SetAdminRole'); var _SetAdminRole2 = _interopRequireDefault(_SetAdminRole); var _SetFounderRole = require('./senders/SetFounderRole'); var _SetFounderRole2 = _interopRequireDefault(_SetFounderRole); var _Upgrade = require('./senders/Upgrade'); var _Upgrade2 = _interopRequireDefault(_Upgrade); var _addRecoveryMethods = require('../addRecoveryMethods'); var _addRecoveryMethods2 = _interopRequireDefault(_addRecoveryMethods); var _constants = require('../constants'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // @note Deprecated in glider-rc.3, replaced with ColonyRoleSet // @note Deprecated in glider-rc.3, replaced with ColonyRoleSet // @note Deprecated in glider-rc.3, replaced with ColonyRoleSet // @note Introduced in glider-rc.3, replacing existing role set events // @note Deprecated in glider-rc.3, replaced with ColonyRoleSet /* eslint-disable import/no-cycle */ var ColonyClient = function (_ContractClient) { (0, _inherits3.default)(ColonyClient, _ContractClient); (0, _createClass3.default)(ColonyClient, null, [{ key: 'defaultQuery', /* Upgrade the colony to a new colony contract version. The new version must be higher than the current version. Downgrading to old versions is not permitted. */ /* Transfer Expenditure via the arbitration permission */ /* Submit a work rating for a task. This function can only be called by the address assigned the task `EVALUATOR` role, who is submitting a rating for the address assigned the task `WORKER` role, or the address assigned the task `WORKER` role, who is submitting a rating for the address assigned the task `MANAGER` role. In order to submit a rating, a `secret` must be generated using the `generateSecret` method, which keeps the rating hidden until all ratings have been submitted and revealed. */ /* Submit the task deliverable. This function can only be called by the address assigned the task `WORKER` role on or before the task due date. The submission cannot be overwritten, which means the deliverable cannot be changed once it has been submitted. */ /* Assign the task `WORKER` role to an address. This function can only be called before the task is finalized. The address assigned the task `MANAGER` role and the address being assigned the task `WORKER` role must both sign the transaction before it can be executed. */ /* Set the skill of a task. Only one skill can be assigned per task. The user assigned the task `MANAGER` role and the address assigned the task `WORKER` role must both sign this transaction before it can be executed. */ /* Set the payout amount for the task `MANAGER` role. */ /* Set the payout amount for the task `EVALUATOR` role. */ /* Set the domain of a task. Every task must belong to a domain. This function can only be called by the address assigned the task `MANAGER` role. TODO: Make unavailable in >v4 but present in <v3 */ /* Set the value for a storage slot while in recovery mode. This can only be called by a user assigned the colony `RECOVERY` role. */ /* Set the inverse amount of the reward. This function can only be called by the address currently assigned the colony `ROOT` role. If the fee is 1% (or 0.01), the inverse amount will be 100. */ /* Set the payment skill. */ /* Set the payment payout. */ /* Set the inverse amount of the reward. This can only be called from the Meta Colony and only by the address assigned the colony `ROOT` role. If the fee is 1% (or 0.01), the inverse amount will be 100. */ /* Assign the colony `FOUNDER` role to an address. This function is not included in the core contracts but instead it comes from the `OldRoles` extension contract. This function can only be called by an address assigned the colony `ROOT` (`FOUNDER`) role. There can only be one address assigned to the colony `ROOT` (`FOUNDER`) role, therefore, the address currently assigned will forfeit the role. */ /* Set the recipient of an expenditure. */ /* Set the payout of an expenditure. */ /* Assign the colony `ARCHITECTURE` role to an address. The address calling the method must have permission within the domain that permission is being granted or a parent domain to the domain that permission is being granted. The address calling the method must already be assigned either the colony `ROOT` or `ARCHITECTURE` role within the domain or parent domain. */ /* Assign the colony `ADMINISTRATION` role to an address. The address calling the method must have permission within the domain that permission is being granted or a parent domain to the domain that permission is being granted. The address calling the method must already be assigned either the colony `ROOT` or `ARCHITECTURE` role within the domain or parent domain. */ /* Reveal a submitted work rating. In order to reveal a work rating, the same `salt` and `value` used to generate the `secret` when the task work rating was submitted must be provided again here to reveal the task work rating. */ /* Remove the task `EVALUATOR` role from an address. This function can only be called before the task is complete, i.e. either before the deliverable has been submitted or the address assigned the task `WORKER` role has failed to meet the deadline and the address assigned the task `MANAGER` role has marked the task as complete. */ /* Remove an extension contract. */ /* Move funds from one pot to another. */ /* Mint new tokens. This function can only be called if the address of the colony contract is the owner of the token contract. If this is the case, then this function can only be called by the address assigned the colony `ROOT` role. */ /* Make a payment in one transaction. This function is not included in the core contracts but instead it comes from the `OneTxPayment` extension contract. The `OneTxPayment` extension contract and the sender must both be assigned the colony `ADMINISTRATION` role. */ /* Check whether an address has a role assigned. */ /* Get the address of the token contract that is the native token assigned to the colony. The native token is the token used to calculate reputation scores, i.e. `1` token earned for completing a task with a satisfactory rating (`2`) will result in `1` reputation point earned. */ /* Get the secret of a task work rating that has been submitted. If a task is in the commit period of the rating process, the work ratings are hidden in a keccak256 hash that was created from a `salt` and `value`. The rating secret can be retrieved but in order to reveal the secret, one would have to know both the `salt` and `value` used to generate the secret. */ /* Get the task payout amount assigned to a task role. Multiple tokens can be used for task payouts, therefore the token must be specified when calling this function. In order to get the task payout amount in Ether, `token` must be an empty address. */ /* Get information about a task. */ /* Get the inverse amount of the reward. If the fee is 1% (or 0.01), the inverse amount will be 100. */ /* Get the total number of payments. */ /* Get the address of the owner of the colony contract. */ /* Get the payout of a funding pot. */ /* Get the balance of a funding pot. */ /* Get the address of an extension contract associated with the colony address. */ /* Get information about an expenditure's slot */ /* Get information about an expenditure. */ /* Get information about a domain. */ /* Get the address of the authority contract associated with the colony contract. */ /* Finalize a task. Once a task is finalized, no further changes to the task can be made and each user assigned a task role can claim the payout assigned to their role. */ /* Finalize a payment. Once a payment is finalized, no further changes to the payment can be made and the address that is assigned the payment can claim the payment. */ /* Exit colony recovery mode. This function can be called by anyone if enough whitelist approvals are given. */ /* Deprecate a global skill. This can only be called from the Meta Colony and only by the address assigned the colony `ROOT` role. */ /* Claim a payout assigned to a task role (`MANAGER`, `EVALUATOR`, or `WORKER`). This function can only be called by the address assigned the given task role after the task has been finalized. */ /* Claim a payment. */ /* Claim funds that the colony has received by adding them to the funding pot of the root domain. A set fee is deducted from the funds claimed and added to the colony rewards pot. No fee is deducted when tokens native to the colony are claimed. */ /* Cancel a task. Once a task is cancelled, no further changes to the task can be made. */ /* Indicate approval to exit colony recovery mode. This function can only be called by an address assigned the colony `RECOVERY` role. */ /* Add a payment to the colony. */ /* Add an extension contract. */ /* Add a domain to the colony. */ get: function get() { return { contractName: 'IColony' }; } /* Verify the correctness of a patricia proof associated with reputation. */ /* Transfer Expenditure via the ownership permission */ /* Transfer Expenditure as the owner */ /* Submit the task deliverable and the work rating for the address assigned the task `MANAGER` role. This function can only be called by the address assigned the task `WORKER` role on or before the task due date. The submission cannot be overwritten, which means the deliverable cannot be changed once it has been submitted. In order to submit a rating, a `secret` must be generated using the `generateSecret` method, which keeps the rating hidden until all ratings have been submitted and revealed. */ /* Start the next reward payout cycle. All the funds in the colony rewards pot for the given token will become locked until reputation holders have claimed their rewards payout using `claimRewardPayout`. Reputation holders can also waive their reward payout and unlock their tokens for past reward payout cycles by using `incrementLockCounterTo`. */ /* Set the payout amount for the task `WORKER` role. */ /* Assign the task `MANAGER` role to an address. This function can only be called before the task is finalized. The address currently assigned the task `MANAGER` role and the address being assigned the task `MANAGER` role must both sign the transaction before it can be executed. */ /* Assign the task `EVALUATOR` role to an address. This function can only be called before the task is finalized. The address assigned the task `MANAGER` role and the address being assigned the task `EVALUATOR` role must both sign the transaction before it can be executed. */ /* Set the due date of a task. The due date is the last day that the address assigned the task `WORKER` role can submit the task deliverable. */ /* Set the task specification. The task specification, or "task brief", is a description of the work that must be completed for the task. The description is hashed and stored with the task for future reference during the rating process or in the event of a dispute. */ /* Assign the colony `ROOT` role to an address. This function can only be called by an address currently assigned the colony `ROOT` role. */ /* Assign the colony `RECOVERY` role to an address. This function can only be called by the colony `ROOT` role. */ /* Set the payment recipient. */ /* Set the payment domain. TODO: Make unavailable in v4 but present in v3 */ /* Assign the colony `FUNDING` role to an address. The address calling the method must have permission within the domain that permission is being granted or a parent domain to the domain that permission is being granted. The address calling the method must already be assigned either the colony `ROOT` or `ARCHITECTURE` role within the domain or parent domain. */ /* Set the skill of an expenditure. */ /* Set the payout of an expenditure. */ /* Set the claim delay of an expenditure's slot */ /* Set the payouts for all task roles. This can only be called by the address assigned the task `MANAGER` role and only if the task `EVALUATOR` role and `WORKER` task role are not assigned or they are assigned to the same address that is currently assigned the task `MANAGER` role. */ /* Assign the colony `ADMIN` role to an address. This function is not included in the core contracts but instead it comes from the `OldRoles` extension contract. This function can only be called by an address assigned the colony `ROOT` (`FOUNDER`) role or an address assigned the colony `ADMIN` (`ARCHITECTURE`) role. There is no limit to the number of addresses that can be assigned the colony `ADMIN` role. */ /* Remove the task `WORKER` role from an address. This function can only be called before the task is complete, i.e. either before the deliverable has been submitted or the address assigned the task `WORKER` role has failed to meet the deadline and the address assigned the task `MANAGER` role has marked the task as complete. */ /* Remove the colony `RECOVERY` role from an address. This function can only be called by the colony `ROOT` role. */ /* Register an ENS label for the colony. */ /* Mint tokens for the Colony Network. This can only be called from the Meta Colony and only by the address assigned the colony `ROOT` role. */ /* Make a payment in one transaction. Like `makePayment` but just funded from the given domainId. This will throw if the given domain doesn't have enough funds */ /* Check whether or not the colony is in recovery mode. */ /* Get the version number of the colony contract. The version number starts at `1` and is incremented by `1` with every new version. */ /* Get information about the secrets of the task work ratings. */ /* Get information about a task role. */ /* Get the total number of tasks in the colony. The return value is also the ID of the last task created. */ /* Get information about a reward payout cycle. */ /* Get the total number of addresses that are assigned the colony `RECOVERY` role. */ /* Get information about a payment. */ /* Get the total amount of funds that are not in the colony rewards pot. This is a value that keeps track of the total assets a colony has to work with, which may be split among several distinct pots associated with various domains and tasks. */ /* Get the total number of funding pots. */ /* Get information about a funding pot. */ /* Get information about an expenditure's slot */ /* Get the total number of expenditures. */ /* Get the total number of domains in the colony. The return value is also the ID of the last domain created. */ /* Get the address of the Colony Network contract. */ /* Generate a secret for task ratings. This function returns a keccak256 hash created from the input parameters. */ /* Finalize a reward payout cycle. This function can only be called when the reward payout cycle has finished, i.e. 60 days have passed since the creation of the reward payout cycle. */ /* Finalize an expenditure. Once an expenditure is finalized, no further changes to the payment can be made by the owner and the address that is assigned to the slots can claim the payments once the timeout has expired. */ /* Enter colony recovery mode. This function can only be called by a user assigned the colony `RECOVERY` role. */ /* Mark a task as complete. If the address assigned the task `WORKER` role fails to submit the task deliverable by the due date, this function must be called by the address assigned the task `MANAGER` role. This allows the task work to be rated and the task to be finalized. */ /* Claim a reward payout. */ /* Claim expenditure payout. */ /* Cancel an expenditure. Once an expenditure is cancelled, no further changes to the task can be made. */ /* Bootstrap the colony by giving an initial amount of tokens and reputation to selected addresses. This function can only be called by the address assigned the colony `ROOT` role when the `taskCount` for the colony is equal to `0`. */ /* Add a new task within the colony. */ /* Add a global skill. This can only be called from the Meta Colony and only by the address assigned the colony `ROOT` role. */ /* Add a new expenditure within the colony. */ /* Add a colony contract version. This can only be called from the Meta Colony and only by the address assigned the colony `ROOT` role. */ }, { key: 'TokenClient', get: function get() { return _index4.default; } }, { key: 'TokenLockingClient', get: function get() { return _index6.default; } }]); function ColonyClient(_ref) { var _ret; var adapter = _ref.adapter, networkClient = _ref.networkClient, query = _ref.query, tokenClient = _ref.tokenClient, tokenLockingClient = _ref.tokenLockingClient, verbose = _ref.verbose; (0, _classCallCheck3.default)(this, ColonyClient); var _this = (0, _possibleConstructorReturn3.default)(this, (ColonyClient.__proto__ || Object.getPrototypeOf(ColonyClient)).call(this, { adapter: adapter, query: query, verbose: verbose })); if (!(networkClient instanceof _index2.default)) throw new Error('A `networkClient` property must be supplied ' + '(an instance of `ColonyNetworkClient`)'); if (!(tokenLockingClient instanceof _index6.default)) throw new Error('A `tokenLockingClient` property must be supplied ' + '(an instance of `TokenLockingClient`)'); _this.networkClient = networkClient; if (tokenClient) _this.tokenClient = tokenClient; _this.tokenLockingClient = tokenLockingClient; return _ret = _this, (0, _possibleConstructorReturn3.default)(_this, _ret); } (0, _createClass3.default)(ColonyClient, [{ key: 'init', value: function () { var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee() { var _ref3, version; return _regenerator2.default.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; return (0, _get3.default)(ColonyClient.prototype.__proto__ || Object.getPrototypeOf(ColonyClient.prototype), 'init', this).call(this); case 2: if (this.tokenClient instanceof _index4.default) { _context.next = 6; break; } _context.next = 5; return this.getTokenClient(); case 5: this.tokenClient = _context.sent; case 6: _context.next = 8; return this.getVersion.call(); case 8: _ref3 = _context.sent; version = _ref3.version; if (!(version > _constants.MAX_VERSION)) { _context.next = 12; break; } throw new Error('Only versions ' + _constants.MAX_VERSION + ' and below are supported'); case 12: return _context.abrupt('return', this); case 13: case 'end': return _context.stop(); } } }, _callee, this); })); function init() { return _ref2.apply(this, arguments); } return init; }() }, { key: 'isMetaColony', value: function isMetaColony() { return this._query.contractName === 'IMetaColony'; } }, { key: '_addMetaColonyOnlyError', value: function _addMetaColonyOnlyError(propName) { Object.assign(this, (0, _defineProperty3.default)({}, propName, function () { throw new Error('"' + propName + '" is only available for the MetaColony'); })); } }, { key: 'addMetaColonySender', value: function addMetaColonySender(name, def) { return this.isMetaColony() ? this.addSender(name, def) : this._addMetaColonyOnlyError(name); } /* Get an initialized TokenClient. */ }, { key: 'getTokenClient', value: function () { var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2() { var _ref5, tokenAddress, tokenClient; return _regenerator2.default.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return this.getTokenAddress.call(); case 2: _ref5 = _context2.sent; tokenAddress = _ref5.address; tokenClient = new this.constructor.TokenClient({ adapter: this.adapter, query: { contractAddress: tokenAddress }, verbose: this.verbose }); _context2.next = 7; return tokenClient.init(); case 7: return _context2.abrupt('return', tokenClient); case 8: case 'end': return _context2.stop(); } } }, _callee2, this); })); function getTokenClient() { return _ref4.apply(this, arguments); } return getTokenClient; }() }, { key: 'initializeContractMethods', value: function initializeContractMethods() { var _this2 = this; (0, _addRecoveryMethods2.default)(this); // Custom callers this.getTask = new _GetTask2.default({ client: this }); this.getExtensionAddress = new _GetExtensionAddress2.default({ client: this, name: 'getExtensionAddress', functionName: 'deployedExtensions', input: [['contractName', 'string']] }); // Custom senders this.addExpenditure = new _AddExpenditure2.default({ client: this, name: 'addExpenditure', functionName: 'makeExpenditure', input: [['permissionDomainId', 'number'], ['childSkillIndex', 'number'], ['domainId', 'number']], defaultValues: { domainId: _constants.DEFAULT_DOMAIN_ID }, permissions: [{ childSkillIndexNames: ['childSkillIndex'], domainIds: ['domainId'], permissionDomainIdName: 'permissionDomainId', roles: [_constants.COLONY_ROLE_ADMINISTRATION] }] }); this.addExtension = new _AddExtension2.default({ client: this, name: 'addExtension', functionName: 'deployExtension', input: [['contractName', 'string']] }); this.addPayment = new _AddPayment2.default({ client: this, name: 'addPayment', functionName: 'addPayment', input: [['permissionDomainId', 'number'], ['childSkillIndex', 'number'], ['recipient', 'address'], ['token', 'anyAddress'], ['amount', 'bigNumber'], ['domainId', 'number'], ['skillId', 'number']], defaultValues: { domainId: _constants.DEFAULT_DOMAIN_ID, skillId: 0 }, permissions: [{ childSkillIndexNames: ['childSkillIndex'], domainIds: ['domainId'], permissionDomainIdName: 'permissionDomainId', roles: [_constants.COLONY_ROLE_ADMINISTRATION] }] }); this.addTask = new _AddTask2.default({ client: this, name: 'addTask', functionName: 'makeTask', input: [['permissionDomainId', 'number'], ['childSkillIndex', 'number'], ['specificationHash', 'ipfsHash'], ['domainId', 'number'], ['skillId', 'number'], ['dueDate', 'date']], defaultValues: { domainId: _constants.DEFAULT_DOMAIN_ID, skillId: 0, dueDate: new Date(0) }, permissions: [{ childSkillIndexNames: ['childSkillIndex'], domainIds: ['domainId'], permissionDomainIdName: 'permissionDomainId', roles: [_constants.COLONY_ROLE_ADMINISTRATION] }] }); this.makePayment = new _MakePayment2.default({ client: this, name: 'makePayment', functionName: 'makePayment', input: [ // permission proof for OneTX contract ['permissionDomainId', 'number'], ['childSkillIndex', 'number'], // permission proof for caller (user who calls the extension) ['callerPermissionDomainId', 'number'], ['callerChildSkillIndex', 'number'], ['recipient', 'address'], ['token', 'anyAddress'], ['amount', 'bigNumber'], ['domainId', 'number'], ['skillId', 'number']], defaultValues: { domainId: _constants.DEFAULT_DOMAIN_ID, skillId: 0 }, permissions: [{ address: function () { var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3() { var _ref7, address; return _regenerator2.default.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return _this2.getExtensionAddress.call({ contractName: 'OneTxPayment' }); case 2: _ref7 = _context3.sent; address = _ref7.address; return _context3.abrupt('return', address); case 5: case 'end': return _context3.stop(); } } }, _callee3, _this2); })); function address() { return _ref6.apply(this, arguments); } return address; }(), childSkillIndexNames: ['childSkillIndex'], domainIds: ['domainId'], permissionDomainIdName: 'permissionDomainId', roles: [_constants.COLONY_ROLE_ADMINISTRATION, _constants.COLONY_ROLE_FUNDING] }, { childSkillIndexNames: ['callerChildSkillIndex'], domainIds: ['domainId'], permissionDomainIdName: 'callerPermissionDomainId', roles: [_constants.COLONY_ROLE_ADMINISTRATION, _constants.COLONY_ROLE_FUNDING] }] }); this.makePaymentFundedFromDomain = new _MakePaymentFundedFromDomain2.default({ client: this, name: 'makePaymentFundedFromDomain', functionName: 'makePaymentFundedFromDomain', input: [ // permission proof for OneTX contract ['permissionDomainId', 'number'], ['childSkillIndex', 'number'], // permission proof for caller (user who calls the extension) ['callerPermissionDomainId', 'number'], ['callerChildSkillIndex', 'number'], ['recipient', 'address'], ['token', 'anyAddress'], ['amount', 'bigNumber'], ['domainId', 'number'], ['skillId', 'number']], defaultValues: { domainId: _constants.DEFAULT_DOMAIN_ID, skillId: 0 }, permissions: [{ address: function () { var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4() { var _ref9, address; return _regenerator2.default.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _context4.next = 2; return _this2.getExtensionAddress.call({ contractName: 'OneTxPayment' }); case 2: _ref9 = _context4.sent; address = _ref9.address; return _context4.abrupt('return', address); case 5: case 'end': return _context4.stop(); } } }, _callee4, _this2); })); function address() { return _ref8.apply(this, arguments); } return address; }(), childSkillIndexNames: ['childSkillIndex'], domainIds: ['domainId'], permissionDomainIdName: 'permissionDomainId', roles: [_constants.COLONY_ROLE_ADMINISTRATION, _constants.COLONY_ROLE_FUNDING] }, { childSkillIndexNames: ['callerChildSkillIndex'], domainIds: ['domainId'], permissionDomainIdName: 'callerPermissionDomainId', roles: [_constants.COLONY_ROLE_ADMINISTRATION, _constants.COLONY_ROLE_FUNDING] }] }); this.removeExtension = new _RemoveExtension2.default({ client: this, name: 'removeExtension', functionName: 'removeExtension', input: [['contractName', 'string']] }); this.setAdminRole = new _SetAdminRole2.default({ client: this, name: 'setAdminRole', functionName: 'setAdminRole', input: [['address', 'address'], ['setTo', 'boolean']] }); this.setFounderRole = new _SetFounderRole2.default({ client: this, name: 'setFounderRole', functionName: 'setFounderRole', input: [['address', 'address']] }); this.addDomain = new _DomainAuth2.default({ client: this, name: 'addDomain', functionName: 'addDomain', input: [['permissionDomainId', 'number'], ['childSkillIndex', 'number'], ['parentDomainId', 'number']], permissions: [{ childSkillIndexNames: ['childSkillIndex'], domainIds: ['parentDomainId'], permissionDomainIdName: 'permissionDomainId', roles: [_constants.COLONY_ROLE_ARCHITECTURE] }] }); this.finalizePayment = new _DomainAuth2.default({ client: this, name: 'finalizePayment', functionName: 'finalizePayment', input: [['permissionDomainId', 'number'], ['childSkillIndex', 'number'], ['paymentId', 'number']], permissions: [{ childSkillIndexNames: ['childSkillIndex'], domainIds: function () { var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(_ref10) { var paymentId = _ref10.paymentId; var _ref12, domainId; return _regenerator2.default.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: _context5.next = 2; return _this2.getPayment.call({ paymentId: paymentId }); case 2: _ref12 = _context5.sent; domainId = _ref12.domainId; return _context5.abrupt('return', [domainId]); case 5: case 'end': return _context5.stop(); } } }, _callee5, _this2); })); function domainIds(_x) { return _ref11.apply(this, arguments); } return domainIds; }(), permissionDomainIdName: 'permissionDomainId', roles: [_constants.COLONY_ROLE_ADMINISTRATION] }] }); this.moveFundsBetweenPots = new _DomainAuth2.default({ client: this, name: 'moveFundsBetweenPots', functionName: 'moveFundsBetweenPots', input: [['permissionDomainId', 'number'], ['fromChildSkillIndex', 'number'], ['toChildSkillIndex', 'number'], ['fromPot', 'number'], ['toPot', 'number'], ['amount', 'bigNumber'], ['token', 'anyAddress']], permissions: [{ childSkillIndexNames: ['fromChildSkillIndex', 'toChildSkillIndex'], domainIds: function () { var _ref14 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(_ref13) { var fromPot = _ref13.fromPot, toPot = _ref13.toPot; return _regenerator2.default.wrap(function _callee6$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: _context6.next = 2; return (0, _DomainAuth.getDomainIdFromPot)(fromPot, _this2); case 2: _context6.t0 = _context6.sent; _context6.next = 5; return (0, _DomainAuth.getDomainIdFromPot)(toPot, _this2); case 5: _context6.t1 = _context6.sent; return _context6.abrupt('return', [_context6.t0, _context6.t1]); case 7: case 'end': return _context6.stop(); } } }, _callee6, _this2); })); function domainIds(_x2) { return _ref14.apply(this, arguments); } return domainIds; }(), permissionDomainIdName: 'permissionDomainId', roles: [_constants.COLONY_ROLE_FUNDING] }] }); this.setAdministrationRole = new _DomainAuth2.default({ client: this, name: 'setAdministrationRole', functionName: 'setAdministrationRole', input: [['permissionDomainId', 'number'], ['childSkillIndex', 'number'], ['address', 'address'], ['domainId', 'number'], ['setTo', 'boolean']], permissions: [{ childSkillIndexNames: ['childSkillIndex'], domainIds: ['domainId'], permissionDomainIdName: 'permissionDomainId', roles: [_constants.COLONY_ROLE_ARCHITECTURE] // TODO: also should allow COLONY_ROLE_ROOT }] }); this.setArchitectureRole = new _DomainAuth2.default({ client: this, name: 'setArchitectureRole', functionName: 'setArchitectureRole', input: [['permissionDomainId', 'number'], ['childSkillIndex', 'number'], ['address', 'address'], ['domainId', 'number'], ['setTo', 'boolean']], permissions: [{ childSkillIndexNames: ['childSkillIndex'], domainIds: ['domainId'], permissionDomainIdName: 'permissionDomainId', roles: [_constants.COLONY_ROLE_ARCHITECTURE] // TODO: also should allow COLONY_ROLE_ROOT }] }); this.setExpenditureClaimDelay = new _DomainAuth2.default({ client: this, name: 'SetExpenditureClaimDelay', functionName: 'setExpenditureClaimDelay', input: [['permissionDomainId', 'number'], ['childSkillIndex', 'number'], ['expenditureId', 'number'], ['slot', 'bigNumber'], ['claimDelay', 'bigNumber']], permissions: [{ childSkillIndexNames: ['childSkillIndex'], domainIds: function () { var _ref16 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(_ref15) { var expenditureId = _ref15.expenditureId; var _ref17, domainId; return _regenerator2.default.wrap(function _callee7$(_context7) { while (1) { switch (_context7.prev = _context7.next) { case 0: _context7.next = 2; return _this2.getExpenditure.call({ expenditureId: expenditureId }); case 2: _ref17 = _context7.sent; domainId = _ref17.domainId; return _context7.abrupt('return', [domainId]); case 5: case 'end': return _context7.stop(); } } }, _callee7, _this2); })); function domainIds(_x3) { return _ref16.apply(this, arguments); } return domainIds; }(), permissionDomainIdName: 'permissionDomainId', roles: [_constants.COLONY_ROLE_ARBITRATION] }] }); this.setExpenditurePayoutModifier = new _DomainAuth2.default({ client: this, name: 'SetExpenditurePayoutModifier', functionName: 'setExpenditurePayoutModifier', input: [['permissionDomainId', 'number'], ['childSkillIndex', 'number'], ['expenditureId', 'number'], ['slot', 'bigNumber'], ['payoutModifier', 'bigNumber']], permissions: [{ childSkillIndexNames: ['childSkillIndex'], domainIds: function () { var _ref19 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(_ref18) { var expenditureId = _ref18.expenditureId; var _ref20, domainId; return _regenerator2.default.wrap(function _callee8$(_context8) { while (1) { switch (_context8.prev = _context8.next) { case 0: _context8.next = 2; return _this2.getExpenditure.call({ expenditureId: expenditureId }); case 2: _ref20 = _context8.sent; domainId = _ref20.domainId; return _context8.abrupt('return', [domainId]); case 5: case 'end': return _context8.stop(); } } }, _callee8, _this2); })); function domainIds(_x4) { return _ref19.apply(this, arguments); } return domainIds; }(), permissionDomainIdName: 'permissionDomainId', roles: [_constants.COLONY_ROLE_ARBITRATION] }] }); this.setFundingRole = new _DomainAuth2.default({ client: this, name: 'setFundingRole', functionName: 'setFundingRole', input: [['permissionDomainId', 'number'], ['childSkillIndex', 'number'], ['address', 'address'], ['domainId', 'number'], ['setTo', 'boolean']], permissions: [{ childSkillIndexNames: ['childSkillIndex'], domainIds: ['domainId'], permissionDomainIdName: 'permissionDomainId', roles: [_constants.COLONY_ROLE_ARCHITECTURE] // TODO: also should allow COLONY_ROLE_ROOT }] }); this.setPaymentPayout = new _DomainAuth2.default({ client: this, name: 'setPaymentPayout', functionName: 'setPaymentPayout', input: [['permissionDomainId', 'number'], ['childSkillIndex', 'number'], ['paymentId', 'number'], ['token', 'anyAddress'], ['amount', 'bigNumber']], permissions: [{ childSkillIndexNames: ['childSkillIndex'], domainIds: function () { var _ref22 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(_ref21) { var paymentId = _ref21.paymentId; var _ref23, domainId; return _regenerator2.default.wrap(function _callee9$(_context9) { while (1) { switch (_context9.prev = _context9.next) { case 0: _context9.next = 2; return _this2.getPayment.call({ paymentId: paymentId }); case 2: _ref23 = _context9.sent; domainId = _ref23.domainId; return _context9.abrupt('return', [domainId]); case 5: case 'end': return _context9.stop(); } } }, _callee9, _this2); })); function domainIds(_x5) { return _ref22.apply(this, arguments); } return domainIds; }(), permissionDomainIdName: 'permissionDomainId', roles: [_constants.COLONY_ROLE_ADMINISTRATION] }] }); this.setPaymentRecipient = new _DomainAuth2.default({ client: this, name: 'setPaymentRecipient', functionName: 'setPaymentRecipient', input: [['permissionDomainId', 'number'], ['childSkillIndex', 'number'], ['paymentId', 'number'], ['recipient', 'address']], permissions: [{ childSkillIndexNames: ['childSkillIndex'], domainIds: function () { var _ref25 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(_ref24) { var paymentId = _ref24.paymentId; var _ref26, domainId; return _regenerator2.default.wrap(function _callee10$(_context10) { while (1) { switch (_context10.prev = _context10.next) { case 0: _context10.next = 2; return _this2.getPayment.call({ paymentId: paymentId }); case 2: _ref26 = _context10.sent; domainId = _ref26.domainId; return _context10.abrupt('return', [domainId]); case 5: case 'end': return _context10.stop(); } } }, _callee10, _this2); })); function domainIds(_x6) { return _ref25.apply(this, arguments); } return domainIds; }(), permissionDomainIdName: 'permissionDomainId', roles: [_constants.COLONY_ROLE_ADMINISTRATION] }] }); this.setPaymentSkill = new _DomainAuth2.default({ client: this, name: 'setPaymentSkill', functionName: 'setPaymentSkill', input: [['permissionDomainId', 'number'], ['childSkillIndex', 'number'], ['paymentId', 'number'], ['skillId', 'number']], permissions: [{ childSkillIndexNames: ['childSkillIndex'], domainIds: function () { var _ref28 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(_ref27) { var paymentId = _ref27.paymentId; var _ref29, domainId; return _regenerator2.default.wrap(function _callee11$(_context11) { while (1) { switch (_context11.prev = _context11.next) { case 0: _context11.next = 2; return _this2.getPayment.call({ paymentId: paymentId }); case 2: _ref29 = _context11.sent; domainId = _ref29.domainId; return _context11.abrupt('return', [domainId]); case 5: case 'end': return _context11.stop(); } } }, _callee11, _this2); })); function domainIds(_x7) { return _ref28.apply(this, arguments); } return domainIds; }(), permissionDomainIdName: 'permissionDomainId', roles: [_constants.COLONY_ROLE_ADMINISTRATION] }] }); this.transferExpenditure = new _TransferExpenditure2.default({ client: this, name: 'transferExpenditure', input: [], functionName: '' }); this.transferExpenditureViaArbitration = new _DomainAuth2.default({ client: this, name: 'transferExpenditure', functionName: 'transferExpenditure(uint256,uint256,uint256,address)', input: [['permissionDomainId', 'number'], ['childSkillIndex', 'number'], ['expenditureId', 'number'], ['newOwner', 'anyAddress']], permissions: [{ childSkillIndexNames: ['childSkillIndex'], domainIds: function () { var _ref31 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12(_ref30) { var expenditureId = _ref30.expenditureId; var _ref32, domainId; return _regenerator2.default.wrap(function _callee12$(_context12) { while (1) { switch (_context12.prev = _context12.next) { case 0: _context12.next = 2; return _this2.getExpenditure.call({ expenditureId: expenditureId }); case 2: _ref32 = _context12.sent; domainId = _ref32.domainId; return _context12.abrupt('return', [domainId]); case 5: case 'end': return _context12.stop(); } } }, _callee12, _this2); })); function domainIds(_x8) { return _ref31.apply(this, arguments); } return domainIds; }(), permissionDomainIdName: 'permissionDomainId', roles: [_constants.COLONY_ROLE_ARBITRATION] }] }); this.upgrade = new _Upgrade2.default({ client: this, name: 'upgrade',