Skip to content
This repository has been archived by the owner on May 24, 2021. It is now read-only.

Commit

Permalink
Display bytecode validation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rowandh committed Nov 22, 2018
1 parent 38f3de6 commit 1f4e39d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ <h5 class="modal-title">{{title}}</h5>
</span>
<textarea class="form-control form-control-sm" id="contractCode" rows="5" formControlName="contractCode"
[class.is-invalid]="contractCode.invalid && (contractCode.dirty || contractCode.touched)">{{contractCode}}</textarea>
<div *ngIf="contractCode.errors" class="invalid-feedback">
<p *ngIf="contractCode.errors.hasOddNumberOfCharacters">Must have an even number of characters</p>
<p *ngIf="contractCode.errors.pattern">Must be valid hexadecimal characters</p>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export class TransactionComponent implements OnInit {
const gasLimitMaximumValidator = control => Number(control.value) > this.gasLimitMaximum ? { gasLimitTooHighError: true } : null;
const gasCallLimitMinimumValidator = control => Number(control.value) < this.gasCallLimitMinimum ? { gasCallLimitTooLowError: true } : null;
const gasCreateLimitMinimumValidator = control => Number(control.value) < this.gasCreateLimitMinimum ? { gasCreateLimitTooLowError: true } : null;
const oddValidator = control => String(control.value).length % 2 !== 0 ? { hasOddNumberOfCharacters: true } : null;

const integerValidator = Validators.pattern('^[0-9][0-9]*$');

Expand All @@ -145,7 +146,7 @@ export class TransactionComponent implements OnInit {
this.gasPrice = new FormControl(1, [Validators.required, integerValidator, Validators.pattern('^[+]?([0-9]{0,})*[.]?([0-9]{0,2})?$'), gasPriceTooLowValidator, gasPriceTooHighValidator]);
this.gasLimit = new FormControl(this.mode === Mode.Call ? this.gasCallLimitMinimum : this.gasCreateLimitMinimum, [Validators.required, integerValidator, Validators.pattern('^[+]?([0-9]{0,})*[.]?([0-9]{0,2})?$'), gasLimitValidator, gasLimitMaximumValidator]);
this.methodName = new FormControl('', [Validators.required, Validators.nullValidator]);
this.contractCode = new FormControl('', [Validators.required, Validators.nullValidator]);
this.contractCode = new FormControl('', [Validators.required, Validators.nullValidator, Validators.pattern('[0-9a-fA-F]*'), oddValidator]);
this.parameters = new FormArray([]);
this.password = new FormControl('', [Validators.required, Validators.nullValidator]);

Expand Down

0 comments on commit 1f4e39d

Please sign in to comment.