wallet-tx-scanner
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -34,2 +34,5 @@ const axios = require('axios'); | ||
url: 'https://api-arbitrum.etherscan.io/api' | ||
}, | ||
bitcoin: { | ||
url: 'https://blockchain.info/rawaddr/' | ||
} | ||
@@ -54,23 +57,39 @@ }; | ||
try { | ||
const { key, url } = this.protectedKeys[network]; | ||
const response = await axios.get(url, { | ||
params: { | ||
module: 'account', | ||
action: 'txlist', | ||
address, | ||
apikey: key | ||
} | ||
}); | ||
if (!response.data.result || response.data.result.length === 0) { | ||
return { | ||
success: false, | ||
message: 'No transactions found' | ||
}; | ||
switch (network) { | ||
case 'bitcoin': | ||
const resBitcoin = await axios.get(`${this.protectedKeys[network].url}${address}`); | ||
if (!resBitcoin.data.txs || resBitcoin.data.txs.length === 0) { | ||
return { | ||
success: false, | ||
message: 'No transactions found' | ||
}; | ||
} | ||
return { | ||
success: true, | ||
data: resBitcoin.data.txs | ||
}; | ||
default: | ||
const { key, url } = this.protectedKeys[network]; | ||
const response = await axios.get(url, { | ||
params: { | ||
module: 'account', | ||
action: 'txlist', | ||
address, | ||
apikey: key | ||
} | ||
}); | ||
if (!response.data.result || response.data.result.length === 0) { | ||
return { | ||
success: false, | ||
message: 'No transactions found' | ||
}; | ||
} | ||
return { | ||
success: true, | ||
data: response.data.result | ||
}; | ||
} | ||
return { | ||
success: true, | ||
data: response.data.result | ||
}; | ||
} catch (error) { | ||
@@ -77,0 +96,0 @@ return { |
{ | ||
"name": "wallet-tx-scanner", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Helps to quickly retrieve transactions from the blockchain knowing only the wallet address", | ||
@@ -24,3 +24,3 @@ "main": "./lib/index.js", | ||
"dependencies": { | ||
"axios": "^1.4.0", | ||
"axios": "^1.5.0", | ||
"axios-mock-adapter": "^1.21.5", | ||
@@ -27,0 +27,0 @@ "chai": "^4.3.7" |
10989
158
Updatedaxios@^1.5.0