-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Simon Mok
committed
Sep 3, 2018
1 parent
69174e9
commit a78f073
Showing
25 changed files
with
16,857 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* cyrillic-ext */ | ||
@font-face { | ||
font-family: 'Open Sans'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://fonts.gstatic.com/s/opensans/v15/mem8YaGs126MiZpBA-UFWJ0bbck.woff2) format('woff2'); | ||
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; | ||
} | ||
/* cyrillic */ | ||
@font-face { | ||
font-family: 'Open Sans'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://fonts.gstatic.com/s/opensans/v15/mem8YaGs126MiZpBA-UFUZ0bbck.woff2) format('woff2'); | ||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; | ||
} | ||
/* greek-ext */ | ||
@font-face { | ||
font-family: 'Open Sans'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://fonts.gstatic.com/s/opensans/v15/mem8YaGs126MiZpBA-UFWZ0bbck.woff2) format('woff2'); | ||
unicode-range: U+1F00-1FFF; | ||
} | ||
/* greek */ | ||
@font-face { | ||
font-family: 'Open Sans'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://fonts.gstatic.com/s/opensans/v15/mem8YaGs126MiZpBA-UFVp0bbck.woff2) format('woff2'); | ||
unicode-range: U+0370-03FF; | ||
} | ||
/* vietnamese */ | ||
@font-face { | ||
font-family: 'Open Sans'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://fonts.gstatic.com/s/opensans/v15/mem8YaGs126MiZpBA-UFWp0bbck.woff2) format('woff2'); | ||
unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB; | ||
} | ||
/* latin-ext */ | ||
@font-face { | ||
font-family: 'Open Sans'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://fonts.gstatic.com/s/opensans/v15/mem8YaGs126MiZpBA-UFW50bbck.woff2) format('woff2'); | ||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; | ||
} | ||
/* latin */ | ||
@font-face { | ||
font-family: 'Open Sans'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: local('Open Sans Regular'), local('OpenSans-Regular'), url(https://fonts.gstatic.com/s/opensans/v15/mem8YaGs126MiZpBA-UFVZ0b.woff2) format('woff2'); | ||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; | ||
} | ||
/* cyrillic-ext */ | ||
@font-face { | ||
font-family: 'Open Sans'; | ||
font-style: normal; | ||
font-weight: 700; | ||
src: local('Open Sans Bold'), local('OpenSans-Bold'), url(https://fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN7rgOX-hpOqc.woff2) format('woff2'); | ||
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; | ||
} | ||
/* cyrillic */ | ||
@font-face { | ||
font-family: 'Open Sans'; | ||
font-style: normal; | ||
font-weight: 700; | ||
src: local('Open Sans Bold'), local('OpenSans-Bold'), url(https://fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN7rgOVuhpOqc.woff2) format('woff2'); | ||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; | ||
} | ||
/* greek-ext */ | ||
@font-face { | ||
font-family: 'Open Sans'; | ||
font-style: normal; | ||
font-weight: 700; | ||
src: local('Open Sans Bold'), local('OpenSans-Bold'), url(https://fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN7rgOXuhpOqc.woff2) format('woff2'); | ||
unicode-range: U+1F00-1FFF; | ||
} | ||
/* greek */ | ||
@font-face { | ||
font-family: 'Open Sans'; | ||
font-style: normal; | ||
font-weight: 700; | ||
src: local('Open Sans Bold'), local('OpenSans-Bold'), url(https://fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN7rgOUehpOqc.woff2) format('woff2'); | ||
unicode-range: U+0370-03FF; | ||
} | ||
/* vietnamese */ | ||
@font-face { | ||
font-family: 'Open Sans'; | ||
font-style: normal; | ||
font-weight: 700; | ||
src: local('Open Sans Bold'), local('OpenSans-Bold'), url(https://fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN7rgOXehpOqc.woff2) format('woff2'); | ||
unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB; | ||
} | ||
/* latin-ext */ | ||
@font-face { | ||
font-family: 'Open Sans'; | ||
font-style: normal; | ||
font-weight: 700; | ||
src: local('Open Sans Bold'), local('OpenSans-Bold'), url(https://fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN7rgOXOhpOqc.woff2) format('woff2'); | ||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; | ||
} | ||
/* latin */ | ||
@font-face { | ||
font-family: 'Open Sans'; | ||
font-style: normal; | ||
font-weight: 700; | ||
src: local('Open Sans Bold'), local('OpenSans-Bold'), url(https://fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN7rgOUuhp.woff2) format('woff2'); | ||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,53 @@ | ||
$(document).ready(function() { | ||
requireJS.require(['settings', 'web3', 'jquery'], function (settings) { | ||
|
||
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); | ||
$(document).ready(function () { | ||
|
||
if (web3.isConnected()) { | ||
var web3 = new Web3(new Web3.providers.HttpProvider(settings.provider)); | ||
|
||
console.log('Web3 successfully connected'); | ||
var issuerAccount = web3.eth.accounts[1]; | ||
var abiDefinition = [{"constant":true,"inputs":[{"name":"_address","type":"address"}],"name":"getIssuerName","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_address","type":"address"}],"name":"getStudentName","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getIssuerCertificates","outputs":[{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"listStudentAddresses","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_address","type":"address"}],"name":"getIssuerDetails","outputs":[{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"student","type":"address"},{"name":"courseTitle","type":"string"},{"name":"completionDate","type":"string"},{"name":"expiryDate","type":"string"}],"name":"createCertificate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"index","type":"uint256"}],"name":"getCertificateDetails","outputs":[{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"},{"name":"_name","type":"string"},{"name":"_issuerAddress","type":"string"},{"name":"_logoUrl","type":"string"}],"name":"createIssuer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"},{"name":"_name","type":"string"}],"name":"createStudent","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"listIssuerAddresses","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getStudentCertificates","outputs":[{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"student","type":"address"},{"name":"issuer","type":"address"},{"name":"courseTitle","type":"string"}],"name":"verifyCertificate","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]; | ||
var contractAddress = '0x64ec4b719fa6b1fb835b7212e1973236be746989'; | ||
var masterContract = web3.eth.contract(abiDefinition); | ||
var contractInstance = masterContract.at(contractAddress); | ||
web3.eth.defaultAccount = issuerAccount; | ||
if (web3.isConnected()) { | ||
|
||
try { | ||
var issuerName = contractInstance.getIssuerName(issuerAccount); | ||
$('h1').html('Create Certificate - ' + issuerName); | ||
} catch (e) { | ||
console.log(e); | ||
$('.alert-danger').html('Issuer not found.').show(); | ||
} | ||
console.log('Web3 successfully connected'); | ||
var issuerAccount = web3.eth.accounts[1]; | ||
var masterContract = web3.eth.contract(settings.abiDefinition); | ||
var contractInstance = masterContract.at(settings.contractAddress); | ||
web3.eth.defaultAccount = issuerAccount; | ||
|
||
try { | ||
var issuerName = contractInstance.getIssuerName(issuerAccount); | ||
$('h1').html('Create Certificate - ' + issuerName); | ||
} catch (e) { | ||
console.log(e); | ||
$('.alert-danger').html('Issuer not found.').show(); | ||
} | ||
|
||
$('form').submit(function (event) { | ||
$('.alert-danger, .alert-success').hide(); | ||
var courseTitle = $("#course-title").val(); | ||
var completionDate = $("#completion-date").val(); | ||
var expiryDate = $("#expiry-date").val(); | ||
var address = $("#address").val(); | ||
var index = web3.eth.accounts.indexOf(address); | ||
$('form').submit(function (event) { | ||
$('.alert-danger, .alert-success').hide(); | ||
var courseTitle = $("#course-title").val(); | ||
var completionDate = $("#completion-date").val(); | ||
var expiryDate = $("#expiry-date").val(); | ||
var address = $("#address").val(); | ||
var index = web3.eth.accounts.indexOf(address); | ||
|
||
if (index < 0) { | ||
$('.alert-danger').html('Account address not found.').show(); | ||
console.log('Valid addresses', web3.eth.accounts); | ||
} else { | ||
try { | ||
var estimatedGas = contractInstance.createCertificate.estimateGas(address, courseTitle, completionDate, expiryDate); | ||
contractInstance.createCertificate(address, courseTitle, completionDate, expiryDate, {from: issuerAccount, gas: estimatedGas}); | ||
$('.alert-success').show(); | ||
$('#course-title, #completion-date, #expiry-date, #address').val(''); | ||
} catch (e) { | ||
console.log(e); | ||
$('.alert-danger').html('Error occurred.').show(); | ||
if (index < 0) { | ||
$('.alert-danger').html('Account address not found.').show(); | ||
console.log('Valid addresses', web3.eth.accounts); | ||
} else { | ||
try { | ||
var estimatedGas = contractInstance.createCertificate.estimateGas(address, courseTitle, completionDate, expiryDate); | ||
contractInstance.createCertificate(address, courseTitle, completionDate, expiryDate, {from: issuerAccount, gas: estimatedGas}); | ||
$('.alert-success').show(); | ||
$('#course-title, #completion-date, #expiry-date, #address').val(''); | ||
} catch (e) { | ||
console.log(e); | ||
$('.alert-danger').html('Error occurred.').show(); | ||
} | ||
} | ||
} | ||
|
||
event.preventDefault(); | ||
}); | ||
} else { | ||
$('form').prepend('<div class="alert alert-danger">Blockchain not connected</div>'); | ||
$(':submit').prop('disabled', true); | ||
} | ||
event.preventDefault(); | ||
}); | ||
} else { | ||
$('form').prepend('<div class="alert alert-danger">Blockchain not connected</div>'); | ||
$(':submit').prop('disabled', true); | ||
} | ||
}); | ||
}); |
Oops, something went wrong.