Skip to content

Commit

Permalink
demo pages. Recreate web3 instance with new endpoint when Sign button…
Browse files Browse the repository at this point in the history
… clicked
  • Loading branch information
dtaipov committed Jan 30, 2019
1 parent caa3248 commit 013ce2b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions docs/eth_signer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h6>Documentation: <a href="https://github.com/arrayio/array-io-keychain/wiki/Ho
<div class="container">
<div class="form-group">
<label class="form-label" for="input-endpoint">Endpoint</label>
<input class="form-input" type="text" id="input-endpoint" disabled value="https://rinkeby.infura.io/v3/6e07edb991d64b9197996b7ff174de42" />
<input class="form-input" type="text" id="input-endpoint" value="https://rinkeby.infura.io/v3/6e07edb991d64b9197996b7ff174de42" />
</div>
<div class="form-group">
<label class="form-label" for="input-to-address">To address</label>
Expand Down Expand Up @@ -71,10 +71,6 @@ <h6>Documentation: <a href="https://github.com/arrayio/array-io-keychain/wiki/Ho

window.onload = function () {
let web3;
// const endpoint = 'https://ropsten.infura.io/v3/046804e3dd3240b09834531326f310cf';
// const endpoint = 'https://rinkeby.infura.io/v3/6e07edb991d64b9197996b7ff174de42';
const endpoint = document.getElementById('input-endpoint').value;
web3 = new Web3(new Web3.providers.HttpProvider(endpoint));
const valueTx = 100;
let keychain;
web3override.Keychain.create()
Expand All @@ -90,8 +86,8 @@ <h6>Documentation: <a href="https://github.com/arrayio/array-io-keychain/wiki/Ho
// };
//
document.getElementById('btn_SIGN').addEventListener('click', function() {
// const endpoint = document.getElementById('input-endpoint').value;
// web3 = new Web3(new Web3.providers.HttpProvider(endpoint)); // todo set web3 to KeyChain on Sign button click
const endpoint = document.getElementById('input-endpoint').value;
web3 = new Web3(new Web3.providers.HttpProvider(endpoint));
const toAddress = document.getElementById('input-to-address').value;
let publicKey;

Expand Down Expand Up @@ -128,6 +124,7 @@ <h6>Documentation: <a href="https://github.com/arrayio/array-io-keychain/wiki/Ho
const result = await web3.eth.sendSignedTransaction(rawHexGlobal);
document.getElementById('progress').style.display = 'none';
log(`Transfer result: \n${JSON.stringify(result, undefined, 2)}`);
const endpoint = document.getElementById('input-endpoint').value;
const prefix = endpoint.indexOf('rinkeby') !== -1 ? 'rinkeby' : 'ropsten';
document.getElementById('etherscanLink').innerHTML = `<a href='https://${prefix}.etherscan.io/tx/${result.transactionHash}'>Etherscan Link</a>`;
} catch (e) {
Expand Down

0 comments on commit 013ce2b

Please sign in to comment.