Some small complexity/readability improvements (#1309)

* Some small complexity/readability improvements

* Bump allowed returns to 5

* Revert override (as limiting as it seems)
This commit is contained in:
Jaco Greeff
2019-08-14 20:25:20 +02:00
committed by GitHub
parent c36173c0bb
commit 9954477de3
7 changed files with 132 additions and 110 deletions
+15 -15
View File
@@ -48,23 +48,23 @@ export default class Blueprint extends RxBase {
return this.apiContracts
.create(endowment, maxGas, this.codeHash, this.abi.deploy(...params))
.signAndSend(account)
.pipe(
map((result: SubmittableResult): BlueprintCreateResult => {
let contract: RxContract | undefined;
if (result.isFinalized) {
const record = result.findRecord('contract', 'Instantiated');
if (record) {
contract = new RxContract(this.api, this.abi, record.event.data[1] as Address);
}
}
return new BlueprintCreateResult(result, contract);
})
);
.pipe(map(this.createResult));
};
return { signAndSend };
}
private createResult = (result: SubmittableResult): BlueprintCreateResult => {
let contract: RxContract | undefined;
if (result.isFinalized) {
const record = result.findRecord('contract', 'Instantiated');
if (record) {
contract = new RxContract(this.api, this.abi, record.event.data[1] as Address);
}
}
return new BlueprintCreateResult(result, contract);
}
}
+15 -15
View File
@@ -61,23 +61,23 @@ export default class RxCode extends RxBase {
return this.apiContracts
.putCode(maxGas, compactAddLength(this.code))
.signAndSend(account)
.pipe(
map((result: ISubmittableResult): CodePutCodeResult => {
let blueprint: RxBlueprint | undefined;
if (result.isFinalized) {
const record = result.findRecord('contract', 'CodeStored');
if (record) {
blueprint = new RxBlueprint(this.api, this.abi, record.event.data[0] as Hash);
}
}
return new CodePutCodeResult(result, blueprint);
})
);
.pipe(map(this.createResult));
};
return { signAndSend };
}
private createResult = (result: ISubmittableResult): CodePutCodeResult => {
let blueprint: RxBlueprint | undefined;
if (result.isFinalized) {
const record = result.findRecord('contract', 'CodeStored');
if (record) {
blueprint = new RxBlueprint(this.api, this.abi, record.event.data[0] as Hash);
}
}
return new CodePutCodeResult(result, blueprint);
}
}