Skip to content
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

Refactor/dependencies #198

Merged
merged 22 commits into from Jul 31, 2019
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Fixing loose typing issues.

  • Loading branch information
Freydal committed Jul 30, 2019
commit 700be836550ddf47780f38f6950b64e43c106f94
@@ -117,7 +117,7 @@ export class KosuToken {
*/
public async transfer(to: string, value: BigNumber): Promise<TransactionReceiptWithDecodedLogs> {
const contract = await this.getContract();
return contract.transfer.awaitTransactionSuccessAsync(to, value);
return contract.transfer.awaitTransactionSuccessAsync(to, new BigNumber(value.toString()));
}

/**
@@ -130,7 +130,7 @@ export class KosuToken {
*/
public async transferFrom(from: string, to: string, value: BigNumber): Promise<TransactionReceiptWithDecodedLogs> {
const contract = await this.getContract();
return contract.transferFrom.awaitTransactionSuccessAsync(from, to, value);
return contract.transferFrom.awaitTransactionSuccessAsync(from, to, new BigNumber(value.toString()));
}

/**
@@ -142,7 +142,7 @@ export class KosuToken {
*/
public async approve(spender: string, value: BigNumber): Promise<TransactionReceiptWithDecodedLogs> {
const contract = await this.getContract();
return contract.approve.awaitTransactionSuccessAsync(spender, value);
return contract.approve.awaitTransactionSuccessAsync(spender, new BigNumber(value.toString()));
}

/**
@@ -165,7 +165,7 @@ export class KosuToken {
*/
public async estimateEtherToToken(etherInput: BigNumber): Promise<BigNumber> {
const contract = await this.getContract();
return contract.estimateEtherToToken.callAsync(etherInput);
return contract.estimateEtherToToken.callAsync(new BigNumber(etherInput.toString()));
}

/**
@@ -176,7 +176,7 @@ export class KosuToken {
*/
public async estimateTokenToEther(tokensToBurn: BigNumber): Promise<BigNumber> {
const contract = await this.getContract();
return contract.estimateTokenToEther.callAsync(tokensToBurn);
return contract.estimateTokenToEther.callAsync(new BigNumber(tokensToBurn.toString()));
}

/**
@@ -188,7 +188,7 @@ export class KosuToken {
*/
public async bondTokens(value: BigNumber, minPayout: BigNumber): Promise<TransactionReceiptWithDecodedLogs> {
const contract = await this.getContract();
return contract.bondTokens.awaitTransactionSuccessAsync(minPayout, { value });
return contract.bondTokens.awaitTransactionSuccessAsync(new BigNumber(minPayout.toString()), { value: new BigNumber(value.toString()) });
}

/**
@@ -199,7 +199,7 @@ export class KosuToken {
*/
public async releaseTokens(tokensToBurn: BigNumber): Promise<TransactionReceiptWithDecodedLogs> {
const contract = await this.getContract();
return contract.releaseTokens.awaitTransactionSuccessAsync(tokensToBurn);
return contract.releaseTokens.awaitTransactionSuccessAsync(new BigNumber(tokensToBurn.toString()));
}

/**
@@ -211,7 +211,7 @@ export class KosuToken {
public async pay(value: BigNumber): Promise<TransactionReceiptWithDecodedLogs> {
const contract = await this.getContract();
return this.web3Wrapper
.sendTransactionAsync({ from: await this.web3.eth.getCoinbase(), to: contract.address, value, gas: 70000 })
.sendTransactionAsync({ from: await this.web3.eth.getCoinbase(), to: contract.address, value: new BigNumber(value.toString()), gas: 70000 })
.then(async txHash => this.web3Wrapper.awaitTransactionSuccessAsync(txHash));
}
}
@@ -126,7 +126,7 @@ export class PosterRegistry {
}
}

return contract.registerTokens.awaitTransactionSuccessAsync(amount);
return contract.registerTokens.awaitTransactionSuccessAsync(parsed);
}

/**
@@ -137,7 +137,7 @@ export class PosterRegistry {
*/
public async releaseTokens(amount: BigNumber): Promise<TransactionReceiptWithDecodedLogs> {
const contract = await this.getContract();
return contract.releaseTokens.awaitTransactionSuccessAsync(amount);
return contract.releaseTokens.awaitTransactionSuccessAsync(new BigNumber(amount.toString()));
}

/**
@@ -149,7 +149,7 @@ export class PosterRegistry {
public async pay(value: BigNumber): Promise<TransactionReceiptWithDecodedLogs> {
const contract = await this.getContract();
return this.web3Wrapper
.sendTransactionAsync({ from: await this.web3.eth.getCoinbase(), to: contract.address, value, gas: 220000 })
.sendTransactionAsync({ from: await this.web3.eth.getCoinbase(), to: contract.address, value: new BigNumber(value.toString()), gas: 220000 })
.then(async txHash => this.web3Wrapper.awaitTransactionSuccessAsync(txHash));
}
}
@@ -111,7 +111,7 @@ export class Treasury {
await this.kosuToken.approve(this.address, value);
}

return contract.deposit.awaitTransactionSuccessAsync(value);
return contract.deposit.awaitTransactionSuccessAsync(new BigNumber(value.toString()));
}

/**
@@ -129,7 +129,7 @@ export class Treasury {
*/
public async withdraw(value: BigNumber): Promise<TransactionReceiptWithDecodedLogs> {
const contract = await this.getContract();
return contract.withdraw.awaitTransactionSuccessAsync(value);
return contract.withdraw.awaitTransactionSuccessAsync(new BigNumber(value.toString()));
}

/**
@@ -209,7 +209,7 @@ export class Treasury {
*/
public async approveTreasury(value: BigNumber): Promise<TransactionReceiptWithDecodedLogs> {
const contract = await this.getContract();
return this.kosuToken.approve(contract.address, value);
return this.kosuToken.approve(contract.address, new BigNumber(value.toString()));
}

/**
@@ -221,7 +221,7 @@ export class Treasury {
public async pay(value: BigNumber): Promise<TransactionReceiptWithDecodedLogs> {
const contract = await this.getContract();
return this.web3Wrapper
.sendTransactionAsync({ from: await this.web3.eth.getCoinbase(), to: contract.address, value, gas: 120000 })
.sendTransactionAsync({ from: await this.web3.eth.getCoinbase(), to: contract.address, value: new BigNumber(value.toString()), gas: 120000 })
.then(async txHash => this.web3Wrapper.awaitTransactionSuccessAsync(txHash));
}
}
@@ -179,7 +179,7 @@ export class ValidatorRegistry {
*/
public async getChallenge(challengeId: BigNumber): Promise<Challenge> {
const contract = await this.getContract();
return contract.getChallenge.callAsync(challengeId);
return contract.getChallenge.callAsync(new BigNumber(challengeId.toString()));
}

/**
@@ -221,15 +221,15 @@ export class ValidatorRegistry {
const maxRewardRate = await this.maxRewardRate();

if (systemBalance.lt(_tokensToStake)) {
const tokensShort = _tokensToStake.minus(systemBalance);
const tokensShort = new BigNumber(_tokensToStake.toString()).minus(systemBalance);
await this.treasury.deposit(tokensShort);
}

if (maxRewardRate.lt(_rewardRate)) {
throw new Error(`Reward rate: ${_rewardRate.toString()} exceeds maxmimum of ${maxRewardRate.toString()}`);
}

return contract.registerListing.awaitTransactionSuccessAsync(_pubKey, _tokensToStake, _rewardRate, _details);
return contract.registerListing.awaitTransactionSuccessAsync(_pubKey, new BigNumber(_tokensToStake.toString()), new BigNumber(_rewardRate.toString()), _details);
}

/**
@@ -309,7 +309,7 @@ export class ValidatorRegistry {
*/
public async claimWinnings(challengeId: BigNumber): Promise<TransactionReceiptWithDecodedLogs> {
const contract = await this.getContract();
return contract.claimWinnings.awaitTransactionSuccessAsync(challengeId);
return contract.claimWinnings.awaitTransactionSuccessAsync(new BigNumber(challengeId.toString()));
}

/**
@@ -73,13 +73,13 @@ export class Voting {

const systemBalance = await this.treasury.systemBalance(this.coinbase);
if (systemBalance.lt(_tokensToCommit)) {
const tokensShort = _tokensToCommit.minus(systemBalance);
const tokensShort = new BigNumber(_tokensToCommit.toString()).minus(systemBalance);
await this.treasury.deposit(tokensShort);
}

// tslint:disable-next-line: no-console
console.log(`Committing vote ${_vote} with ${_tokensToCommit} DIGM tokens`);
return contract.commitVote.awaitTransactionSuccessAsync(_pollId, _vote, _tokensToCommit);
return contract.commitVote.awaitTransactionSuccessAsync(new BigNumber(_pollId.toString()), _vote, new BigNumber(_tokensToCommit.toString()));
}

/**
@@ -95,7 +95,7 @@ export class Voting {
_voteSalt: BigNumber,
): Promise<TransactionReceiptWithDecodedLogs> {
const contract = await this.getContract();
return contract.revealVote.awaitTransactionSuccessAsync(_pollId, _voteOption, _voteSalt);
return contract.revealVote.awaitTransactionSuccessAsync(new BigNumber(_pollId.toString()), new BigNumber(_voteOption.toString()), new BigNumber(_voteSalt.toString()));
}

/**
@@ -105,7 +105,7 @@ export class Voting {
*/
public async winningOption(_pollId: BigNumber): Promise<BigNumber> {
const contract = await this.getContract();
return contract.winningOption.callAsync(_pollId);
return contract.winningOption.callAsync(new BigNumber(_pollId.toString()));
}

/**
@@ -115,7 +115,7 @@ export class Voting {
*/
public async totalWinningTokens(_pollId: BigNumber): Promise<BigNumber> {
const contract = await this.getContract();
return contract.totalWinningTokens.callAsync(_pollId);
return contract.totalWinningTokens.callAsync(new BigNumber(_pollId.toString()));
}

/**
@@ -125,7 +125,7 @@ export class Voting {
*/
public async totalRevealedTokens(_pollId: BigNumber): Promise<BigNumber> {
const contract = await this.getContract();
return contract.totalRevealedTokens.callAsync(_pollId);
return contract.totalRevealedTokens.callAsync(new BigNumber(_pollId.toString()));
}

/**
@@ -136,7 +136,7 @@ export class Voting {
*/
public async userWinningTokens(_pollId: BigNumber, _userAddress: string = this.coinbase): Promise<BigNumber> {
const contract = await this.getContract();
return contract.userWinningTokens.callAsync(_pollId, _userAddress);
return contract.userWinningTokens.callAsync(new BigNumber(_pollId.toString()), _userAddress);
}

/**
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.