diff --git a/Be/passthrough/passtrough.js b/Be/passthrough/passtrough.js index f51d0fc..96209e7 100644 --- a/Be/passthrough/passtrough.js +++ b/Be/passthrough/passtrough.js @@ -119,6 +119,18 @@ res.header('Access-Control-Allow-Origin', SERVING); } } ); +//Endpoint /txs/:hash/withdrawals +app.get('/txs/:hash/withdrawals', async (req, res) => { + res.header('Access-Control-Allow-Origin', SERVING); + const { hash } = req.params; + try { + const response = await axios.get(`${blockfrostApis[req.headers.project_id]}/txs/${hash}/withdrawals`, { headers: { project_id: blockfrostApiKeys[req.headers.project_id] } }); + res.json(response.data); + }catch (error) { + const statusCode = error.response.status || 500; + res.status(statusCode).json({ error: error.message }); + } +}); //Endpoint :txs/${txHash} app.get('/txs/:txHash', async (req, res) => { diff --git a/Fe/src/components/Minting/minting.js b/Fe/src/components/Minting/minting.js index 12d85eb..e691309 100644 --- a/Fe/src/components/Minting/minting.js +++ b/Fe/src/components/Minting/minting.js @@ -261,8 +261,8 @@ import { toast } from 'react-toastify';class Minting extends React.Component { } } - async newLucidInstance(settings) { - getNewLucidInstance(settings); + async newLucidInstance(settings){ + return getNewLucidInstance(settings); } diff --git a/Fe/src/helpers/TransactionHistory.js b/Fe/src/helpers/TransactionHistory.js index 4e8f05e..01c727b 100644 --- a/Fe/src/helpers/TransactionHistory.js +++ b/Fe/src/helpers/TransactionHistory.js @@ -34,7 +34,7 @@ async function getTransactionHistory(address, settings, page=0 , limit = 10){ }else if ( settings.metadataProvider === "Blockfrost"){ const api = settings.api.url const response = await fetch( - `${api}/addresses/${address}/transactions?order=acs`, + `${api}/addresses/${address}/transactions`, { method: "GET", headers: { @@ -47,7 +47,7 @@ async function getTransactionHistory(address, settings, page=0 , limit = 10){ if (json.error) return [] json.sort((a,b) => b.block_height - a.block_height) - return await getTransactionDetails(json.slice(page*limit,(page+1)*limit), settings) + return await getTransactionDetails(json.slice(page*limit,(page+1)*limit), settings, address) }else if(settings.metadataProvider === "Maestro") { const MaestroUrl = `https://${settings.network}.gomaestro-api.org` @@ -72,12 +72,17 @@ async function getTransactionHistory(address, settings, page=0 , limit = 10){ } -async function getTransactionDetails(transactionIds, settings){ +async function getTransactionDetails(transactionIds, settings, address){ let transactionInfo = {...JSON.parse(localStorage.getItem('transactionInfo'))}; - + const lucid = await Lucid.new( + null, + settings.network + ); + + // I want to refresh every 15 minutes let fullTransactionsInfo = transactionIds.map( async (transactionId) => { - if (transactionInfo[transactionId.tx_hash] && transactionInfo[transactionId.tx_hash].provider === settings.metadataProvider ){ + if (transactionInfo[transactionId.tx_hash] && transactionInfo[transactionId.tx_hash].provider === settings.metadataProvider && Date.now() - transactionInfo[transactionId.tx_hash].fetch_time < 900000){ return (transactionInfo[transactionId.tx_hash]) } else @@ -138,10 +143,35 @@ async function getTransactionDetails(transactionIds, settings){ } } ); + let withdraw + try{ + const withdrawResponce = await fetch( + `${api}/txs/${transactionId.tx_hash}/withdrawals`, + { + + method: "GET", + headers: { + project_id: settings.api.projectId + } + } + ) + withdraw = await withdrawResponce.json() + }catch(e){ + console.log(e) + withdraw = [] + } let fullTransactionInfo = {...transactionId}; fullTransactionInfo.utxos = await response.json(); transactionInfo[transactionId.tx_hash] = fullTransactionInfo transactionInfo[transactionId.tx_hash].fetch_time = Date.now() + transactionInfo[transactionId.tx_hash].withdrawals = {} + transactionInfo[transactionId.tx_hash].withdrawals.amount = 0 + withdraw.forEach( w => { + if(lucid.utils.getAddressDetails(address).stakeCredential.hash === lucid.utils.getAddressDetails(w.address).stakeCredential.hash) { + transactionInfo[transactionId.tx_hash].withdrawals.amount += Number(w.amount)} + }) + + // transactionInfo[transactionId.tx_hash].withdrawals = withdrawResponce.ok ? await withdrawResponce.json() : null transactionInfo[transactionId.tx_hash].provider = "Blockfrost" localStorage.setItem('transactionInfo', JSON.stringify(transactionInfo)); return transactionInfo[transactionId.tx_hash] @@ -156,10 +186,7 @@ async function getTransactionDetails(transactionIds, settings){ } }, ).then((res) => res.json()); - const lucid = await Lucid.new( - null, - settings.network - ); + let fullTransactionInfo = {...transactionId}; fullTransactionInfo.utxos = {} diff --git a/Fe/src/helpers/newLucid.js b/Fe/src/helpers/newLucid.js index 04718ac..735dd47 100644 --- a/Fe/src/helpers/newLucid.js +++ b/Fe/src/helpers/newLucid.js @@ -4,12 +4,11 @@ import { Lucid, Blockfrost ,Kupmios, Maestro} from "lucid-cardano"; async function getNewLucidInstance(settings){ return new Promise(async (resolve, reject) => { const provider = getProvider(settings); - - let lucid = await Lucid.new( - provider, - settings.network, - ); - resolve(lucid); + let lucid = await Lucid.new( + provider, + settings.network, + ); + resolve(lucid); }); } diff --git a/README.md b/README.md index 3fb80e3..1b6c57c 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,11 @@ # BroClanWallet Bro Clan is a multisig Wallet for the Cardano ecosystem. -## Running BroClan: - - +This is the monorepo of the software that runs The [BroClan Multisig Wallet](https://broclan.io) -You can run access this app via our servise on broclan.io +## Running BroClan: - + We also provide dockerfiles and docker Images for all components.