Skip to content

mods for [email protected] #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
414 changes: 215 additions & 199 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"webpack-dev-server": "^2.11.1"
},
"dependencies": {
"@daostack/arc.js": "0.0.0-alpha.105",
"@daostack/arc.js": "0.0.0-alpha.106",
"arrive": "^2.4.1",
"aurelia-animator-css": "^1.0.4",
"aurelia-bootstrapper": "^2.1.1",
Expand Down
8 changes: 2 additions & 6 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ import { autoinject } from 'aurelia-framework';
import { Router, RouterConfiguration } from 'aurelia-router';
import { PLATFORM } from 'aurelia-pal';
import { Web3Service } from "./services/Web3Service";
import { ArcService } from "./services/ArcService";
import '../static/styles.scss';
import { AureliaConfiguration } from 'aurelia-configuration';
import { BindingSignaler } from "aurelia-templating-resources";
import { runInThisContext } from "vm";
import { EventAggregator } from "aurelia-event-aggregator";
import { Utils } from "services/utils";
import { DateService } from "services/DateService";

@autoinject
export class App {
Expand All @@ -20,19 +17,18 @@ export class App {
private intervalId: any;

constructor(
private web3: Web3Service
private web3Service: Web3Service
, private signaler: BindingSignaler
, private eventAggregator: EventAggregator
, appConfig: AureliaConfiguration
, private web3Service: Web3Service
) {
App.timezone = appConfig.get("rootTimezone");
}

activate() {
this.intervalId = setInterval(async () => {
this.signaler.signal('secondPassed');
if (this.web3.isConnected) {
if (this.web3Service.isConnected) {
const blockDate = await Utils.lastBlockDate(this.web3Service.web3);
this.eventAggregator.publish("secondPassed", blockDate);
}
Expand Down
4 changes: 2 additions & 2 deletions src/resources/customElements/TokenBalance/TokenBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class TokenBalance {

if (this.token) {

const token = await this.tokenService.getStandardToken(this.token);
const token = await this.tokenService.getErc20Token(this.token);

if (token) {
this.getBalance(token);
Expand All @@ -69,7 +69,7 @@ export class TokenBalance {
}
async getBalance(token) {
try {
this.balance = (await this.tokenService.getUserStandardTokenBalance(token, true)).toFixed(2);
this.balance = (await this.tokenService.getUserErc20TokenBalance(token, true)).toFixed(2);
this.text = this.balance.toString();
} catch {
}
Expand Down
18 changes: 2 additions & 16 deletions src/schemeDashboards/Auction4Reputation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { autoinject } from 'aurelia-framework';
import { DaoSchemeDashboard } from "./schemeDashboard"
import { EventAggregator } from 'aurelia-event-aggregator';
import { WrapperService, Address, Auction4ReputationWrapper, StandardTokenWrapper, Auction4ReputationBidEventResult } from "../services/ArcService";
import { WrapperService, Address, Auction4ReputationWrapper, Erc20Wrapper, Auction4ReputationBidEventResult } from "../services/ArcService";
import { BigNumber, Web3Service } from '../services/Web3Service';
import { SchemeDashboardModel } from 'schemeDashboards/schemeDashboardModel';
import { EventConfigTransaction, EventConfigException, EventConfigFailure } from 'entities/GeneralEvents';
Expand All @@ -15,8 +15,7 @@ export class Auction4Reputation extends DaoSchemeDashboard {
protected wrapper: Auction4ReputationWrapper;
auctionsStartTime: Date;
auctionsEndTime: Date;
token: StandardTokenWrapper;
auctionId: number = -1;
token: Erc20Wrapper;
auctionIsOver: boolean;
auctionNotBegun: boolean;
refreshing: boolean = false;
Expand Down Expand Up @@ -185,17 +184,4 @@ export class Auction4Reputation extends DaoSchemeDashboard {

this.bidding = false;
}

// async _userHasBid(auctionId: number): Promise<void> {
// this.userHasBid = (await this.wrapper.getBid(this.web3Service.defaultAccount, auctionId)).gt(0);
// }

// async _totalBids(auctionId: number): Promise<BigNumber> {
// let totalBids = new BigNumber(0);
// const numAuctions = await this.wrapper.getNumberOfAuctions();
// for (let auctionId = 0; auctionId < numAuctions; ++auctionId) {
// totalBids.add(await this.wrapper.getAuctionTotalBid(auctionId));
// }
// return totalBids;
// }
}
4 changes: 2 additions & 2 deletions src/schemeDashboards/LockingToken4Reputation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { autoinject } from 'aurelia-framework';
import { LockingToken4ReputationWrapper, StandardTokenFactory, StandardTokenWrapper, TokenLockingOptions, LockInfo, Address } from "../services/ArcService";
import { LockingToken4ReputationWrapper, Erc20Factory, Erc20Wrapper, TokenLockingOptions, LockInfo, Address } from "../services/ArcService";
import { Locking4Reputation } from 'schemeDashboards/Locking4Reputation';
import { EventAggregator } from "aurelia-event-aggregator";
import { Web3Service } from "services/Web3Service";
Expand Down Expand Up @@ -49,7 +49,7 @@ export class LockingToken4Reputation extends Locking4Reputation {

if (!(await this.getLockBlocker())) {

const token = (await StandardTokenFactory.at(this.selectedToken.address)) as StandardTokenWrapper;
const token = (await Erc20Factory.at(this.selectedToken.address)) as Erc20Wrapper;

await (await token.approve({
owner: this.lockModel.lockerAddress,
Expand Down
24 changes: 12 additions & 12 deletions src/services/TokenService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { autoinject } from "aurelia-framework";
import { Web3Service, BigNumber } from "./Web3Service";
import { ArcService, Address, StandardTokenWrapper, Utils, DaoTokenWrapper, WrapperService } from './ArcService';
import { ArcService, Address, Erc20Wrapper, Utils, DaoTokenWrapper, WrapperService } from './ArcService';

@autoinject
export class TokenService {
Expand All @@ -22,12 +22,12 @@ export class TokenService {
* in Wei by default
* @param tokenAddress
*/
public async getUserStandardTokenBalance(
token: StandardTokenWrapper,
public async getUserErc20TokenBalance(
token: Erc20Wrapper,
inEth: boolean = false): Promise<BigNumber> {

let userAddress = this.web3.defaultAccount;
return this.getStandardTokenBalance(token, userAddress, inEth);
return this.getErc20TokenBalance(token, userAddress, inEth);
}

public async getUserTokenBalance(
Expand All @@ -39,8 +39,8 @@ export class TokenService {
return this.getTokenBalance(tokenAddress, userAddress, inEth);
}

public async getStandardTokenBalance(
token: StandardTokenWrapper,
public async getErc20TokenBalance(
token: Erc20Wrapper,
accountAddress: Address,
inEth: boolean = false): Promise<BigNumber> {

Expand All @@ -56,13 +56,13 @@ export class TokenService {
accountAddress: Address,
inEth: boolean = false): Promise<BigNumber> {

const token = await this.getStandardToken(tokenAddress);
const token = await this.getErc20Token(tokenAddress);

if (!token) {
return new BigNumber(0);
}

return this.getStandardTokenBalance(token, accountAddress, inEth);
return this.getErc20TokenBalance(token, accountAddress, inEth);
}

public getGenTokenBalance(): Promise<BigNumber | undefined> {
Expand All @@ -75,13 +75,13 @@ export class TokenService {
}
}

public async getGlobalGenToken(): Promise<StandardTokenWrapper | undefined> {
public async getGlobalGenToken(): Promise<Erc20Wrapper | undefined> {
const address = await Utils.getGenTokenAddress();
return this.getStandardToken(address);
return this.getErc20Token(address);
}


public getStandardToken(address: Address): Promise<StandardTokenWrapper> {
return WrapperService.factories.StandardToken.at(address);
public getErc20Token(address: Address): Promise<Erc20Wrapper> {
return WrapperService.factories.Erc20.at(address);
}
}
6 changes: 3 additions & 3 deletions src/services/lockServices.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Locking4ReputationWrapper, Address, LockerInfo, LockInfo } from "services/ArcService";
import { LockingToken4ReputationWrapper, StandardTokenWrapper } from "@daostack/arc.js";
import { LockingToken4ReputationWrapper, Erc20Wrapper } from "@daostack/arc.js";
import { AureliaConfiguration } from "aurelia-configuration";
import { BigNumber } from "bignumber.js";

Expand All @@ -25,9 +25,9 @@ export class LockService {
return fetcher.get();
}

public async getUserLockedTokens(): Promise<Array<StandardTokenWrapper>> {
public async getUserLockedTokens(): Promise<Array<Erc20Wrapper>> {
const locks = await this.getUserLocks();
const tokens = new Array<StandardTokenWrapper>();
const tokens = new Array<Erc20Wrapper>();
const tokenWrapper = (this.wrapper as LockingToken4ReputationWrapper);
for (const lock of locks) {
const token = await tokenWrapper.getTokenForLock(lock.lockId);
Expand Down
2 changes: 2 additions & 0 deletions static/_landing.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
}

.landing-page .countdown {
padding-left: 1rem;
padding-right: 1rem;
font-size:3rem;
text-align: center;
margin-bottom: 4rem;
Expand Down
25 changes: 14 additions & 11 deletions static/app-config.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"rootTimezone": "Asia/Tel_Aviv",
"lockingPeriodStartDate": "2019-02-18T00:00:00.000",
"lockingPeriodEndDate": "2019-03-21T00:00:00.000",
"governanceStartDate": "2019-04-04T00:00:00.000",
"lockingPeriodStartDate": "2019-02-18T12:00:00.000",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this times are for the dapp or landing page ?
If for dapp , why not read it from the contracts ?

Copy link
Contributor Author

@dkent600 dkent600 Jan 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the default when not specified in the other setting sections below it.

The contract dashboards do not use these hard-coded settings at all (except for one special case in the externalLocking dashboard where it has to know the global starting date). The hard-coded settings are for everything except the contract dashboards.

Copy link
Contributor Author

@dkent600 dkent600 Jan 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undertaking the suggestion of pulling the start/end dates from one of the contracts, we would have to choose one contract from which to obtain the dates. There would be no gaurantee it will have the right dates nor be consistent with the other contracts.

The following is what in the UI would be affected:

  1. the locking period end date that is shown in text on the dashboard page
  2. when the "reputation you have earned" section becomes visible
  3. when the "Register" button becomes visible in the MGN dashboard

(Not much.)

A wrong date will be immediately and easily spotted, and I so far see no advantage in testing.

I am not convinced this is worth spending any more time on.

"lockingPeriodEndDate": "2019-03-20T12:00:00.000",
"governanceStartDate": "2019-04-04T12:00:00.000",
"Landing": {
"lockingPeriodStartDate": "2019-02-18T00:00:00.000",
"lockingPeriodEndDate": "2019-03-21T00:00:00.000",
"governanceStartDate": "2019-04-04T00:00:00.000"
"lockingPeriodStartDate": "2019-02-18T12:00:00.000",
"lockingPeriodEndDate": "2019-03-20T12:00:00.000",
"governanceStartDate": "2019-04-04T12:00:00.000"
},
"Ganache": {
"daoAddress": "0xcb4e66eca663fdb61818d52a152601ca6afef74f",
Expand All @@ -23,10 +23,10 @@
]
},
"Kovan": {
"lockingPeriodStartDate": "2018-11-01T00:00:00.000",
"lockingPeriodEndDate": "2019-03-21T00:00:00.000",
"governanceStartDate": "2019-04-04T00:00:00.000",
"daoAddress": "0x9b055567ae152cf14e19b285d4cdd35ff6b58260",
"lockingPeriodStartDate": "2019-01-09T12:00:00.000",
"lockingPeriodEndDate": "2019-01-10T18:00:00.000",
"governanceStartDate": "2019-01-11T12:00:00.000",
"daoAddress": "0xc0e7580aba695453f3a18b7deb9b1e0d52da8265",
"gnoTokenAddress": "0x6018bf616ec9db02f90c8c8529ddadc10a5c29dc",
"lockableTokens": [
{
Expand All @@ -44,7 +44,10 @@
]
},
"Rinkeby": {
"daoAddress": "0x4Ceb1d7C144E06b8cD36225A7559897Cb0c6D64c",
"lockingPeriodStartDate": "2019-01-09T12:00:00.000",
"lockingPeriodEndDate": "2019-01-10T18:00:00.000",
"governanceStartDate": "2019-01-11T12:00:00.000",
"daoAddress": "0xbb491d151ff2ae050a24357a3916bb04a3e07d44",
"gnoTokenAddress": "0xd0dab4e640d95e9e8a47545598c33e31bdb53c7c",
"lockableTokens": [
{
Expand Down
19 changes: 10 additions & 9 deletions test/unit/app.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { App } from '../../src/app';
import { PLATFORM } from 'aurelia-pal';
import { BindingSignaler } from "aurelia-templating-resources";
import { EventAggregator } from "aurelia-event-aggregator";

class RouterStub {
routes;
Expand Down Expand Up @@ -27,26 +29,25 @@ describe('the App module', () => {
defaultAccount: {}
};

let fakeArcService = {
arcContracts: []
};

let fakeAppConfigService = {
get: (name: string): string => { return ""; }
};

app = new App(fakeWeb3Service as any, fakeArcService as any, fakeAppConfigService as any);
app = new App(
fakeWeb3Service as any,
{} as BindingSignaler,
{} as EventAggregator,
fakeAppConfigService as any);
app.configureRouter(mockedRouter, mockedRouter);
});

it('contains a router property', () => {
expect(app.router).toBeDefined();
});

// commented-out until Aurelia fixes its d.ts to reference title:
// it('configures the router title', () => {
// expect(app.router.title).toEqual('DAOstack DxBootStrapper');
// });
it('configures the router title', () => {
expect(app.router.title).toEqual('DutchX Initializer');
});

it('should have a dashboard route', () => {
expect(app.router.routes).toContainEqual({ route: ['dashboard/:address?'], name: 'dashboard', moduleId: PLATFORM.moduleName('./organizations/dashboard'), nav: false, title: 'Dashboard' });
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ module.exports = ({ production, server, extractCss, coverage } = {}) => {
// filter ABI contract files
new webpack.ContextReplacementPlugin(
/@daostack[/\\]arc.js[/\\]migrated_contracts$/,
/Controller.json|Avatar.json|DAOToken.json|Reputation.json|StandardToken.json|Auction4Reputation.json|ExternalLocking4Reputation.json|Locking4Reputation.json|LockingEth4Reputation.json|LockingToken4Reputation.json|BasicToken.json/),
/Controller.json|Avatar.json|DAOToken.json|Reputation.json|ERC20.json|Auction4Reputation.json|ExternalLocking4Reputation.json|Locking4Reputation.json|LockingEth4Reputation.json|LockingToken4Reputation.json/),
...when(extractCss, new ExtractTextPlugin({
filename: production ? '[contenthash].css' : '[id].css',
allChunks: true,
Expand Down