diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index c4b2538..ab998e3 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -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) {
diff --git a/src/app/globals.ts b/src/app/globals.ts
index fceae19..5bc85be 100644
--- a/src/app/globals.ts
+++ b/src/app/globals.ts
@@ -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');
diff --git a/src/app/send-tx/send-tx.component.html b/src/app/send-tx/send-tx.component.html
index 8a71e67..3803fb3 100644
--- a/src/app/send-tx/send-tx.component.html
+++ b/src/app/send-tx/send-tx.component.html
@@ -52,7 +52,7 @@
Must start with 0x!
-
+
@@ -92,6 +92,11 @@
+
+
+
+
+
diff --git a/src/app/send-tx/send-tx.component.ts b/src/app/send-tx/send-tx.component.ts
index 69a8ef6..75a7139 100644
--- a/src/app/send-tx/send-tx.component.ts
+++ b/src/app/send-tx/send-tx.component.ts
@@ -49,11 +49,12 @@ export class SendTxComponent implements OnInit {
to: ['', []],
amount: ['', []],
byteCode: [''],
- gasLimit: ['300000', []],
+ deployGasLimit: ['2000000', []],
contractAddress: ['', []],
contractAmount: ['', []],
contractABI: ['', []],
contractFunction: [''],
+ contractGasLimit: ['500000', []],
functionParameters: this.fb.array([
])
})
@@ -71,6 +72,10 @@ export class SendTxComponent implements OnInit {
return this.func && this.func.payable
}
+ functionIsConstant(): boolean {
+ return this.func && this.func.constant;
+ }
+
addFunctionParameter() {
this.functionParameters.push(this.fb.control(''));
}
@@ -240,20 +245,20 @@ export class SendTxComponent implements OnInit {
this.txForm.get('byteCode').setValidators([Validators.required]);
this.txForm.get('byteCode').updateValueAndValidity();
- this.txForm.get('gasLimit').setValidators([Validators.required]);
- this.txForm.get('gasLimit').updateValueAndValidity();
+ this.txForm.get('deployGasLimit').setValidators([Validators.required]);
+ this.txForm.get('deployGasLimit').updateValueAndValidity();
}
if (this.step === 'contract') {
console.log("setting contract validators")
this.unvalidateSend();
this.unvalidateDeploy();
- this.txForm.get('contractAddress').setValidators(null);
+ this.txForm.get('contractAddress').setValidators([Validators.required]);
this.txForm.get('contractAddress').updateValueAndValidity();
- this.txForm.get('contractABI').setValidators(null);
+ this.txForm.get('contractABI').setValidators([Validators.required]);
this.txForm.get('contractABI').updateValueAndValidity();
-
-
+ this.txForm.get('contractGasLimit').setValidators([Validators.required]);
+ this.txForm.get('contractGasLimit').updateValueAndValidity();
}
}
@@ -267,15 +272,17 @@ export class SendTxComponent implements OnInit {
unvalidateDeploy(): void {
this.txForm.get('byteCode').setValidators(null);
this.txForm.get('byteCode').updateValueAndValidity();
- this.txForm.get('gasLimit').setValidators(null);
- this.txForm.get('gasLimit').updateValueAndValidity();
+ this.txForm.get('deployGasLimit').setValidators(null);
+ this.txForm.get('deployGasLimit').updateValueAndValidity();
}
unvalidateContract(): void {
- this.txForm.get('byteCode').setValidators(null);
- this.txForm.get('byteCode').updateValueAndValidity();
- this.txForm.get('gasLimit').setValidators(null);
- this.txForm.get('gasLimit').updateValueAndValidity();
+ this.txForm.get('contractAddress').setValidators(null);
+ this.txForm.get('contractAddress').updateValueAndValidity();
+ this.txForm.get('contractABI').setValidators(null);
+ this.txForm.get('contractABI').updateValueAndValidity();
+ this.txForm.get('contractGasLimit').setValidators(null);
+ this.txForm.get('contractGasLimit').updateValueAndValidity();
}
validate(): boolean {
@@ -330,23 +337,24 @@ export class SendTxComponent implements OnInit {
let pk = this.txForm.get('privateKey').value;
this.sending = true;
let tx = {};
-
if (this.step === 'deploy') {
+ // DEPLOY ===============================================
+ let gasLimit = this.txForm.get('deployGasLimit').value;
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') {
+ // USE CONTRACT ==========================================
+ let gasLimit = this.txForm.get('contractGasLimit').value;
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;
@@ -361,7 +369,7 @@ 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")
@@ -369,7 +377,7 @@ export class SendTxComponent implements OnInit {
to: this.txForm.get('contractAddress').value,
amount: 0,
data: m.encodeABI(),
- gas: '2000000'
+ gas: gasLimit
});
} else {
console.log("Free function with parameters")
@@ -394,7 +402,8 @@ export class SendTxComponent implements OnInit {
this.sending = false;
return;
}
- tx = { to: to, value: amount, gas: '2000000' }
+ // should probably use this since we don't ask the user here: https://web3js.readthedocs.io/en/1.0/web3-eth.html#estimategas
+ tx = { to: to, value: amount, gas: '100000' }
}
console.log("TX:", tx);
this.sendAndWait(pk, tx)
diff --git a/src/environments/environment.ts b/src/environments/environment.ts
index 003a014..b7f639a 100644
--- a/src/environments/environment.ts
+++ b/src/environments/environment.ts
@@ -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
};