Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #296 from makerdao/feat/exec-hash
Browse files Browse the repository at this point in the history
Feat/exec hash
  • Loading branch information
rafinskipg authored Oct 13, 2021
2 parents 5733703 + 5c0b73a commit 43b6818
Show file tree
Hide file tree
Showing 3 changed files with 229 additions and 111 deletions.
297 changes: 186 additions & 111 deletions packages/dai-plugin-governance/contracts/abis/DSSpell.json
Original file line number Diff line number Diff line change
@@ -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"
}]
27 changes: 27 additions & 0 deletions packages/dai-plugin-governance/src/SpellService.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export default class SpellService extends PublicService {
this.executionDate = {};
this.scheduledDate = {};
this.nextCastTime = {};
this.executiveHash = {};
this.officeHours = {};
}

getDelayInSeconds() {
Expand Down Expand Up @@ -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(
Expand Down
16 changes: 16 additions & 0 deletions packages/dai-plugin-governance/test/SpellService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 43b6818

Please sign in to comment.