Skip to content

Commit

Permalink
Fixes gas limit, wasn't using the form field on deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
treeder committed Dec 20, 2018
1 parent ba62d88 commit 06ee5d5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/app/app.component.ts
Expand Up @@ -11,7 +11,7 @@ import { environment } from '../environments/environment';
})
export class AppComponent {
title = 'GoChain Wallet';
public version: string = environment.VERSION;
public version: string = this.globals.version;
public network: string;

constructor(private globals: Globals, private walletService: WalletService, public router: Router) {
Expand Down
1 change: 1 addition & 0 deletions src/app/globals.ts
Expand Up @@ -4,6 +4,7 @@ import { environment } from '../environments/environment';
@Injectable()
export class Globals {
network: string = 'mainnet';
version: string = '1.1.20'

constructor() {
let nw = localStorage.getItem('network');
Expand Down
16 changes: 7 additions & 9 deletions src/app/send-tx/send-tx.component.ts
Expand Up @@ -42,7 +42,7 @@ export class SendTxComponent implements OnInit {
to: ['', []],
amount: ['', []],
byteCode: [''],
gasLimit: ['300000', []],
gasLimit: ['500000', []],
contractAddress: ['', []],
contractAmount: ['', []],
contractABI: ['', []],
Expand Down Expand Up @@ -323,23 +323,21 @@ export class SendTxComponent implements OnInit {
let pk = this.txForm.get('privateKey').value;
this.sending = true;
let tx = {};

let gasLimit = this.txForm.get('gasLimit').value;
if (this.step === 'deploy') {
let byteCode = this.txForm.get('byteCode').value;
if (!byteCode.startsWith("0x")) {
byteCode = '0x' + byteCode;
}
tx = { data: byteCode, gas: '2000000' }
tx = { data: byteCode, gas: gasLimit }
} else if (this.step === 'contract') {
let params: string[] = [];
if (this.func.inputs.length > 0) {
for (var control of this.functionParameters.controls) {
params.push(control.value);
}
}
let m = this.contract.methods[this.func.name](...params);
console.log("method:", m);
console.log("m.encode:", m.encodeABI());
let m = this.contract.methods[this.func.name](...params);
if (this.func.payable) {
console.log("Payable function")
let amount = this.txForm.get('contractAmount').value;
Expand All @@ -354,15 +352,15 @@ export class SendTxComponent implements OnInit {
Object.assign(tx, tx, {
to: this.txForm.get('contractAddress').value,
data: m.encodeABI(),
gas: '2000000'
gas: gasLimit
});
} else if (this.func.constant == false) {
console.log("Non-constant function with parameters")
Object.assign(tx, tx, {
to: this.txForm.get('contractAddress').value,
amount: 0,
data: m.encodeABI(),
gas: '2000000'
gas: gasLimit
});
} else {
console.log("Free function with parameters")
Expand All @@ -387,7 +385,7 @@ export class SendTxComponent implements OnInit {
this.sending = false;
return;
}
tx = { to: to, value: amount, gas: '2000000' }
tx = { to: to, value: amount, gas: gasLimit }
}
console.log("TX:", tx);
this.sendAndWait(pk, tx)
Expand Down
3 changes: 1 addition & 2 deletions src/environments/environment.ts
Expand Up @@ -4,6 +4,5 @@
// The list of which env maps to which file can be found in `.angular-cli.json`.

export const environment = {
production: false,
VERSION: "1.1.20"
production: false
};

0 comments on commit 06ee5d5

Please sign in to comment.