Skip to content

Commit

Permalink
remove console.log / console.debug
Browse files Browse the repository at this point in the history
  • Loading branch information
cshung1994 committed Aug 27, 2019
1 parent e6ff812 commit 7654a65
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 43 deletions.
16 changes: 0 additions & 16 deletions js/dappModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,15 @@ const addWalletBtnListener = (walletConnector, end, onLoginSuccess) => {
// add listener once
$('#use-metamask-btn').click(() => {
if (!(windowProvider && windowProvider.isMetaMask)) {
console.debug('Can\'t find MetaMask');
myAlert.metamask();
return;
}
console.debug('Use MetaMask');

window.ethereum = windowProvider;
window.web3 = windowWeb3;

modalStartLoading();
window.ethereum.enable().then((res) => {
console.debug('res: ', res);
modalHide();
end(null, res);
}).catch((err) => {
Expand All @@ -71,16 +68,13 @@ const addWalletBtnListener = (walletConnector, end, onLoginSuccess) => {
});
$('#use-dapper-btn').click(() => {
if (!(windowProvider && windowProvider.isDapper)) {
console.debug('Can\'t find Dapper');
myAlert.dapper();
return;
}

console.debug('Use Dapper');

// Check if Dapper is unclocked
if (!(windowWeb3.eth.coinbase)) {
console.debug('Dapper is locked');
myAlert.dapperIsLocked();
return;
}
Expand All @@ -90,7 +84,6 @@ const addWalletBtnListener = (walletConnector, end, onLoginSuccess) => {

modalStartLoading();
window.ethereum.enable().then((res) => {
console.debug('res: ', res);
modalHide();
end(null, res);
}).catch((err) => {
Expand All @@ -99,7 +92,6 @@ const addWalletBtnListener = (walletConnector, end, onLoginSuccess) => {
});
});
$('#use-portis-btn').click(() => {
console.debug('Use Portis');

const portis = new Portis('696237e9-38fb-406a-a4d6-bfa3a4d63293', config.network);
const web3 = new Web3(portis.provider);
Expand All @@ -109,7 +101,6 @@ const addWalletBtnListener = (walletConnector, end, onLoginSuccess) => {

modalStartLoading();
window.ethereum.enable().then((res) => {
console.debug('res: ', res);
modalHide();
end(null, res);
}).catch((err) => {
Expand All @@ -118,7 +109,6 @@ const addWalletBtnListener = (walletConnector, end, onLoginSuccess) => {
});
});
$('#use-torus-btn').click(async () => {
console.debug('Use Torus');

// Optional, if ture, reload or restore website will keep user web3 data
// const isTorus = sessionStorage.getItem('pageUsingTorus');
Expand Down Expand Up @@ -152,7 +142,6 @@ const addWalletBtnListener = (walletConnector, end, onLoginSuccess) => {
}
});
$('#use-ledger-btn').click(async () => {
console.debug('Use Ledger');
showLedgerDerivationPath();
$('#go-back').click(() => {
ledgerPathGoBack();
Expand All @@ -167,7 +156,6 @@ const addWalletBtnListener = (walletConnector, end, onLoginSuccess) => {
let accounts;
try {
accounts = await web3.eth.getAccounts();
console.debug(accounts);
// Set default Account
const [firstAccount, ...rest] = accounts;
web3.eth.defaultAccount = firstAccount;
Expand All @@ -191,7 +179,6 @@ const addWalletBtnListener = (walletConnector, end, onLoginSuccess) => {
let accounts;
try {
accounts = await web3.eth.getAccounts();
console.debug(accounts);
// Set default Account
const [firstAccount, ...rest] = accounts;
web3.eth.defaultAccount = firstAccount;
Expand Down Expand Up @@ -230,7 +217,6 @@ const addWalletBtnListener = (walletConnector, end, onLoginSuccess) => {
}
});
$('#use-mobile-btn').click(() => {
console.debug('Use WalletConnect');

if (window.isMobile) { // Mobile
myAlert.wcUnsupport();
Expand All @@ -247,7 +233,6 @@ const addWalletBtnListener = (walletConnector, end, onLoginSuccess) => {
const { uri } = walletConnector;
// display QR Code modal
WalletConnectQRCodeModal.open(uri, () => {
console.debug('QR Code Modal closed');
});
});

Expand Down Expand Up @@ -290,7 +275,6 @@ module.exports = {

// Add dismiss handler
const listener = () => {
console.debug('On dappQrcodeModal close');
$('#dappQrcodeModal').off();
};
$('#dappQrcodeModal').on('hidden.bs.modal', listener);
Expand Down
12 changes: 0 additions & 12 deletions js/dappSdkProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ RemoteLoginSubprovider.prototype.handleRequest = function handleRequest(payload,
switch (payload.method) {
// enable
case 'eth_requestAccounts': {
console.debug('******* enable(), eth_requestAccounts *******');
const { payload: { walletConnector } } = payload;

console.debug(walletConnector);

dappModal.showLoginQrcodeWithString(
walletConnector,
Expand All @@ -36,13 +34,11 @@ RemoteLoginSubprovider.prototype.handleRequest = function handleRequest(payload,
}

case 'eth_coinbase': {
console.log('eth_coinbase');
end(null, self.defaultAddress);
break;
}

case 'eth_accounts': {
console.log('eth_accounts');
end(null, [self.defaultAddress]);
break;
}
Expand All @@ -53,17 +49,14 @@ RemoteLoginSubprovider.prototype.handleRequest = function handleRequest(payload,
}

const txData = payload.params[0];
console.log('eth_sendTransaction txData: ', txData);
self.walletConnector
.sendTransaction(txData)
.then((result) => {
// Returns transaction id (hash)
console.log('result: ', result);
end(null, result);
})
.catch((error) => {
// Error returned when rejected
console.log('error: ', error);
end(error);
});
break;
Expand All @@ -74,7 +67,6 @@ RemoteLoginSubprovider.prototype.handleRequest = function handleRequest(payload,
end(Error('Please login.'));
}

console.log(payload.params);
const { params: [address, data] } = payload;
const msgParams = [
address,
Expand All @@ -83,12 +75,10 @@ RemoteLoginSubprovider.prototype.handleRequest = function handleRequest(payload,
self.walletConnector.signMessage(msgParams)
.then((result) => {
// Returns signature.
console.log('result: ', result);
end(null, result);
})
.catch((error) => {
// Error returned when rejected
console.log('error: ', error);
end(error);
});
break;
Expand All @@ -112,12 +102,10 @@ RemoteLoginSubprovider.prototype.handleRequest = function handleRequest(payload,
self.walletConnector.signPersonalMessage(msgParams)
.then((result) => {
// Returns signature.
console.log('result: ', result);
end(null, result);
})
.catch((error) => {
// Error returned when rejected
console.log('error: ', error);
end(error);
});
break;
Expand Down
5 changes: 0 additions & 5 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ let _defaultAddress;
const { rpcUrl } = config;

const getDefaultAddress = () => {
console.log('getDefaultAddress');
if (_defaultAddress !== undefined) {
return _defaultAddress;
}
return '';
};

const getNetVersion = () => {
console.log('getNetVersion');
return 1;
};

Expand Down Expand Up @@ -75,7 +73,6 @@ const initEngine = () => {
eng.dappSdk = { version };

eng.enable = async (cb = () => {}) => {
console.log('enable');
const p = new Promise((resolve, reject) => {
const rpcData = {
method: 'eth_requestAccounts',
Expand All @@ -85,10 +82,8 @@ const initEngine = () => {
};
eng.sendAsync(rpcData, (err, res) => {
if (err) {
console.log('enable rejected with err: ', err);
reject(err);
}
console.log('enable resolved, res: ', res);
defaultEnableCallback(err, res);
cb(err, res);
resolve(res);
Expand Down
5 changes: 0 additions & 5 deletions js/staticProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ function StaticProvider(defaultAddressGenerator, defaulNetVersionGenerator) {

self.staticResponses = {
eth_accounts: () => {
console.log('****eth_accounts');
return [self.defaultAddressGenerator()];
},
eth_coinbase: () => {
console.log('****eth_coinbase');
return self.defaultAddressGenerator();
},
net_version: () => {
console.log('****net_version');
return self.defaulNetVersionGenerator();
},
};
Expand All @@ -31,13 +28,11 @@ StaticProvider.prototype.handleRequest = function handleRequest(payload, next, e

StaticProvider.prototype.handleSyncRequest = function handleSyncRequest(payload) {
const self = this;
console.log('payload.method: ', payload.method);
const staticResponse = self.staticResponses[payload.method];
if (typeof staticResponse === 'function') {
return staticResponse();
// static response - null is valid response
} if (staticResponse !== undefined) {
console.log(staticResponse);
return staticResponse;
// no prepared response - skip
}
Expand Down
2 changes: 0 additions & 2 deletions js/walletConnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const setupWalletConnector = (walletConnector) => {

// Get updated accounts and chainId
const { accounts, chainId } = payload.params[0];
console.debug('on session_update', accounts, chainId);
});

walletConnector.on('disconnect', (error, payload) => {
Expand All @@ -17,7 +16,6 @@ const setupWalletConnector = (walletConnector) => {
}

// Delete walletConnector
console.debug('on disconnect');
// eslint-disable-next-line no-alert
alert('Log out successfully.');
// eslint-disable-next-line no-restricted-globals
Expand Down
1 change: 0 additions & 1 deletion sample/sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ <h5 class="card-title">ETH Amount</h5>
alert('Please use wallet connect.');
} else {
window.ethereum.logout().then((res) => {
console.log('logout done. res: ', res);
}).catch((err) => {
alert(err);
});
Expand Down
2 changes: 0 additions & 2 deletions sample/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ var path = require('path');
function start(route) {
var app = express();

console.log('Server start...');

app.get('/', (req, res) => {
console.log("Request received.");
fs.readFile('./sample/sample.html',(err, data) => {
res.writeHead(200, {"Content-Type": "text/html", 'Content-Length':data.length});
res.write(data);
Expand Down

0 comments on commit 7654a65

Please sign in to comment.