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

Commit

Permalink
Merged with dev
Browse files Browse the repository at this point in the history
  • Loading branch information
rafinskipg committed Oct 15, 2021
2 parents 47a4a9e + 58be486 commit 2d25d81
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
13 changes: 13 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,7 @@ export default class SpellService extends PublicService {
this.executionDate = {};
this.scheduledDate = {};
this.nextCastTime = {};
this.expiration = {};
this.executiveHash = {};
this.officeHours = {};
}
Expand Down Expand Up @@ -50,6 +51,18 @@ export default class SpellService extends PublicService {
return this.nextCastTime[spellAddress];
}

async getExpiration(spellAddress) {
if (this.expiration[spellAddress]) return this.expiration[spellAddress];
const spell = this.get('smartContract').getContractByAddressAndAbi(
spellAddress,
DsSpellAbi
);
const expiration = await spell.expiration();
if (!expiration.toNumber()) return undefined;
this.expiration[spellAddress] = new Date(expiration.toNumber() * 1000);
return this.expiration[spellAddress];
}

async getScheduledDate(spellAddress) {
if (this.scheduledDate[spellAddress])
return this.scheduledDate[spellAddress];
Expand Down
9 changes: 9 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,15 @@ describe('use mainnet', () => {
expect(eta).toEqual(new Date('2020-01-26T11:53:19.000Z'));
});

test('get spell expiration', async () => {
const eta = await spellService.getExpiration(
'0x9400d4D59134af2a48a4bf4237E809A80f90Fe63'
);
expect(eta).toEqual(new Date('2021-11-07T20:22:48.000Z'));
});

//TODO: add test for getNextCastTime();

test('get executive hash text', async () => {
const done = await spellService.getExecutiveHash(
'0x9400d4D59134af2a48a4bf4237E809A80f90Fe63'
Expand Down
1 change: 0 additions & 1 deletion packages/dai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"test:watch": "yarn test --watch",
"test:mainnet": "export NETWORK='mainnet' && jest --runInBand --config ./test/config/jestIntegrationConfig.json",
"test:kovan": "export NETWORK='kovan' && jest --runInBand --config ./test/config/jestIntegrationConfig.json",
"test:goerli": "export NETWORK='goerli' && jest --runInBand --config ./test/config/jestIntegrationConfig.json",
"test:integration": "export NETWORK='test' && yarn test --config ./test/config/jestIntegrationConfig.json",
"test:build": "yarn test --config ./test/config/jestBuildConfig.json",
"repl": "../../node_modules/.bin/tsc scripts/repl.ts"
Expand Down

0 comments on commit 2d25d81

Please sign in to comment.