Skip to content

Commit 5e1f409

Browse files
committed
replace vm by self
1 parent c018c4c commit 5e1f409

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

src/components/SimpleStorage.vue

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export default {
252252
// Dial node
253253
dialNode() {
254254
// Get provider
255-
web3.setProvider(new web3.providers.HttpProvider(this.nodeUrl))
255+
web3.setProvider(this.nodeUrl)
256256
},
257257
// Get balance
258258
getBalance(address) {
@@ -261,12 +261,12 @@ export default {
261261
this.dialNode()
262262
263263
// Get balance
264-
let vm = this
264+
let self = this
265265
web3.eth.getBalance(address)
266266
.then(function(balance){
267267
console.log('Get balance: ' + balance)
268268
balance = Units.convert(balance, 'wei', 'eth')
269-
vm.balance = balance + ' Ether'
269+
self.balance = balance + ' Ether'
270270
})
271271
} else {
272272
console.log('Address not valid')
@@ -316,26 +316,26 @@ export default {
316316
var payload = contractDeploy.encodeABI();
317317
318318
// Save current this
319-
let vm = this
320-
vm.deploying = true
321-
vm.contractAddress = ''
319+
let self = this
320+
self.deploying = true
321+
self.contractAddress = ''
322322
323323
// Estimate gas price
324324
web3.eth.getGasPrice(function(gasPriceError, result) {
325325
if (gasPriceError) {
326326
console.log('Get GasPrice error: ', gasPriceError)
327-
vm.deploying = false
327+
self.deploying = false
328328
return
329329
} else{
330330
var gasPrice = result;
331331
console.log('Get GasPrice success: ', gasPrice)
332332
var gasPriceHex = web3.utils.numberToHex(gasPrice)
333333
334334
// Get nonce
335-
web3.eth.getTransactionCount(vm.address, function(nonceError, nonce) {
335+
web3.eth.getTransactionCount(self.address, function(nonceError, nonce) {
336336
if (nonceError) {
337337
console.log("Nonce error : ", nonceError)
338-
vm.deploying = false
338+
self.deploying = false
339339
return
340340
}
341341
else {
@@ -352,7 +352,7 @@ export default {
352352
gasPrice: gasPriceHex,
353353
gasLimit: gasLimitHex,
354354
value: '0x00',
355-
from: vm.address,
355+
from: self.address,
356356
data: payload
357357
}
358358
console.log("Raw Transaction: ",rawTx)
@@ -368,16 +368,16 @@ export default {
368368
web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
369369
.on('error', function(error){
370370
console.log('sendRawTransaction error : ', error)
371-
vm.deploying = false
371+
self.deploying = false
372372
})
373373
.on('transactionHash', function(transactionHash){
374374
console.log('sendRawTransaction success : ', transactionHash)
375-
vm.deployTransactionHash = transactionHash
375+
self.deployTransactionHash = transactionHash
376376
})
377377
.on('receipt', function(receipt){
378378
console.log(receipt.contractAddress)
379-
vm.contractAddress = receipt.contractAddress
380-
vm.deploying = false
379+
self.contractAddress = receipt.contractAddress
380+
self.deploying = false
381381
})
382382
.on('confirmation', function(confirmationNumber, receipt){
383383
console.log(confirmationNumber)
@@ -411,25 +411,25 @@ export default {
411411
console.log('Contract: ', contract);
412412
413413
// Save current this
414-
let vm = this
415-
vm.executing = true
414+
let self = this
415+
self.executing = true
416416
417417
// Estimate gas price
418418
web3.eth.getGasPrice(function(gasPriceError, result) {
419419
if (gasPriceError) {
420420
console.log('Get GasPrice error: ', gasPriceError)
421-
vm.executing = false
421+
self.executing = false
422422
return
423423
} else{
424424
var gasPrice = result;
425425
console.log('Get GasPrice success: ', gasPrice)
426426
var gasPriceHex = web3.utils.numberToHex(gasPrice)
427427
428428
// Get nonce
429-
web3.eth.getTransactionCount(vm.address, function(nonceError, nonce) {
429+
web3.eth.getTransactionCount(self.address, function(nonceError, nonce) {
430430
if (nonceError) {
431431
console.log("Nonce error : ", nonceError)
432-
vm.executing = false
432+
self.executing = false
433433
return
434434
}
435435
else {
@@ -438,7 +438,7 @@ export default {
438438
console.log("Nonce hex : ", nonce)
439439
440440
// Execute the smart contract method
441-
var newValue = parseInt(vm.storageValue)
441+
var newValue = parseInt(self.storageValue)
442442
var contractCallData = contract.methods.set(newValue)
443443
console.log('contractCallData : ', contractCallData)
444444
@@ -454,8 +454,8 @@ export default {
454454
gasPrice: gasPriceHex,
455455
gasLimit: gasLimitHex,
456456
value: '0x00',
457-
from: vm.address,
458-
to: vm.contractAddress,
457+
from: self.address,
458+
to: self.contractAddress,
459459
data: payload
460460
}
461461
console.log("Raw Transaction: ",rawTx)
@@ -471,15 +471,15 @@ export default {
471471
web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
472472
.on('error', function(error){
473473
console.log('sendRawTransaction error : ', error)
474-
vm.executing = false
474+
self.executing = false
475475
})
476476
.on('transactionHash', function(transactionHash){
477477
console.log('sendRawTransaction success : ', transactionHash)
478-
vm.execTransactionHash = transactionHash
478+
self.execTransactionHash = transactionHash
479479
})
480480
.on('receipt', function(receipt){
481481
console.log(receipt)
482-
vm.executing = false
482+
self.executing = false
483483
})
484484
.on('confirmation', function(confirmationNumber, receipt){
485485
console.log(confirmationNumber)
@@ -504,11 +504,11 @@ export default {
504504
// Exec contract
505505
var contract = new web3.eth.Contract(abi, this.contractAddress)
506506
console.log('start call get')
507-
let vm = this;
507+
let self = this;
508508
contract.methods.get().call().then(
509509
function (result) {
510510
console.log('Result: ' + result)
511-
vm.retreivedValue = result
511+
self.retreivedValue = result
512512
})
513513
}
514514
}

0 commit comments

Comments
 (0)