Skip to content

Commit 9727b29

Browse files
committed
security.csp.enable problem solved. Now it is not necessary disable this feature.
1 parent 7e76a87 commit 9727b29

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

Plugin/block.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
} else {
1616
createWeb3();
1717
}
18+
document.getElementById("setNet").addEventListener("click", setNetwork);
19+
document.getElementById("loginButton").addEventListener("click", Login);
20+
document.getElementById("completeFields").addEventListener("click", CompleteFields);
21+
document.getElementById("submitButton").addEventListener("click", SubmitToBlockchain);
22+
document.getElementById("checkButton").addEventListener("click", CheckIntegrity);
23+
1824

1925
function SubmitToBlockchain (){
2026

@@ -56,8 +62,8 @@
5662
var nonce = "0x" + (nonceValue).toString(16);
5763
rawtx = {
5864
nonce: nonce,
59-
gasPrice: this.web3.utils.toHex(estimatedGas),
60-
gasLimit: this.web3.utils.toHex(GasLimit),
65+
gasPrice: web3.utils.toHex(estimatedGas),
66+
gasLimit: web3.utils.toHex(GasLimit),
6167
to: contractAddress,
6268
data: bytecodeData
6369
};
@@ -67,7 +73,7 @@
6773
tx.sign(privateKey);
6874
var raw = "0x" + tx.serialize().toString("hex");
6975

70-
this.web3.eth.sendSignedTransaction(raw)
76+
web3.eth.sendSignedTransaction(raw)
7177
.once('transactionHash', function(hash){
7278
document.getElementById("comment").innerHTML = "Transaction sent, please wait til' it is mined"
7379
//Arranco el spin y el boton
@@ -217,8 +223,8 @@
217223
var nonce = "0x" + (nonceValue).toString(16);
218224
rawtx = {
219225
nonce: nonce,
220-
gasPrice: this.web3.utils.toHex(estimatedGas),
221-
gasLimit: this.web3.utils.toHex(GasLimit),
226+
gasPrice: web3.utils.toHex(estimatedGas),
227+
gasLimit: web3.utils.toHex(GasLimit),
222228
to: contractAddress,
223229
data: bytecodeData
224230
};
@@ -227,15 +233,14 @@
227233

228234
tx.sign(privateKey);
229235
var raw = "0x" + tx.serialize().toString("hex");
230-
this.web3.eth.sendSignedTransaction(raw)
236+
web3.eth.sendSignedTransaction(raw)
231237
.once('transactionHash', function(hash){
232238
document.getElementById("comment").innerHTML = "Transaction sent, please wait til' it is mined";
233239
//Arranco el spin y oculto el boton
234240
document.getElementById("spin").style.display = "block";
235241
document.getElementById("loginButton").style.display = "none";
236242
})
237243
.on('error', function(error){
238-
//console.log(error);
239244
document.getElementById("comment").innerHTML = "";
240245
document.getElementById("error").innerHTML = "Error in transaction";
241246
document.getElementById("spin").style.display = "none"
@@ -370,7 +375,6 @@
370375
}
371376

372377
function createWeb3(){
373-
console.log("func createweb3");
374378
switch (selectedNetwork) {
375379
case "Ropsten":
376380
web3 = new Web3();

Plugin/manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"16": "images/icon-16.png",
99
"128": "images/icon-128.png"
1010
},
11+
"content_security_policy": "default-src * 'unsafe-inline' 'unsafe-eval'; script-src 'self' 'unsafe-eval'; object-src 'self'; style-src 'self' 'unsafe-inline' 'unsafe-eval';",
1112
"applications": {
1213
"gecko": {
1314
"id": "webextension@block.io"

Plugin/popup.html

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
<head>
55
<meta charset="utf-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1 user-scalable=no">
7-
<meta http-equiv="Content-Security-Policy"
8-
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline';">
97
<link rel="stylesheet" type="text/css" href="main.css">
108
<script type="text/javascript" src="./web3/web3.js"></script>
119
<script type="text/javascript" src="./web3/ethereumjs-tx.js"></script>
@@ -23,18 +21,16 @@
2321
<option>MainNet</option>
2422
</select>
2523
</form>
26-
<script src="./block.js" type="text/javascript" charset="utf-8"></script>
27-
<button onclick="setNetwork()" class="boton_personalizado">Set Network</button>
24+
<input id="setNet" type="button" class="boton_personalizado" value="Set Network">
25+
2826
<hr size="1px">
2927
<p class="login">
3028
<b>Register:</b><br>
3129
<input type="password" id="pk" required minlength="64" maxlength="64" placeholder="Enter your private key"> <br>
32-
<input class="boton_personalizado" type="button" value="Login" onclick="Login()" style="display: block;"
33-
id="loginButton" />
30+
<input id="loginButton" class="boton_personalizado" type="button" value="Login" style="display: block;" />
3431
</p>
3532
<br>
36-
<input class="boton_personalizado" type="button" value="AutoComplete" onclick="CompleteFields()"
37-
style="display: block;" id="completeFields" />
33+
<button class="boton_personalizado" type="button" value="AutoComplete" style="display: block;" id="completeFields">AutoComplete</button>
3834
<br>
3935
<input type="text" id="url_id" placeholder="https://"><br>
4036
<br>
@@ -44,13 +40,13 @@
4440
<div id="spin" class="loader" style="display: none;"></div>
4541
<br>
4642
<div style="width: 200px; margin: auto;">
47-
<input class="boton_grande" style="float:left;" type="button" value="Submit&#13;&#10;message"
48-
onclick="SubmitToBlockchain()" style="display: block;" id="submitButton" />
49-
<input class="boton_grande" style="float:right;" type="button" value="Check&#13;&#10;integrity"
50-
onclick="CheckIntegrity()" style="display: block;" id="checkButton" />
43+
<input class="boton_grande" style="float:left;" type="button" value="Submit&#13;&#10;message" style="display: block;" id="submitButton" />
44+
<input class="boton_grande" style="float:right;" type="button" value="Check&#13;&#10;integrity" style="display: block;" id="checkButton" />
5145
</div>
5246
<h3 id="comment"></h3>
5347
<b id="error" style="color: red;"></b>
48+
<script src="./block.js" type="text/javascript" charset="utf-8"></script>
49+
5450
</body>
5551

5652
</html>

0 commit comments

Comments
 (0)