diff --git a/packages/dai-plugin-governance/contracts/abis/DSSpell.json b/packages/dai-plugin-governance/contracts/abis/DSSpell.json index a0eb71ae1..a44adffeb 100644 --- a/packages/dai-plugin-governance/contracts/abis/DSSpell.json +++ b/packages/dai-plugin-governance/contracts/abis/DSSpell.json @@ -1,113 +1,188 @@ -[ - { - "inputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "constant": true, - "inputs": [], - "name": "SAIMOM", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "SCDCAP", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "action", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "cast", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "done", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "eta", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "nextCastTime", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "pause", - "outputs": [ +[{ + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" +}, +{ + "inputs": [], + "constant": true, + "name": "action", + "outputs": [ { - "internalType": "contract DSPauseAbstract", - "name": "", - "type": "address" + "internalType": "address", + "name": "", + "type": "address" } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "schedule", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "sig", - "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "tag", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "payable": false, - "stateMutability": "view", - "type": "function" - } -] + ], + "stateMutability": "view", + "type": "function" +}, +{ + "inputs": [], + "name": "cast", + "constant": false, + "payable": false, + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" +}, +{ + "inputs": [], + "name": "description", + "payable": false, + "constant": true, + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" +}, +{ + "inputs": [], + "name": "done", + "constant": true, + "payable": false, + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" +}, +{ + "inputs": [], + "name": "eta", + "constant": true, + "payable": false, + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" +}, +{ + "inputs": [], + "name": "expiration", + "constant": true, + "payable": false, + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" +}, +{ + "inputs": [], + "name": "log", + "constant": true, + "payable": false, + "outputs": [ + { + "internalType": "contract Changelog", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" +}, +{ + "inputs": [], + "payable": false, + "constant": true, + "name": "nextCastTime", + "outputs": [ + { + "internalType": "uint256", + "name": "castTime", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" +}, +{ + "inputs": [], + "payable": false, + "constant": true, + "name": "officeHours", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" +}, +{ + "inputs": [], + "payable": false, + "constant": true, + "name": "pause", + "outputs": [ + { + "internalType": "contract PauseAbstract", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" +}, +{ + "inputs": [], + "payable": false, + "constant": false, + "name": "schedule", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" +}, +{ + "inputs": [], + "name": "sig", + "payable": false, + "constant": true, + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" +}, +{ + "inputs": [], + "name": "tag", + "payable": false, + "constant": true, + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" +}] \ No newline at end of file diff --git a/packages/dai-plugin-governance/src/SpellService.js b/packages/dai-plugin-governance/src/SpellService.js index 91c94d9c9..e961da45d 100644 --- a/packages/dai-plugin-governance/src/SpellService.js +++ b/packages/dai-plugin-governance/src/SpellService.js @@ -16,6 +16,8 @@ export default class SpellService extends PublicService { this.executionDate = {}; this.scheduledDate = {}; this.nextCastTime = {}; + this.executiveHash = {}; + this.officeHours = {}; } getDelayInSeconds() { @@ -80,6 +82,31 @@ export default class SpellService extends PublicService { return this.done[spellAddress]; } + async getExecutiveHash(spellAddress) { + if (this.executiveHash[spellAddress]) + return this.executiveHash[spellAddress]; + const spell = this.get('smartContract').getContractByAddressAndAbi( + spellAddress, + DsSpellAbi + ); + this.executiveHash[spellAddress] = spell.description().then(description => { + return description.substr(description.indexOf('0x'), description.length); + }); + + return this.executiveHash[spellAddress]; + } + + async getOfficeHours(spellAddress) { + if (this.officeHours[spellAddress]) return this.officeHours[spellAddress]; + const spell = this.get('smartContract').getContractByAddressAndAbi( + spellAddress, + DsSpellAbi + ); + this.officeHours[spellAddress] = spell.officeHours(); + + return this.officeHours[spellAddress]; + } + async getAction(spellAddress) { if (this.action[spellAddress]) return this.action[spellAddress]; const spell = this.get('smartContract').getContractByAddressAndAbi( diff --git a/packages/dai-plugin-governance/test/SpellService.test.js b/packages/dai-plugin-governance/test/SpellService.test.js index 517fce0a5..656921a3a 100644 --- a/packages/dai-plugin-governance/test/SpellService.test.js +++ b/packages/dai-plugin-governance/test/SpellService.test.js @@ -52,6 +52,22 @@ describe('use mainnet', () => { expect(eta).toEqual(new Date('2020-01-26T11:53:19.000Z')); }); + test('get executive hash text', async () => { + const done = await spellService.getExecutiveHash( + '0x9400d4D59134af2a48a4bf4237E809A80f90Fe63' + ); + expect(done).toBe( + '0xe1126241f8df6e094363eac12a5c4620f0dbf54c4d7da7fa94f5b8dd499e30d2' + ); + }); + + test('get office hours', async () => { + const done = await spellService.getOfficeHours( + '0x9400d4D59134af2a48a4bf4237E809A80f90Fe63' + ); + expect(done).toBe(true); + }); + test('get spell done boolean', async () => { const done = await spellService.getDone( '0xf880d43bb9a32dd212c77b82a7336be31ecaee08'