@@ -42,7 +42,9 @@ const fundTransactions = signedTxs => {
4242// returns true if gas tank was used, false otherwise
4343// askForFunding: callback that takes (address, requiredBalance, currentBalance)
4444// and tells the user to get that address the required balance
45−const ensureFundsFor = async (web3, point, address, cost, signedTxs, askForFunding) => {
45+// gotFunding: optional callback that stops telling the user to go get funding
46+const ensureFundsFor = async (web3, point, address, cost, signedTxs,
47+ askForFunding, gotFunding) => {
4648 let balance = await web3.eth.getBalance(address);
4749
4850 if (cost > balance) {
@@ -74,7 +76,7 @@ const ensureFundsFor = async (web3, point, address, cost, signedTxs, askForFundi
7476 } catch (e) {
7577
7678 console.log('tank: funding failed', e);
77− await waitForBalance(web3, address, cost, askForFunding);
79+ await waitForBalance(web3, address, cost, askForFunding, gotFunding);
7880
7981 }
8082
@@ -87,13 +89,18 @@ const ensureFundsFor = async (web3, point, address, cost, signedTxs, askForFundi
8789// resolves when address has at least minBalance
8890//
8991//TODO should maybe do a "we got it" callback also, so clients can hide msg?
90−async function waitForBalance(web3, address, minBalance, askForFunding) {
92+async function waitForBalance(web3, address, minBalance,
93+ askForFunding, gotFunding) {
9194 console.log('tank: awaiting balance', address, minBalance);
9295 return new Promise((resolve, reject) => {
9396 let oldBalance = null;
9497 const checkForBalance = async () => {
9598 const balance = await web3.eth.getBalance(address);
9699 if (balance >= minBalance) {
100+ // if we ever asked for funding, retract that request now
101+ if (gotFunding && (oldBalance !== null)) {
102+ gotFunding();
103+ }
97104 resolve();
98105 } else {
99106 if (balance !== oldBalance) {