diff --git a/docs/offline.html b/docs/offline.html index f3ac43d..09370a4 100644 --- a/docs/offline.html +++ b/docs/offline.html @@ -46,7 +46,7 @@ ERC-20 ERC-721 Messages - Wallet Tool + diff --git a/docs/wallettool.html b/docs/wallettool.html index 2010db4..7182163 100644 --- a/docs/wallettool.html +++ b/docs/wallettool.html @@ -41,15 +41,7 @@ WalletTool:TopSecrets - Addresses - ETH - ERC-20 - ERC-721 - Messages - Wallet Tool - - - + @@ -92,294 +84,6 @@ - - - - - - - - - - - Generate Random - - - - - - - - - -
-
-
-
- -
-
- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - Add - - - - - - - - - - - Generate Random - - - - - - - - - - - - - - - Add - - - - - - - - - - - - - - Load - - - - - - - - - - - - - - - - - - Add - - - - - - - - - - - - - - - - - - - - - - - Add - - - Update - Delete - - - - - -
-
-
-
- - - New Wallet From Mnemonic - New Wallet From Private Key - New Wallet From Keystore - New Address - -
-
-
-
- {{ commify0(addresses.length) }} -
-
- -
-
- -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Test - - - - - - TODO: ERC-20 Functions - approve, transfer, transferFrom - - - - - TODO: ERC-721 Functions - *approv*, *transfer* - - - - - - - - - - - - - - Sign - - - - - - - - - - - - - - - - - - - - @@ -884,272 +588,6 @@ this.$bvModal.show('modal-saveprivatekeytokeystore'); }, - showNewWalletFromMnemonic() { - console.log(moment().format("HH:mm:ss") + " showNewWalletFromMnemonic"); - this.$bvModal.show('modal-newwalletfrommnemonic'); - }, - showNewWalletFromPrivateKey() { - console.log(moment().format("HH:mm:ss") + " showNewWalletFromPrivateKey"); - this.$bvModal.show('modal-newwalletfromprivatekey'); - }, - showNewWalletFromKeystore() { - console.log(moment().format("HH:mm:ss") + " showNewWalletFromKeystore"); - this.$bvModal.show('modal-newwalletfromkeystore'); - }, - showAddressNew() { - console.log(moment().format("HH:mm:ss") + " showAddressNew"); - this.address.mode = 'add'; - this.address.type = 'address'; - this.address.address = null; - this.address.addressError = null; - this.address.name = null; - this.address.keystore = null; - this.address.password = null; - this.address.passwordError = null; - this.address.privateKey = null; - this.$bvModal.show('modal-address'); - }, - - newWalletFromMnemonicGenerateRandom() { - console.log(moment().format("HH:mm:ss") + " newWalletFromMnemonicGenerateRandom"); - try { - const randomBytes = ethers.utils.randomBytes(this.newWalletFromMnemonic.randomBytesLength); - this.newWalletFromMnemonic.phrase = ethers.utils.entropyToMnemonic(randomBytes); - this.newWalletFromMnemonic.phraseError = null; - - // const randomBytes = ethers.utils.randomBytes(16); - // const phrase = ethers.utils.entropyToMnemonic(randomBytes); - // const node = ethers.utils.HDNode.fromMnemonic(phrase); - // console.log(moment().format("HH:mm:ss") + " newWalletFromMnemonicGenerateRandom - node: " + JSON.stringify(node, null, 2)); - // const defaultPath = "m/44'/60'/0'/0/0"; - // const wallet = node.derivePath(defaultPath); - // this.newWalletFromPrivateKey.privateKey = wallet.privateKey; - // this.newWalletFromPrivateKey.privateKeyError = null; - // this.newWalletFromPrivateKey.address = wallet.address; - // console.log(moment().format("HH:mm:ss") + " newWalletFromMnemonicGenerateRandom - this.newWalletFromPrivateKey: " + JSON.stringify(this.newWalletFromPrivateKey, null, 2)); - } catch (e) { - console.log(moment().format("HH:mm:ss") + " newWalletFromMnemonicGenerateRandom ERROR: " + e.message); - } - }, - - newWalletFromMnemonicRecompute() { - console.log(moment().format("HH:mm:ss") + " newWalletFromMnemonicRecompute"); - if (this.newWalletFromMnemonic.phrase) { - try { - const node = ethers.utils.HDNode.fromMnemonic(this.newWalletFromMnemonic.phrase); - this.newWalletFromMnemonic.phraseError = null; - } catch (e) { - console.log(moment().format("HH:mm:ss") + " newWalletFromMnemonicRecompute ERROR: " + e.message); - this.newWalletFromMnemonic.phraseError = e.message; - } - } else { - this.newWalletFromMnemonic.phraseError = null; - } - }, - - newWalletFromMnemonicAddressesRowSelected(item) { - console.log(moment().format("HH:mm:ss") + " newWalletFromMnemonicAddressesRowSelected: " + JSON.stringify(item)); - if (item && item.length > 0) { - this.newWalletFromMnemonic.selectedItem = item[0]; - this.$bvModal.show('modal-newwalletfrommnemonic-add'); - } else { - this.newWalletFromMnemonic.selectedItem = null; - } - console.log(moment().format("HH:mm:ss") + " newWalletFromMnemonicAddressesRowSelected - this.newWalletFromMnemonic: " + JSON.stringify(this.newWalletFromMnemonic, null, 2)); - }, - - async newWalletFromMnemonicAdd() { - console.log(moment().format("HH:mm:ss") + " newWalletFromMnemonicAdd - this.newWalletFromMnemonic: " + JSON.stringify(this.newWalletFromMnemonic, null, 2)); - const wallet = new ethers.Wallet(this.newWalletFromMnemonic.selectedItem.privateKey); - const encryptedText = await wallet.encrypt(this.newWalletFromMnemonic.password); - const keystore = JSON.parse(encryptedText); - keystore.filename = "UTC--" + moment.utc().format("YYYY-MM-DDTHH-mm-ss") + ".0Z--" + this.newWalletFromMnemonic.selectedItem.address.slice(2).toLowerCase(); - Vue.set(this.addresses, this.newWalletFromMnemonic.selectedItem.address, { - type: "walletfrommnemonic", - name: this.newWalletFromMnemonic.name, - keystore, - }); - localStorage.topSecretsOfflineAddresses = JSON.stringify(this.addresses); - console.log(moment().format("HH:mm:ss") + " newWalletFromMnemonicAdd - this.addresses: " + JSON.stringify(this.addresses, null, 2)); - this.$bvModal.hide('modal-newwalletfrommnemonic-add'); - }, - - newWalletFromPrivateKeyGenerateRandom() { - console.log(moment().format("HH:mm:ss") + " newWalletFromPrivateKeyGenerateRandom"); - try { - const randomBytes = ethers.utils.randomBytes(16); - const phrase = ethers.utils.entropyToMnemonic(randomBytes); - const node = ethers.utils.HDNode.fromMnemonic(phrase); - console.log(moment().format("HH:mm:ss") + " newWalletFromPrivateKeyGenerateRandom - node: " + JSON.stringify(node, null, 2)); - const defaultPath = "m/44'/60'/0'/0/0"; - const wallet = node.derivePath(defaultPath); - this.newWalletFromPrivateKey.privateKey = wallet.privateKey; - this.newWalletFromPrivateKey.privateKeyError = null; - this.newWalletFromPrivateKey.address = wallet.address; - console.log(moment().format("HH:mm:ss") + " newWalletFromPrivateKeyGenerateRandom - this.newWalletFromPrivateKey: " + JSON.stringify(this.newWalletFromPrivateKey, null, 2)); - } catch (e) { - console.log(moment().format("HH:mm:ss") + " newWalletFromPrivateKeyGenerateRandom ERROR: " + e.message); - } - }, - - newWalletFromPrivateKeyRecompute() { - console.log(moment().format("HH:mm:ss") + " newWalletFromPrivateKeyRecompute: " + JSON.stringify(this.newWalletFromPrivateKey)); - if (this.newWalletFromPrivateKey.privateKey) { - try { - const wallet = new ethers.Wallet(this.newWalletFromPrivateKey.privateKey); - this.newWalletFromPrivateKey.privateKeyError = null; - this.newWalletFromPrivateKey.address = wallet.address; - console.log(moment().format("HH:mm:ss") + " newWalletFromPrivateKeyRecompute - AFTER: " + JSON.stringify(this.newWalletFromPrivateKey)); - } catch (e) { - console.log(moment().format("HH:mm:ss") + " newWalletFromPrivateKeyRecompute - privatekey ERROR: " + e.message); - this.newWalletFromPrivateKey.privateKeyError = e.message; - this.newWalletFromPrivateKey.address = null; - } - } else { - this.newWalletFromPrivateKey.privateKeyError = null; - this.newWalletFromPrivateKey.address = null; - } - }, - - async newWalletFromPrivateKeyAdd() { - const wallet = new ethers.Wallet(this.newWalletFromPrivateKey.privateKey); - const encryptedText = await wallet.encrypt(this.newWalletFromPrivateKey.password); - const keystore = JSON.parse(encryptedText); - keystore.filename = "UTC--" + moment.utc().format("YYYY-MM-DDTHH-mm-ss") + ".0Z--" + this.newWalletFromPrivateKey.address.slice(2).toLowerCase(); - Vue.set(this.addresses, this.newWalletFromPrivateKey.address, { - type: "walletfromprivatekey", - name: this.newWalletFromPrivateKey.name, - keystore, - }); - localStorage.topSecretsOfflineAddresses = JSON.stringify(this.addresses); - console.log(moment().format("HH:mm:ss") + " newWalletFromPrivateKeyAdd - this.addresses: " + JSON.stringify(this.addresses, null, 2)); - this.$bvModal.hide('modal-newwalletfromprivatekey'); - }, - - async newWalletFromKeystoreFileChange(fileName, fileList) { - console.log(moment().format("HH:mm:ss") + " newWalletFromKeystoreFileChange: " + JSON.stringify(fileName)); - const reader = new FileReader(); - this.newWalletFromKeystore.keystoreFileContent = {}; - const t = this; - reader.onload = function (event) { - const data = event.target.result; - t.newWalletFromKeystore.keystoreFileContent = data; - console.log(moment().format("HH:mm:ss") + " newWalletFromKeystoreFileChange - keystoreFileContent: " + t.newWalletFromKeystore.keystoreFileContent); - }; - await reader.readAsText(fileList[0]); - }, - - async newWalletFromKeystoreLoad() { - console.log(moment().format("HH:mm:ss") + " newWalletFromKeystoreLoad - this.newWalletFromKeystore.keystoreFileContent: " + this.newWalletFromKeystore.keystoreFileContent); - console.log(moment().format("HH:mm:ss") + " newWalletFromKeystoreLoad - this.newWalletFromKeystore.keystoreFilePassword: " + this.newWalletFromKeystore.keystoreFilePassword); - try { - const wallet = await ethers.Wallet.fromEncryptedJsonSync(this.newWalletFromKeystore.keystoreFileContent, this.newWalletFromKeystore.keystoreFilePassword); - this.newWalletFromKeystore.privateKey = wallet.privateKey; - this.newWalletFromKeystore.address = wallet.address; - } catch (e) { - console.log(moment().format("HH:mm:ss") + " newWalletFromKeystoreLoad - keystorefile ERROR: " + e.message); - } - }, - - async newWalletFromKeystoreAdd() { - const wallet = new ethers.Wallet(this.newWalletFromKeystore.privateKey); - const encryptedText = await wallet.encrypt(this.newWalletFromKeystore.password); - const keystore = JSON.parse(encryptedText); - keystore.filename = "UTC--" + moment.utc().format("YYYY-MM-DDTHH-mm-ss") + ".0Z--" + this.newWalletFromKeystore.address.slice(2).toLowerCase(); - Vue.set(this.addresses, this.newWalletFromKeystore.address, { - type: "walletfromkeystore", - name: this.newWalletFromKeystore.name, - keystore, - }); - localStorage.topSecretsOfflineAddresses = JSON.stringify(this.addresses); - console.log(moment().format("HH:mm:ss") + " newWalletFromKeystoreAdd - this.addresses: " + JSON.stringify(this.addresses, null, 2)); - this.$bvModal.hide('modal-newwalletfromkeystore'); - }, - - newAddressRecompute() { - console.log(moment().format("HH:mm:ss") + " newAddressRecompute: " + JSON.stringify(this.address)); - if (this.address.address) { - try { - const addr = ethers.utils.getAddress(this.address.address); - this.address.addressError = null; - console.log(moment().format("HH:mm:ss") + " newAddressRecompute - AFTER: " + JSON.stringify(this.address)); - } catch (e) { - console.log(moment().format("HH:mm:ss") + " newAddressRecompute - ERROR: " + e.message); - this.address.addressError = e.message; - } - } else { - this.address.addressError = null; - } - }, - - async addressAdd() { - console.log(moment().format("HH:mm:ss") + " addressAdd - this.address: " + JSON.stringify(this.address, null, 2)); - Vue.set(this.addresses, this.address.address, { - type: this.address.type, - name: this.address.name, - }); - localStorage.topSecretsOfflineAddresses = JSON.stringify(this.addresses); - console.log(moment().format("HH:mm:ss") + " addressAdd - this.addresses: " + JSON.stringify(this.addresses, null, 2)); - this.$bvModal.hide('modal-address'); - }, - - async addressPrivateKeyPasswordUpdate() { - try { - const wallet = await ethers.Wallet.fromEncryptedJsonSync(JSON.stringify(this.address.keystore), this.address.password); - this.address.privateKey = wallet.privateKey; - this.address.passwordError = null; - } catch (e) { - console.log(moment().format("HH:mm:ss") + " addressPrivateKeyPasswordUpdate - keystorefile ERROR: " + e.message); - this.address.passwordError = e.message; - this.address.privateKey = null; - } - console.log(moment().format("HH:mm:ss") + " addressPrivateKeyPasswordUpdate AFTER - this.address: " + JSON.stringify(this.address, null, 2)); - }, - - async addressUpdate() { - console.log(moment().format("HH:mm:ss") + " addressUpdate - this.address: " + JSON.stringify(this.address, null, 2)); - Vue.set(this.addresses[this.address.address], 'type', this.address.type); - Vue.set(this.addresses[this.address.address], 'name', this.address.name); - localStorage.topSecretsOfflineAddresses = JSON.stringify(this.addresses); - console.log(moment().format("HH:mm:ss") + " addressUpdate - this.addresses: " + JSON.stringify(this.addresses, null, 2)); - this.$bvModal.hide('modal-address'); - }, - - async addressDelete() { - console.log(moment().format("HH:mm:ss") + " addressDelete - this.address: " + JSON.stringify(this.address, null, 2)); - this.$bvModal.msgBoxConfirm("Delete " + this.address.address + '?') - .then(confirmed => { - if (confirmed) { - Vue.delete(this.addresses, this.address.address); - localStorage.topSecretsOfflineAddresses = JSON.stringify(this.addresses); - console.log(moment().format("HH:mm:ss") + " addressDelete - this.addresses: " + JSON.stringify(this.addresses, null, 2)); - this.$bvModal.hide('modal-address'); - } - }) - .catch(err => { - }); - }, - - async signMessageSign() { - console.log(moment().format("HH:mm:ss") + " signMessageSign - this.signMessage: " + JSON.stringify(this.signMessage, null, 2)); - const walletInfo = this.addresses[this.signMessage.wallet]; - // console.log(moment().format("HH:mm:ss") + " signMessageSign - walletInfo: " + JSON.stringify(walletInfo, null, 2)); - const wallet = new ethers.Wallet(walletInfo.privateKey); - // console.log(moment().format("HH:mm:ss") + " signMessageSign - wallet: " + JSON.stringify(wallet, null, 2)); - const signature = await wallet.signMessage(this.signMessage.message); - // console.log(moment().format("HH:mm:ss") + " signMessageSign - signature: " + JSON.stringify(signature, null, 2)); - Vue.set(this.signMessage, 'signature', signature); - // let result = null; - // try { - // console.log(moment().format("HH:mm:ss") + " checkMessageRecoveredAddress - message: " + this.signMessage.message); - // let pubKey = ethers.utils.recoverPublicKey(ethers.utils.arrayify(ethers.utils.hashMessage(this.signMessage.message)), signature); - // result = ethers.utils.computeAddress(pubKey); - // console.log(moment().format("HH:mm:ss") + " checkMessageRecoveredAddress - result: " + result); - // } catch (e) { - // console.log(moment().format("HH:mm:ss") + " checkMessageRecoveredAddress ERROR: " + e.message); - // } - }, - // Older stuff below generateDerivedAddresses() {