Skip to content

Commit 1c8e55f

Browse files
author
Micah Zoltu
authored
Merge pull request #514 from AugurProject/micah
Minor improvements.
2 parents 44b757f + edc4566 commit 1c8e55f

File tree

4 files changed

+35
-21
lines changed

4 files changed

+35
-21
lines changed

source/libraries/ContractInterfaces.ts

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,13 @@ export class Augur extends Controlled {
367367
return <boolean>result[0];
368368
}
369369

370+
public isKnownUniverse_ = async(universe: string, options?: { sender?: string }): Promise<boolean> => {
371+
options = options || {};
372+
const abi: AbiFunction = {"constant":true,"inputs":[{"name":"_universe","type":"address"}],"name":"isKnownUniverse","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"};
373+
const result = await this.localCall(abi, [universe], options.sender);
374+
return <boolean>result[0];
375+
}
376+
370377
public logFeeWindowCreated = async(feeWindow: string, id: BN, options?: { sender?: string, gasPrice?: BN }): Promise<string> => {
371378
options = options || {};
372379
const abi: AbiFunction = {"constant":false,"inputs":[{"name":"_feeWindow","type":"address"},{"name":"_id","type":"uint256"}],"name":"logFeeWindowCreated","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"};
@@ -471,13 +478,6 @@ export class Augur extends Controlled {
471478
return <boolean>result[0];
472479
}
473480

474-
public isKnownUniverse_ = async(universe: string, options?: { sender?: string }): Promise<boolean> => {
475-
options = options || {};
476-
const abi: AbiFunction = {"constant":true,"inputs":[{"name":"_universe","type":"address"}],"name":"isKnownUniverse","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"};
477-
const result = await this.localCall(abi, [universe], options.sender);
478-
return <boolean>result[0];
479-
}
480-
481481
public createChildUniverse = async(parentPayoutDistributionHash: string, options?: { sender?: string, gasPrice?: BN }): Promise<string> => {
482482
options = options || {};
483483
const abi: AbiFunction = {"constant":false,"inputs":[{"name":"_parentPayoutDistributionHash","type":"bytes32"}],"name":"createChildUniverse","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"};
@@ -4014,16 +4014,16 @@ export class CancelOrder extends Controlled {
40144014
return <boolean>result[0];
40154015
}
40164016

4017-
public cancelOrder = async(orderId: string, type: BN, market: string, outcome: BN, options?: { sender?: string, gasPrice?: BN }): Promise<string> => {
4017+
public cancelOrder = async(orderId: string, options?: { sender?: string, gasPrice?: BN }): Promise<string> => {
40184018
options = options || {};
4019-
const abi: AbiFunction = {"constant":false,"inputs":[{"name":"_orderId","type":"bytes32"},{"name":"_type","type":"uint8"},{"name":"_market","type":"address"},{"name":"_outcome","type":"uint8"}],"name":"cancelOrder","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"};
4020-
return await this.remoteCall(abi, [orderId, type, market, outcome], options.sender, options.gasPrice);
4019+
const abi: AbiFunction = {"constant":false,"inputs":[{"name":"_orderId","type":"bytes32"}],"name":"cancelOrder","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"};
4020+
return await this.remoteCall(abi, [orderId], options.sender, options.gasPrice);
40214021
}
40224022

4023-
public cancelOrder_ = async(orderId: string, type: BN, market: string, outcome: BN, options?: { sender?: string }): Promise<boolean> => {
4023+
public cancelOrder_ = async(orderId: string, options?: { sender?: string }): Promise<boolean> => {
40244024
options = options || {};
4025-
const abi: AbiFunction = {"constant":false,"inputs":[{"name":"_orderId","type":"bytes32"},{"name":"_type","type":"uint8"},{"name":"_market","type":"address"},{"name":"_outcome","type":"uint8"}],"name":"cancelOrder","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"};
4026-
const result = await this.localCall(abi, [orderId, type, market, outcome], options.sender);
4025+
const abi: AbiFunction = {"constant":false,"inputs":[{"name":"_orderId","type":"bytes32"}],"name":"cancelOrder","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"};
4026+
const result = await this.localCall(abi, [orderId], options.sender);
40274027
return <boolean>result[0];
40284028
}
40294029

@@ -5190,6 +5190,19 @@ export class ShareToken extends Controlled {
51905190
return <boolean>result[0];
51915191
}
51925192

5193+
public trustedCancelOrderTransfer = async(source: string, destination: string, attotokens: BN, options?: { sender?: string, gasPrice?: BN }): Promise<string> => {
5194+
options = options || {};
5195+
const abi: AbiFunction = {"constant":false,"inputs":[{"name":"_source","type":"address"},{"name":"_destination","type":"address"},{"name":"_attotokens","type":"uint256"}],"name":"trustedCancelOrderTransfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"};
5196+
return await this.remoteCall(abi, [source, destination, attotokens], options.sender, options.gasPrice);
5197+
}
5198+
5199+
public trustedCancelOrderTransfer_ = async(source: string, destination: string, attotokens: BN, options?: { sender?: string }): Promise<boolean> => {
5200+
options = options || {};
5201+
const abi: AbiFunction = {"constant":false,"inputs":[{"name":"_source","type":"address"},{"name":"_destination","type":"address"},{"name":"_attotokens","type":"uint256"}],"name":"trustedCancelOrderTransfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"};
5202+
const result = await this.localCall(abi, [source, destination, attotokens], options.sender);
5203+
return <boolean>result[0];
5204+
}
5205+
51935206
public getOutcome_ = async( options?: { sender?: string }): Promise<BN> => {
51945207
options = options || {};
51955208
const abi: AbiFunction = {"constant":true,"inputs":[],"name":"getOutcome","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"};

source/libraries/ContractInterfacesGenerator.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ ${contractMethods.join("\n\n")}
134134
const argNames: String = this.getArgNamesString(abiFunction);
135135
const params: String = this.getParamsString(abiFunction);
136136
const options: String = `{ sender?: string${abiFunction.payable ? ", attachedEth?: BN" : ""} }`;
137-
const returnType: String = this.getTsTypeFromPrimitive(abiFunction.outputs[0].type);
138-
const returnPromiseType: String = abiFunction.outputs.length == 1 ? returnType : "Array<string>";
137+
const returnType: String = (abiFunction.outputs[0] !== undefined) ? this.getTsTypeFromPrimitive(abiFunction.outputs[0].type) : "void";
138+
const returnPromiseType: String = (abiFunction.outputs.length === 0 || abiFunction.outputs.length === 1) ? returnType : "Array<string>";
139139
const returnValue: String = abiFunction.outputs.length == 1 ? `<${returnType}>result[0]` : "<Array<string>>result";
140140
return ` public ${abiFunction.name}_ = async(${params} options?: ${options}): Promise<${returnPromiseType}> => {
141141
options = options || {};
142142
const abi: AbiFunction = ${JSON.stringify(abiFunction)};
143-
const result = await this.localCall(abi, [${argNames}], options.sender${abiFunction.payable ? ", options.attachedEth" : ""});
144-
return ${returnValue};
143+
${abiFunction.outputs.length !== 0 ? 'const result = ' : ''}await this.localCall(abi, [${argNames}], options.sender${abiFunction.payable ? ", options.attachedEth" : ""});
144+
${abiFunction.outputs.length !== 0 ? `return ${returnValue};` : ''}
145145
}`;
146146
}
147147

source/tools/generateContractInterfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
22

3+
require('source-map-support').install();
34
import { ContractCompiler } from "../libraries/ContractCompiler";
45
import { Configuration } from '../libraries/Configuration';
56
import { ContractInterfaceGenerator } from '../libraries/ContractInterfacesGenerator';

support/test/integration/docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ services:
1414
dockerfile: support/Dockerfile
1515
cache_from:
1616
- augurproject/augur-core:latest
17-
entrypoint: [ "npm", "run", "test:integration"]
17+
entrypoint: [ "npm", "run", "test:integration" ]
1818
# uncomment the following 3 lines to enable debugging the tests
19-
# command: [ "--debug=0.0.0.0:9229", "--inspect-brk" ]
19+
# command: [ "--", "--debug=0.0.0.0:9229", "--inspect-brk" ]
2020
# ports:
2121
# - "9229:9229"
2222
environment:
@@ -38,9 +38,9 @@ services:
3838
dockerfile: support/Dockerfile
3939
cache_from:
4040
- augurproject/augur-core:latest
41-
entrypoint: [ "npx", "mocha", "output/tests-integration/**/*.js", "--no-timeouts", "--require", "source-map-support/register"]
41+
entrypoint: [ "npm", "run", "test:integration" ]
4242
# uncomment the following 3 lines to enable debugging the tests
43-
# command: [ "--debug=0.0.0.0:9229", "--inspect-brk" ]
43+
command: [ "--", "--debug=0.0.0.0:9229", "--inspect-brk" ]
4444
# ports:
4545
# - "9229:9229"
4646
environment:

0 commit comments

Comments
 (0)