diff --git a/CHANGELOG.md b/CHANGELOG.md index 069602915..7fc74a9d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Current Master +- Only rebrodcast transactions for a day not a days worth of blocks - Remove Slack link from info page, since it is a big phishing target. ## 3.10.8 2017-9-28 diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index 94e04c429..a0f983deb 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -59,7 +59,7 @@ module.exports = class TransactionController extends EventEmitter { this.pendingTxTracker = new PendingTransactionTracker({ provider: this.provider, nonceTracker: this.nonceTracker, - retryLimit: 3500, // Retry 3500 blocks, or about 1 day. + retryTimePeriod: 86400000, // Retry 3500 blocks, or about 1 day. publishTransaction: (rawTx) => this.query.sendRawTransaction(rawTx), getPendingTransactions: this.txStateManager.getPendingTransactions.bind(this.txStateManager), }) diff --git a/app/scripts/lib/pending-tx-tracker.js b/app/scripts/lib/pending-tx-tracker.js index 6f1601586..8a626e222 100644 --- a/app/scripts/lib/pending-tx-tracker.js +++ b/app/scripts/lib/pending-tx-tracker.js @@ -22,7 +22,8 @@ module.exports = class PendingTransactionTracker extends EventEmitter { super() this.query = new EthQuery(config.provider) this.nonceTracker = config.nonceTracker - this.retryLimit = config.retryLimit || Infinity + // default is one day + this.retryTimePeriod = config.retryTimePeriod || 86400000 this.getPendingTransactions = config.getPendingTransactions this.publishTransaction = config.publishTransaction } @@ -99,8 +100,9 @@ module.exports = class PendingTransactionTracker extends EventEmitter { } async _resubmitTx (txMeta) { - if (txMeta.retryCount > this.retryLimit) { - const err = new Error(`Gave up submitting after ${this.retryLimit} blocks un-mined.`) + if (Date.now() > txMeta.time + this.retryTimePeriod) { + const hours = (this.retryTimePeriod / 3.6e+6).toFixed(1) + const err = new Error(`Gave up submitting after ${hours} hours.`) return this.emit('tx:failed', txMeta.id, err) } diff --git a/gulpfile.js b/gulpfile.js index ac36cf983..557b58a68 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -151,7 +151,7 @@ gulp.task('copy:watch', function(){ gulp.task('lint', function () { // Ignoring node_modules, dist/firefox, and docs folders: - return gulp.src(['app/**/*.js', 'ui/**/*.js', '!node_modules/**', '!dist/firefox/**', '!docs/**', '!app/scripts/chromereload.js']) + return gulp.src(['app/**/*.js', 'ui/**/*.js', 'mascara/src/*.js', 'mascara/server/*.js', '!node_modules/**', '!dist/firefox/**', '!docs/**', '!app/scripts/chromereload.js', '!mascara/test/jquery-3.1.0.min.js']) .pipe(eslint(fs.readFileSync(path.join(__dirname, '.eslintrc')))) // eslint.format() outputs the lint results to the console. // Alternatively use eslint.formatEach() (see Docs). diff --git a/mascara/example/app.js b/mascara/example/app.js index d0cb6ba83..598e2c84c 100644 --- a/mascara/example/app.js +++ b/mascara/example/app.js @@ -7,20 +7,32 @@ async function loadProvider() { const ethereumProvider = window.metamask.createDefaultProvider({ host: 'http://localhost:9001' }) const ethQuery = new EthQuery(ethereumProvider) const accounts = await ethQuery.accounts() - logToDom(accounts.length ? accounts[0] : 'LOCKED or undefined') - setupButton(ethQuery) + window.METAMASK_ACCOUNT = accounts[0] || 'locked' + logToDom(accounts.length ? accounts[0] : 'LOCKED or undefined', 'account') + setupButtons(ethQuery) } -function logToDom(message){ - document.getElementById('account').innerText = message +function logToDom(message, context){ + document.getElementById(context).innerText = message console.log(message) } -function setupButton (ethQuery) { - const button = document.getElementById('action-button-1') - button.addEventListener('click', async () => { +function setupButtons (ethQuery) { + const accountButton = document.getElementById('action-button-1') + accountButton.addEventListener('click', async () => { const accounts = await ethQuery.accounts() - logToDom(accounts.length ? accounts[0] : 'LOCKED or undefined') + window.METAMASK_ACCOUNT = accounts[0] || 'locked' + logToDom(accounts.length ? accounts[0] : 'LOCKED or undefined', 'account') + }) + const txButton = document.getElementById('action-button-2') + txButton.addEventListener('click', async () => { + if (!window.METAMASK_ACCOUNT || window.METAMASK_ACCOUNT === 'locked') return + const txHash = await ethQuery.sendTransaction({ + from: window.METAMASK_ACCOUNT, + to: window.METAMASK_ACCOUNT, + data: '', + }) + logToDom(txHash, 'cb-value') }) } \ No newline at end of file diff --git a/mascara/example/app/index.html b/mascara/example/app/index.html index f3e38877c..8afb6f3f2 100644 --- a/mascara/example/app/index.html +++ b/mascara/example/app/index.html @@ -10,6 +10,8 @@
+ +